aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-12-19 18:03:14 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-12-19 18:03:14 +0000
commitba37c8851d6c52dabc964371df0a996c256c1391 (patch)
tree07b8e61e3718678e6d2cbc89f4f6ccad664f5172 /socket.c
parentbe297b4d957ea1808c6134185f9c70ac5a0a01f4 (diff)
downloadfetchmail-ba37c8851d6c52dabc964371df0a996c256c1391.tar.gz
fetchmail-ba37c8851d6c52dabc964371df0a996c256c1391.tar.bz2
fetchmail-ba37c8851d6c52dabc964371df0a996c256c1391.zip
Line-buffer all socket streams.
svn path=/trunk/; revision=665
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/socket.c b/socket.c
index dbab9254..ddbf2f93 100644
--- a/socket.c
+++ b/socket.c
@@ -35,17 +35,11 @@
#endif
/*
- * In case we ever optimize this further,
- * a note on Carl Harris's original implementation said:
- *
* Size of buffer for internal buffering read function
* don't increase beyond the maximum atomic read/write size for
* your sockets, or you'll take a potentially huge performance hit
- *
- * #define INTERNAL_BUFSIZE 2048
- *
- * Note that stdio's 1024-byte default is just fine.
*/
+#define INTERNAL_BUFSIZE 2048
FILE *sockopen(char *host, int clientPort)
{
@@ -53,7 +47,9 @@ FILE *sockopen(char *host, int clientPort)
unsigned long inaddr;
struct sockaddr_in ad;
struct hostent *hp;
-
+ FILE *fp;
+ static char sbuf[INTERNAL_BUFSIZE];
+
memset(&ad, 0, sizeof(ad));
ad.sin_family = AF_INET;
@@ -77,7 +73,9 @@ FILE *sockopen(char *host, int clientPort)
close(sock);
return (FILE *)NULL;
}
- return fdopen(sock, "r+");
+ fp = fdopen(sock, "r+");
+ setvbuf(fp, sbuf, _IOLBF, INTERNAL_BUFSIZE);
+ return(fp);
}
/* socket.c ends here */