Hm, if that be the case (and it does look likely), then the same lines 
probably need to be entered between lines 289 and 290 of server.c. 
(After the "Couldn't allocate server name." error.)  Either that or we 
should have a new function that does all the freeing.

Also, it looks like "server->connection" on line 278, in 
"if(server->connection == NULL)", should probably be "server->idleHandler".

Here's a plausible patch for all of it:

diff -rN -u old_server.c server.c
--- old_server.c        2008-09-07 16:21:20.000000000 -0600
+++ server.c    2009-04-22 16:33:52.515625000 -0600
@@ -103,6 +103,19 @@
  }

  static void
+freeServer(HTTPServerPtr server)
+{
+    if (server->connection != NULL)
+        free(server->connection);
+    if (server->idleHandler != NULL)
+        free(server->idleHandler);
+    if (server->name != NULL)
+        free(server->name);
+
+    free(server);
+}
+
+static void
  discardServer(HTTPServerPtr server)
  {
      HTTPServerPtr previous;
@@ -117,7 +130,7 @@
          previous->next = server->next;
      }

-    free(server);
+    freeServer(server);
  }

  static int
@@ -270,15 +283,14 @@
      server->connection = malloc(serverMaxSlots * 
sizeof(HTTPConnectionPtr));
      if(server->connection == NULL) {
          do_log(L_ERROR, "Couldn't allocate server.\n");
-        free(server);
+        freeServer(server);
          return NULL;
      }

      server->idleHandler = malloc(serverMaxSlots * 
sizeof(FdEventHandlerPtr));
-    if(server->connection == NULL) {
+    if(server->idleHandler == NULL) {
          do_log(L_ERROR, "Couldn't allocate server.\n");
-        free(server->connection);
-        free(server);
+        freeServer(server);
          return NULL;
      }

@@ -287,7 +299,7 @@
      server->name = strdup(name);
      if(server->name == NULL) {
          do_log(L_ERROR, "Couldn't allocate server name.\n");
-        free(server);
+        freeServer(server);
          return NULL;
      }


Ken

Ming Fu wrote:
> Hi,
> 
> There is a number of malloc memories attached to server. These memory are
> allocated in getServer function. They need to be freed.
> 
> ***************
> *** 124,129 ****
> --- 125,139 ----
>               previous = previous->next;
>           previous->next = server->next;
>       }
> +       /*
> +          * Need to free structures attached to the server
> +       */
> +     if (server->connection)
> +        free(server->connection);
> +     if (server->idleHandler)
> +        free(server->idleHandler);
> +     if (server->name)
> +        free(server->name);
> 
>       free(server);
>   }
> 
> BTW, is there a way to control the total number of servers besides
> shortening the serverExpireTime?
> 
> Regards,
> Ming
> ------------------------------------------------------------------------------
> Stay on top of everything new and different, both inside and 
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today. 
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> Polipo-users mailing list
> Polipo-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/polipo-users
> 

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Polipo-users mailing list
Polipo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/polipo-users

Reply via email to