From ffe3a796eda21cb75c6e0c6678b5bb20fb49c79f Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 15 Jan 2001 23:31:40 +0000 Subject: Updated to be able to get the CAMEL_SOCKOPT_NONBLOCKING socket opt. 2001-01-15 Jeffrey Stedfast * camel-tcp-stream-raw.c (stream_getsockopt): Updated to be able to get the CAMEL_SOCKOPT_NONBLOCKING socket opt. (stream_setsockopt): Updated to be able to set the CAMEL_SOCKOPT_NONBLOCKING socket opt. svn path=/trunk/; revision=7519 --- camel/ChangeLog | 11 +++++++++-- camel/camel-tcp-stream-raw.c | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 43e7245117..b0766558b1 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,7 +1,14 @@ +2001-01-15 Jeffrey Stedfast + + * camel-tcp-stream-raw.c (stream_getsockopt): Updated to be able + to get the CAMEL_SOCKOPT_NONBLOCKING socket opt. + (stream_setsockopt): Updated to be able to set the + CAMEL_SOCKOPT_NONBLOCKING socket opt. + 2001-01-15 Peter Williams - * providers/imap/camel-imap-folder.c (camel_imap_folder_new): Lock around the - imap_rescan, which needs it. + * providers/imap/camel-imap-folder.c (camel_imap_folder_new): Lock + around the imap_rescan, which needs it. 2001-01-15 Not Zed diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c index 5c884fd136..53722034de 100644 --- a/camel/camel-tcp-stream-raw.c +++ b/camel/camel-tcp-stream-raw.c @@ -247,6 +247,17 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data) if ((optname = get_sockopt_optname (data)) == -1) return -1; + if (data->option == CAMEL_SOCKOPT_NONBLOCKING) { + long flags; + + if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL, &flags) == -1) + return -1; + + data->value.non_blocking = flags & O_NONBLOCK; + + return 0; + } + return getsockopt (((CamelTcpStreamRaw *)stream)->sockfd, get_sockopt_level (data), optname, @@ -262,6 +273,21 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data) if ((optname = get_sockopt_optname (data)) == -1) return -1; + if (data->option == CAMEL_SOCKOPT_NONBLOCKING) { + guint32 flags, set; + + if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL, &flags) == -1) + return -1; + + set = data->value.non_blocking ? 1 : 0; + flags = (flags & ~O_NONBLOCK) | (set & O_NONBLOCK); + + if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_SETFL, flags) == -1) + return -1; + + return 0; + } + return setsockopt (((CamelTcpStreamRaw *)stream)->sockfd, get_sockopt_level (data), optname, -- cgit