W3C home > Mailing lists > Public > www-lib@w3.org > October to December 2002

pseudo-threaded / non preemptive server?

From: Timothee Besset <ttimo@idsoftware.com>
Date: Wed, 18 Dec 2002 11:15:27 -0500 (EST)
To: www-lib@w3.org
Cc: zerodeux@zerodeux.net
Message-Id: <20021218171352.5309cd93.ttimo@idsoftware.com>

I am trying to put together a pseudo-threaded / non preemptive server
application. I compiled Library/Examples/listen.c, but even though the
listen socket has it's options set as non blocking, the event loop
select() call is blocking.

I have attached the trace of an unmodified version of listen. You clearly
see the socket being binded as non-blocking:

Socket...... Created 3
Net Manager. Increasing active sockets to 1, 0 persistent sockets
Socket...... Turned off Nagle's algorithm
Socket...... Non-blocking socket

And at first event loop iteration:

Event....... Registering socket for HTEvent_ACCEPT
Event....... New value for MaxSock is 3
Event Loop.. calling select: maxfds is 3
............. READ : 3
............. WRITE:
............. OOB  :

And it blocks..

So I started digging deeper into the HTEvtLst.c code, and found out that
there is a NULL timeout value being passed to the select() call. That's it!

Added HTHost_setEventTimeout(0); in listen.c, and now it's correctly
working as non-preemptive. Just wanted to share the joy (and in case push
this for an update in listen.c)

Received on Thursday, 19 December 2002 13:27:16 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:55 UTC