diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-10-31 08:46:37 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-10-31 08:46:37 +0000 |
commit | 5e5aa7075cefa4a53bcc10359619a366ad712189 (patch) | |
tree | 727a025145ed593456f747e555282e26f59ca103 | |
parent | 913459f3ed6c7e9316986419855671d3fa769d4b (diff) | |
download | fetchmail-5e5aa7075cefa4a53bcc10359619a366ad712189.tar.gz fetchmail-5e5aa7075cefa4a53bcc10359619a366ad712189.tar.bz2 fetchmail-5e5aa7075cefa4a53bcc10359619a366ad712189.zip |
STEP 9: Eliminate the static buffer in the socket library.
svn path=/trunk/; revision=453
-rw-r--r-- | socket.c | 49 |
1 files changed, 1 insertions, 48 deletions
@@ -93,53 +93,6 @@ FILE *sockfp; return wrlen; } -static int sbuflen = 0; - -static int SockInternalRead (socket,buf,len) -int socket; -char *buf; -int len; -{ - static char sbuf [INTERNAL_BUFSIZE]; - static char *bp; - - if (sbuflen <= 0) { - /* buffer is empty; refresh. */ - if ((sbuflen = read(socket,sbuf,INTERNAL_BUFSIZE)) < 0) { - if (errno == EINTR) - return -1; - perror("SockInternalRead: read"); - exit(9); - } - else - bp = sbuf; - } - else - ; /* already some data in the buffer */ - - /* can't get more than we have right now. */ - /* XXX -- should probably try to load any unused part of sbuf - so that as much of 'len' as possible can be satisfied */ - if (len > sbuflen) - len = sbuflen; - else - ; /* wants no more than we already have */ - - /* transfer to caller's buffer */ - if (len == 1) { - /* special case: if caller only wants one character, it probably - costs a lot more to call bcopy than to do it ourselves. */ - *buf = *(bp++); - sbuflen--; - } - else { - bcopy(bp,buf,len); - sbuflen -= len; - bp += len; - } - return(len); -} - int SockGets(buf, len, sockfp) char *buf; int len; @@ -149,7 +102,7 @@ FILE *sockfp; while (--len) { - if (SockInternalRead(fileno(sockfp), buf, 1) != 1) + if (read(fileno(sockfp), buf, 1) != 1) return -1; else rdlen++; |