aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-remote-store.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-01-17 07:27:51 +0800
committerDan Winship <danw@src.gnome.org>2001-01-17 07:27:51 +0800
commit3f72f5232033c8ba639a73f96faf0b8d801e7d78 (patch)
treead7d615dbf20b0f20cea59fcd793feb860bae22e /camel/camel-remote-store.c
parentb7e8dd7d688c1c302a834f35806f0509f15433fe (diff)
downloadgsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.tar
gsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.tar.gz
gsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.tar.bz2
gsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.tar.lz
gsoc2013-evolution-3f72f5232033c8ba639a73f96faf0b8d801e7d78.tar.xz
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-remote-store.c')
-rw-r--r--camel/camel-remote-store.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c
index 993d9b5778..ef6fe56df0 100644
--- a/camel/camel-remote-store.c
+++ b/camel/camel-remote-store.c
@@ -240,15 +240,16 @@ static int socket_connect(struct hostent *h, int port)
return fd;
} else {
fd_set rdset, wrset;
- long flags;
- int fdmax;
+ int flags, fdmax;
- fcntl(fd, F_GETFL, &flags);
+ flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
ret = connect(fd, (struct sockaddr *)&sin, sizeof (sin));
- if (ret == 0)
+ if (ret == 0) {
+ fcntl(fd, F_SETFL, flags);
return fd;
+ }
if (errno != EINPROGRESS) {
close(fd);