diff options
-rw-r--r-- | Makefile.in | 11 | ||||
-rw-r--r-- | acconfig.h | 3 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | socket.c | 33 |
4 files changed, 42 insertions, 7 deletions
diff --git a/Makefile.in b/Makefile.in index e7dea005..21153574 100644 --- a/Makefile.in +++ b/Makefile.in @@ -154,6 +154,7 @@ fetchmail.spec: $(srcdir)/Makefile.in $(srcdir)/specgen.sh clean: -rm -f fetchmail *.o core fetchmail.dvi \ rcfile_l.c rcfile_y.h rcfile_y.c fetchmail.tar fetchmail.tar.gz + -rm -f linetest[12] distclean: clean -rm -f Makefile config.h @@ -179,6 +180,9 @@ stamp-config: config.status $(srcdir)/config.h.in configure: configure.in autoconf $(ACFLAGS) +config.h.in: acconfig.h + autoheader $(ACFLAGS) + # This tells versions [3.59,3.63) of GNU make not to export all variables. .NOEXPORT: @@ -215,6 +219,13 @@ fetchmail-$(VERS).tar: $(all) fetchmail-$(VERS).tar.gz: fetchmail-$(VERS).tar gzip -f fetchmail-$(VERS).tar +# Test for stdio line-buffering lossage on sockets +linetest1: socket.c + $(CC) -g -I. -DMAIN socket.c -o linetest1 # Use setlinebuf +linetest2: socket.c + $(CC) -g -I. -DMAIN -D__SETVBUF_WORKS_OK__=1 socket.c -o linetest2 # Use setvnbuf + + # The automatically generated dependencies below may omit config.h # because it is included with ``#include <config.h>'' rather than # ``#include "config.h"''. So we add the explicit dependency to make sure. @@ -32,6 +32,9 @@ /* Define if you have GNU's getopt family of functions. */ #undef HAVE_GETOPTLONG +/* Define if you have setlinebuf(3) */ +#undef HAVE_SETLINEBUF + /* Leave that blank line there!! Autoheader needs it. If you're adding to this file, keep in mind: diff --git a/configure.in b/configure.in index 2bda847b..d988c620 100644 --- a/configure.in +++ b/configure.in @@ -77,7 +77,7 @@ AC_SUBST(EXTRASRC) AC_SUBST(EXTRAOBJ) AC_CHECK_FUNCS(tcsetattr stty setsid seteuid gethostbyname res_search herror \ - strrchr strerror) + strrchr strerror setlinebuf) dnl AC_FUNC_SETVBUF_REVERSED @@ -48,7 +48,6 @@ FILE *sockopen(char *host, int clientPort) struct sockaddr_in ad; struct hostent *hp; FILE *fp; - static char sbuf[INTERNAL_BUFSIZE]; memset(&ad, 0, sizeof(ad)); ad.sin_family = AF_INET; @@ -75,17 +74,39 @@ FILE *sockopen(char *host, int clientPort) } fp = fdopen(sock, "r+"); -#ifdef FOO +#ifdef __SETVBUF_WORKS_OK__ /* - * For unknown reasons, this results in horrible lossage. + * For unknown reasons, this results in horrible lossage under Linux. * To see this, condition in this line, generate a test pattern * of 8K, fetch it, and watch it garble the test pattern. - * I think there's a bug in stdio lurking here. + * I think there's a bug in Linux stdio lurking here. */ - setvbuf(fp, sbuf, _IOLBF, INTERNAL_BUFSIZE); -#endif /* FOO */ + { + static char sbuf[INTERNAL_BUFSIZE]; + setvbuf(fp, sbuf, _IOLBF, INTERNAL_BUFSIZE); + } +#endif /* __SETVBUF_WORKS_OK__ */ + +#if !defined(__SETVBUF_WORKS_OK__) && defined(HAVE_SETLINEBUF) + /* this on the other hand works OK under Linux */ + setlinebuf(fp); +#endif return(fp); } +#ifdef MAIN +/* + * Use the chargen service to test buffering directly. + */ +main() +{ + FILE *fp = sockopen("localhost", 19); + char buf[80]; + + while (fgets(buf, sizeof(buf)-1, fp)) + fputs(buf, stdout); +} +#endif /* MAIN */ + /* socket.c ends here */ |