[PATCH] Maintain outgoing TCP meta buffer

Scott Lamb slamb at slamb.org
Sat Jan 14 20:56:11 CET 2006


On Jan 14, 2006, at 11:39 AM, Guus Sliepen wrote:
> Another option is to do nothing in send_tcppacket() if there is more
> than a certain number of bytes left in the buffer. Actually, on Linux
> you can see the amount of data left in the kernel's TCP buffers with
> ioctl(fd, SIOCOUTQ, &amount), but that is not portable and does not  
> give
> any guarantees about write() not returing EWOULDBLOCK.

Well, I want to do the userland buffering anyway, because it solves  
the problem of consolidating the write calls. So once I implement  
that buffering, I don't think there's much advantage to avoiding  
EWOULDBLOCK entirely, if that's what you're saying.

Here's a modified patch that adds a new PongTimeout, signifying how  
long we're willing to wait for a response. This is both the response  
to PINGs and how long we're willing to wait for it to flush (ACKs).  
So if the kernel's buffer has room, it will now take PingTimeout 
+PongTimeout+some seconds rather than 2*PingTimeout+some seconds for  
it to realize it. If the kernel's buffer is full, it will take it  
PongTimeout+some seconds to realize it. I defaulted PongTimeout to 5.

It's also a bit less dumb. Some of my copying in send_meta was  
totally unnecessary, and it's gone now. And I just realized that  
connections are reused after terminate_connection, so I cleaned up my  
buffer completely. (c->outbuf == NULL && c->outbufsize > 0 is trouble.)

Regards,
Scott

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tinc-buffer-2.patch
Type: application/octet-stream
Size: 14374 bytes
Desc: not available
Url : http://brouwer.uvt.nl/pipermail/tinc-devel/attachments/20060114/b8b78875/tinc-buffer-2-0001.obj


More information about the tinc-devel mailing list