- From: Jens Meggers <jens.meggers@firepad.com>
- Date: Sun, 25 Mar 2001 14:31:03 -0800
- To: "'www-lib@w3.org'" <www-lib@w3.org>
- Message-ID: <DDF913B74F07D411B22500B0D0206D9F185475@FIREPLUG>
Hi, I have an improvement suggestion for HTMemory.c. As we know, libwww is not thread safe. However, when integrating the latest patches it is very reliable when using the async mode, which is equally powerful compared to multithreading. In some cases, it also might have some advantages. Having this in mind, an implementation might want to run libwww in a separate thread, waiting for some results and fork a thread to process the data libwww received from a web server. The HTChunk() data structure are very convenient for doing so as it forms the basis for request outputs. Unfortunatly, HTChunk() is not thread safe simply because HTMemory.c is not. For example, check out this code in HTmemory: PUBLIC void * HTMemory_calloc (size_t nobj, size_t size) { void * ptr; ptr = calloc(nobj, LastAllocSize = size); ... here, the input into a function is taken from the output of an assignment to a global static valiable. This is not thread safe because a different thread may change the valiable in between the call, leading to wrong input parameters. Because of that I suggest to change the code to PUBLIC void * HTMemory_calloc (size_t nobj, size_t size) { void * ptr; LastAllocSize = size ptr = calloc(nobj, size); ... I have attached a diff file that does includes all other changes. Jens <<diff.txt>>
Attachments
- text/plain attachment: diff.txt
Received on Sunday, 25 March 2001 17:41:29 UTC