aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-28 03:49:39 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-28 03:49:39 +0000
commitb1000cb703b852ea6c7493d9d8d24780e4a3b157 (patch)
treecd6a56441d638475c0b331cda5b3c0c7c1fbfd5f /socket.c
parentcab2269e10d82e3e5e371889b42d19d0cafc9eaa (diff)
downloadfetchmail-b1000cb703b852ea6c7493d9d8d24780e4a3b157.tar.gz
fetchmail-b1000cb703b852ea6c7493d9d8d24780e4a3b157.tar.bz2
fetchmail-b1000cb703b852ea6c7493d9d8d24780e4a3b157.zip
Cleanup for PL3.
svn path=/trunk/; revision=402
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/socket.c b/socket.c
index ba281a31..52f88e95 100644
--- a/socket.c
+++ b/socket.c
@@ -192,28 +192,30 @@ int len;
for data. */
int SockDataWaiting(int socket)
{
- int flags;
- char sbuf[INTERNAL_BUFSIZE];
- int n;
- int res;
- flags = fcntl(socket,F_GETFL,0);
+ int flags;
+ char sbuf[INTERNAL_BUFSIZE];
+ int n;
+ flags = fcntl(socket,F_GETFL,0);
- /* set it to non-block */
- if (fcntl(socket,F_SETFL,flags | O_NONBLOCK) == -1)
- return -1;
+ /* set it to non-block */
+ if (fcntl(socket,F_SETFL,flags | O_NONBLOCK) == -1)
+ return -1;
+
+ n = recv(socket,sbuf,INTERNAL_BUFSIZE,MSG_PEEK);
+
+ /* reset it to block (or, whatever it was). */
+ fcntl(socket,F_SETFL,flags);
- if ((n = recv(socket,sbuf,INTERNAL_BUFSIZE,MSG_PEEK)) == -1)
+ if (n == -1)
{
- /* No data to read. */
- if (errno == EWOULDBLOCK)
- res = 0;
+ /* No data to read. */
+ if (errno == EWOULDBLOCK)
+ return(0);
+ else
+ return(-1);
}
- else
- res = n;
-
- /* reset it to block (or, whatever it was). */
- fcntl(socket,F_SETFL,flags);
- return res;
+ else
+ return(n);
}