W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2002

post.c too slow due to select() sleeping in event loop - what to do?

From: Wells, Charles <cwells@rational.com>
Date: Mon, 11 Mar 2002 13:16:22 -0500
Message-ID: <982A819715AC804D915E8A053B48CBB804DAE3F7@sus-ma1it04.rational.com>
To: "'www-lib@w3.org'" <www-lib@w3.org>
The example "post.c" is taking way to long to execute (at least on Unix
anyway).  I sort of know the reason for this, but not the best solution.
The HTEventList_loop function is calling the select function with a time
value, and the system is going to sleep for a second.  The servlet on the
server-side is trying to read from its input stream (i.e. the data sent from
the client), and the read function waits for a second while the client gets
around to waking up and sending the data.

Now, if I just write an HTML file like this:

<form action="http://thehostname:8080/examples/servlet/TroubleShooter"
<input type=submit value="Submit">
<input type=hidden name=thename value="Bunch of junk">

and I open that in IE and press the submit button, that same server handles
the post almost instantly.  post.c is similar to this HTML's functionality,
except that it takes too long to execute.

I don't really care about post.c except that I am patterning my own code
after post.c, and that file sufficiently demonstrates this problem.  My
code, however, won't prompt for a filename and it will keep making requests
for the life of the application (i.e. the terminate_handler will not exit
the application after the first request).

What's the best way to make post.c fast?  Should I try synchronous instead
of asynchronous (haven't got that to work yet)?  Do I need to write my own
event loop?  Surely others on the list must have solved this, because this
default behavior is unusably slow (yes, 1 second is unusably slow if you are
trying to do thousands of requests using SOAP or something similar).

Received on Monday, 11 March 2002 13:17:03 UTC

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