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

cleaning up HostTable

From: Raffaele Sena <raff@nuvomedia.com>
Date: Thu, 25 Mar 1999 18:13:58 -0800
Message-ID: <016901be772e$4edc1640$52c0a8c0@tux.nuvomedia.com>
To: "libwww" <www-lib@w3.org>
As I said before, I'm using libwww in a somewhat strange way.

I have a module that can be called to process HTML pages. This module
initialize the library, use it and then release it (by calling
HTLibTerminate).

The main application can call the module again and reuse it. So, if the
HTLibTerminate
doesn't correctly clean up the global data structures (or at least leave
them in a
consistent state) libwww will crash at the next attempt.

So, I'm not completely sure on how this happen (or better, why it does not
happen on every
page), but I got this crash when downloading a specific page multiple times.
I found out
the channels were deleted (HTLibTerminate calls HTChannel_deleteAll), but
the HTHost objects
referencing them were not cleaned up. So, I added an HTHost_deleteAll and
called it before
HTChannel_delete all. Maybe this is too much, but it works.

-- Raffaele

--------------------------- 8< CUT HERE
>8 ----------------------------------
cvs diff HTLib.c HTHost.html HTHost.c (in directory
c:\SOFTWAREDEV\LIBWWW\Library\src)
Index: HTLib.c
===================================================================
RCS file: /sources/public/libwww/Library/src/HTLib.c,v
retrieving revision 2.15
diff -r2.15 HTLib.c
190a191
>     HTHost_deleteAll();  /* Delete remaining hosts */
Index: HTHost.html
===================================================================
RCS file: /sources/public/libwww/Library/src/HTHost.html,v
retrieving revision 2.27
diff -r2.27 HTHost.html
79a80,87
>   Delete the Host table
> </H3>
> <P>
> Cleanup and delete the host table.
> <PRE>
> extern void HTHost_deleteAll (void);
> </PRE>
> <H3>
Index: HTHost.c
===================================================================
RCS file: /sources/public/libwww/Library/src/HTHost.c,v
retrieving revision 2.61
diff -r2.61 HTHost.c
451a452,477
> ** Cleanup the host list
> */
> PUBLIC void HTHost_deleteAll (void)
> {
>     HTList * list;
>     HTHost * host;
>     int i;
>
>     if (!HostTable)
>  return;
>
>     for (i=0; i < HOST_HASH_SIZE; i++) {
>  list = HostTable[i];
>  if (!list) continue;
>
>  while ((host = (HTHost *) HTList_removeFirstObject(list)) != NULL)
>      free_object(host);
>
>  HTList_delete(list);
>     }
>
>     HT_FREE(HostTable);
>     HostTable = NULL;
> }
>
> /*
1056a1083
>       host->channel = NULL;
1075c1102
<                 if (HTChannel_delete(host->channel, status))
---
>                 if (HTChannel_delete(host->channel, status)) {
1077c1104,1105
<
---
>       host->channel = NULL;
>                 }
1109a1138
>  host->lock = HTList_firstObject(host->pending);
Received on Thursday, 25 March 1999 21:13:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:29 GMT