- From: Jerry G. Chiuan <jerry@oridus.com>
- Date: Mon, 8 Sep 2003 21:21:34 -0700
- To: <www-lib@w3.org>
- Message-ID: <003f01c37689$da73b8c0$25a8a8a8@piglet>
> Since libwww is not thread safe, any solution of yours in which several > threads access libwww would simply have one "libwww thread" which gets > handed the requests from the other threads and passes them to libwww. > > I must say I'm not really sure what you have in mind. :) > > Maybe you're thinking in terms of the example libwww programs which all > have code which first sends the request, then calls some other libwww > functions and blocks until they return the data. > > This is not how you should use libwww once your program has >1 concurrent > requests running. You can't run in parallel several threads which do this > - libwww will crash! Hi, In my applications, there are 2 threads, in which I new individual HT_Request. These 2 threads send out their own requests in their own loop at the same time by using HTPostDataAnchorToChunk( ) I "thought" they both would use their own libwww object, however, they actually send out requests via the same <port, ip> underlying ( I use sniffer and found it ) is it because there is only one thread which ends up taking care of sending the requests no matter how many HT_Requests we construct on the top? The code doesn't crash, but: one of the threads only sends out http header first, and its body is not sent out until another thread sends out its request, the order is 1. First of all, 1st thread sends requests continously..... 2. at this time, 2nd thread starts and sends out its 1st request, but ONLY header is sent out first ( use the same connection as 1st thread uses ) 3. then, 1st thread sends out next request, the header is sent out first 4. then, the body of 2nd thread's request is now sent out ( it seems to me that it is flushed out ) 5. then, the body of 1st thread's request is sent out The server actually can receive all requests, but it will response "Bad Request" for the last request Is it because the libwww is locked by 1st thread, and the body of 2nd thread's request can't be sent out until 1st thread comes back to send its request Is it possible to run multiple threads in simultaneously to send requests by using seperate <port, ip> (multiple different TCP connections) ? - Jerry
Received on Tuesday, 9 September 2003 00:18:09 UTC