On Fri, Apr 11, 2008 at 11:49:26PM +0200, Andreas Kemnade wrote:
Hi Jorge,
On Fri, 11 Apr 2008 15:34:49 -0400 Jorge Arellano Cid <jcid@dillo.org> wrote:
Note: What still puzzles me, is why accept() returns when there's nothing to read.
Hmm, accept() returns when you call connect() on the other side. Many TCP server programs send stuff to the client before receiving anything from the client (like ssh servers, smtp servers) so there is nothing unusual about that.
So, normally you have on cookies.dpi side: accept() returns after connect() on dillo side read() returns after write() on dillo side
then on dillo side: read() returns after write() on cookies.dpi side.
As far as I understand in the race condition case you have:
dillo cookies.dpi connect(sock1,...) sock1=accept(....) connect(sock2,...) (via a_Dpi_send_blocking_cmd) read(sock1,...) write(sock2,...) (does not block, contents will be added to the recv queue) read(sock2,...)
and now, both sides are waiting for data,....
Thanks a lot for the explanation. -- Cheers Jorge.-