Day47 - Multi-message TX Queue & EPOLLOUT Pipeline¶
Key Concepts¶
- TCP is stream-based, not message-based.
send()may send only partial data.- Each pending TX message needs its own offset.
- TX queue stores multiple pending responses.
- EPOLLOUT should be enabled only when TX queue is not empty.
TX Queue Model¶
struct tx_msg {
unsigned char *buf;
size_t len;
size_t offset;
};
struct tx_queue {
struct tx_msg msgs[MAX_TXQ_MSG];
size_t head;
size_t tail;
size_t count;
};
Flow¶
EPOLLIN:
recv raw bytes
generate response
tx_queue_push()
enable EPOLLOUT
EPOLLOUT:
front message
send remaining bytes
update offset
if message done:
pop and free
if queue empty:
disable EPOLLOUT
Important Finding¶
Current server treats each recv() result as one application message. This is not protocol-correct because TCP may merge or split data.
Next step: RX buffer + protocol parser.