diff options
author | Tor Lillqvist <tml@novell.com> | 2008-06-04 13:25:57 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2008-06-04 13:25:57 +0000 |
commit | 3e27f4722e8afe083c41c899b227b8cb6c8db01e (patch) | |
tree | 3d6adcfe4bd9e5bbc8e799c0c6ddd16d8efc1fee | |
parent | a1eb436848f7514182e2441b5f4ab5005d24e7c6 (diff) | |
download | libsoup-3e27f4722e8afe083c41c899b227b8cb6c8db01e.tar.gz |
The SO_RCVTIMEO and SO_SNDTIMEO options to setsockopt() take int values,
2008-06-04 Tor Lillqvist <tml@novell.com>
* libsoup/soup-socket.c (set_fdflags): The SO_RCVTIMEO and
SO_SNDTIMEO options to setsockopt() take int values, in
milliseconds, on Windows. Not struct timeval. Eek. So passing a
struct timeval meant that the tv_sec value (which is first in the
struct) is interpreted as milliseconds. setsockopt apparently
doesn't even get upset by the fact that the option size doesn't
match the sizeof(int) it should expect.
svn path=/trunk/; revision=1142
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | libsoup/soup-socket.c | 15 |
2 files changed, 24 insertions, 1 deletions
@@ -1,3 +1,13 @@ +2008-06-04 Tor Lillqvist <tml@novell.com> + + * libsoup/soup-socket.c (set_fdflags): The SO_RCVTIMEO and + SO_SNDTIMEO options to setsockopt() take int values, in + milliseconds, on Windows. Not struct timeval. Eek. So passing a + struct timeval meant that the tv_sec value (which is first in the + struct) is interpreted as milliseconds. setsockopt apparently + doesn't even get upset by the fact that the option size doesn't + match the sizeof(int) it should expect. + 2008-05-02 Dan Winship <danw@gnome.org> * libsoup/soup-cookie.c (soup_cookie_applies_to_uri): fix the path diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c index e5020865..4bc2d28f 100644 --- a/libsoup/soup-socket.c +++ b/libsoup/soup-socket.c @@ -333,8 +333,8 @@ static void set_fdflags (SoupSocketPrivate *priv) { int opt; - struct timeval timeout; #ifndef G_OS_WIN32 + struct timeval timeout; int flags; #endif @@ -357,6 +357,7 @@ set_fdflags (SoupSocketPrivate *priv) setsockopt (priv->sockfd, SOL_SOCKET, SO_REUSEADDR, (void *) &opt, sizeof (opt)); +#ifndef G_OS_WIN32 timeout.tv_sec = priv->timeout; timeout.tv_usec = 0; setsockopt (priv->sockfd, SOL_SOCKET, @@ -366,6 +367,18 @@ set_fdflags (SoupSocketPrivate *priv) timeout.tv_usec = 0; setsockopt (priv->sockfd, SOL_SOCKET, SO_SNDTIMEO, (void *) &timeout, sizeof (timeout)); +#else + if (priv->timeout < G_MAXINT / 1000) + opt = priv->timeout * 1000; + else + opt = 0; + + setsockopt (priv->sockfd, SOL_SOCKET, + SO_RCVTIMEO, (void *) &opt, sizeof (opt)); + + setsockopt (priv->sockfd, SOL_SOCKET, + SO_SNDTIMEO, (void *) &opt, sizeof (opt)); +#endif #ifndef G_OS_WIN32 priv->iochannel = |