There seems to be mem leak happening when a persistant ssl connection is enabled.
The leak actually happens in gethttp() and its related set of functions that register
and
check for persistant connectionsWhen a server promises a persistant connection we
register it
but later say the connection times out we close the socket descriptor but we donot
delete the
SSL struct causing the leak
Below is a patch that fixes that
===================================================================
file: wget/src/http.c
diff -u http.c
@@ -385,70 +231,70 @@
+ #ifdef HAVE_SSL
+# define SHUTDOWN_SSL(ssl) do { \
+if (ssl) \
+ shutdown_ssl (ssl); \
+} while (0)
+#else
+# define SHUTDOWN_SSL(ssl)
+#endif
/* Return non-zero if a persistent connection is available for
connecting to HOST:PORT. */
static int
persistent_available_p (const char *host, unsigned short port
#ifdef HAVE_SSL
, int ssl
#endif
)
{
unsigned char this_host[4];
/* First, check whether a persistent connection is active at all. */
if (!pc_active_p)
return 0;
/* Second, check if the active connection pertains to the correct
(HOST, PORT) ordered pair. */
if (port != pc_last_port)
return 0;
#ifdef HAVE_SSL
/* Second, a): check if current connection is (not) ssl, too. This
test is unlikely to fail because HTTP and HTTPS typicaly use
different ports. Yet it is possible, or so I [Christian
Fraenkel] have been told, to run HTTPS and HTTP simultaneus on
the same port. */
if (ssl != pc_active_ssl)
return 0;
#endif /* HAVE_SSL */
if (!store_hostaddress (this_host, host))
return 0;
if (memcmp (pc_last_host, this_host, 4))
return 0;
/* Third: check whether the connection is still open. This is
important because most server implement a liberal (short) timeout
on persistent connections. Wget can of course always reconnect
if the connection doesn't work out, but it's nicer to know in
advance. This test is a logical followup of the first test, but
is "expensive" and therefore placed at the end of the list. */
if (!test_socket_open (pc_last_fd))
{
/* Oops, the socket is no longer open. Now that we know that,
let's invalidate the persistent connection before returning
0. */
+ #ifdef HAVE_SSL
+ SHUTDOWN_SSL (pc_last_ssl);pc_last_ssl = NULL;
+ #endif
CLOSE (pc_last_fd);
invalidate_persistent ();
return 0;
}
return 1;
}
- #ifdef HAVE_SSL
- # define SHUTDOWN_SSL(ssl) do { \
- if (ssl) \
- shutdown_ssl (ssl); \
- } while (0)
- #else
- # define SHUTDOWN_SSL(ssl)
- #endif