From 3f72f5232033c8ba639a73f96faf0b8d801e7d78 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 16 Jan 2001 23:27:51 +0000 Subject: 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 --- camel/camel-stream-fs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'camel/camel-stream-fs.c') diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index 92c11435fa..c1758c1ab0 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -226,10 +226,9 @@ stream_read (CamelStream *stream, char *buffer, size_t n) } while (nread == -1 && errno == EINTR); } else { fd_set rdset; - long flags; - int fdmax; + int flags, fdmax; - fcntl(stream_fs->fd, F_GETFL, &flags); + flags = fcntl(stream_fs->fd, F_GETFL); fcntl(stream_fs->fd, F_SETFL, flags | O_NONBLOCK); FD_ZERO(&rdset); FD_SET(stream_fs->fd, &rdset); @@ -278,10 +277,9 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) } while (v == -1 && errno == EINTR); } else { fd_set rdset, wrset; - long flags; - int fdmax; + int flags, fdmax; - fcntl(stream_fs->fd, F_GETFL, &flags); + flags = fcntl(stream_fs->fd, F_GETFL); fcntl(stream_fs->fd, F_SETFL, flags | O_NONBLOCK); FD_ZERO(&rdset); FD_ZERO(&wrset); -- cgit v1.2.3