diff options
author | Dan Winship <danw@src.gnome.org> | 2001-01-17 07:27:51 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-01-17 07:27:51 +0800 |
commit | 3f72f5232033c8ba639a73f96faf0b8d801e7d78 (patch) | |
tree | ad7d615dbf20b0f20cea59fcd793feb860bae22e /camel/camel-tcp-stream-raw.c | |
parent | b7e8dd7d688c1c302a834f35806f0509f15433fe (diff) | |
download | gsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.tar.gz gsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.tar.zst gsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.zip |
fcntl(fd, F_GETFL) returns the flags as the return value, not via a passed
* camel-tcp-stream-raw.c (stream_getsockopt, stream_setsockopt):
* camel-stream-fs.c (stream_read, stream_write):
* camel-remote-store.c (socket_connect): fcntl(fd, F_GETFL)
returns the flags as the return value, not via a passed in
pointer. And F_SETFL looks for an int, not a long, and you have to
pass it what it's expecting because it's a va_arg parameter. (Yes,
the man page lies on Linux. But check the UNIX98 spec or the glibc
source.) Also, fix another bug in socket_connect: if we manage to
connect right away, unset O_NONBLOCK so it doesn't mess us up
later.
Fixes a bunch of problems with non-blocking I/O being done in the
allegedly-blocking case and then returning EWOULDBLOCK.
svn path=/trunk/; revision=7555
Diffstat (limited to 'camel/camel-tcp-stream-raw.c')
-rw-r--r-- | camel/camel-tcp-stream-raw.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c index 5886a30663..6467eed5da 100644 --- a/camel/camel-tcp-stream-raw.c +++ b/camel/camel-tcp-stream-raw.c @@ -243,9 +243,10 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data) return -1; if (data->option == CAMEL_SOCKOPT_NONBLOCKING) { - long flags; + int flags; - if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL, &flags) == -1) + flags = fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL); + if (flags == -1) return -1; data->value.non_blocking = flags & O_NONBLOCK; @@ -269,9 +270,10 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data) return -1; if (data->option == CAMEL_SOCKOPT_NONBLOCKING) { - guint32 flags, set; + int flags, set; - if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL, &flags) == -1) + fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL); + if (flags == -1) return -1; set = data->value.non_blocking ? 1 : 0; |