[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] HTTPS timeout fixed

From: Gregg Weber
Subject: [Bug-wget] HTTPS timeout fixed
Date: Fri, 08 Jan 2010 18:41:32 -0800
User-agent: Thunderbird (X11/20080421)

I noticed that wget still hangs if the https server dies after the initial handshake completes.
I found out it is due to the second call to SSL_shutdown locking up.
Well, it seems dumb to politely send a "close notify" alert to a server that is dead, I think it makes more sense to just go away after the server has already timed out.
So, here is my solution:

In http.c, define a new macro SHUTDOWN_SSL2

#ifdef HAVE_SSL
# define SHUTDOWN_SSL(ssl) do {        \
 if (ssl)                \
   shutdown_ssl (ssl);            \
} while (0)
# define SHUTDOWN_SSL2(ssl) do {        \
 if (ssl)                \
   shutdown_ssl_when_connection_is_dead (ssl);            \
} while (0)
# define SHUTDOWN_SSL(ssl)
# define SHUTDOWN_SSL2(ssl)

and change the CLOSE_INVALIDATE macro to call the new SHUTDOWN_SSL2

#define CLOSE_INVALIDATE(fd) do {        \
 SHUTDOWN_SSL2 (ssl);                \
 CLOSE (fd);                    \
 if (pc_active_p && (fd) == pc_last_fd)    \
   invalidate_persistent ();            \
} while (0)

And in gen_sslfunc.c define a new routine "shutdown_ssl_when_connection_is_dead"

shutdown_ssl_when_connection_is_dead (SSL* con)
 if (con == NULL)
 SSL_shutdown (con);
 SSL_free (con);

I tested the fix with this command:
wget --read-timeout=5 --tries=1 -O boz https://some_malfunctioning_server.com

It times out after 5 seconds, as it should.

What do you think?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]