From ca2fa92632c69041aa6a5de2c46a6ff042ddd4ad Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 8 Dec 1998 20:47:04 +0000 Subject: [PATCH] * Discovered that the HTTP socket problem is related to a socket that isn't properly lingering on close. Temporarily hacked a sleep(10) into context_loop.c until it is figured out. --- webcit/ChangeLog | 5 +++++ webcit/auth.c | 4 ++++ webcit/child.h | 1 + webcit/context_loop.c | 10 +++++++--- webcit/tcp_sockets.c | 12 ++++++------ webcit/webcit.c | 3 +-- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 0811d277c..ec438d105 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,3 +1,8 @@ +Tue Dec 8 15:45:42 EST 1998 Art Cancro + * Discovered that the HTTP socket problem is related to a socket that + isn't properly lingering on close. Temporarily hacked a sleep(10) + into context_loop.c until it is figured out. + Mon Dec 7 17:03:18 EST 1998 Art Cancro * Did a little debugging, still trying to figure out why logging in displays "Connection reset by peer" error. It used to work... diff --git a/webcit/auth.c b/webcit/auth.c index ef8d83ef0..3796b91ad 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -102,6 +102,10 @@ void do_login(void) { output_headers(); wprintf("Nope\n"); wprintf("Your password was not accepted.\n"); + wprintf("
\n");
+		wprintf("%s\n", buf);
+		dump_vars();
+		wprintf("

\n"); wprintf("
Try again\n"); wprintf("\n"); wDumpContent(); diff --git a/webcit/child.h b/webcit/child.h index d95ffb468..070339dfb 100644 --- a/webcit/child.h +++ b/webcit/child.h @@ -36,3 +36,4 @@ void escputs(char *strbuf); void url(char *buf); void escputs1(char *strbuf, int nbsp); long extract_long(char *source, long int parmnum); +void dump_vars(void); diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 17085bf19..944619cf3 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -129,10 +129,12 @@ void *context_loop(int sock) { int ContentLength; int CloseSession = 0; - if ((req = malloc(sizeof(char[256][256]))) == NULL) { - printf("Can't malloc buffers; dropping connection.\n"); + if ((req = malloc((long)sizeof(char[256][256]))) == NULL) { + sprintf(buf, "Can't malloc buffers; dropping connection.\n"); + fprintf(stderr, "%s", buf); + write(sock, buf, strlen(buf)); close (sock); - return NULL; + pthread_exit(NULL); } printf("Reading request from socket %d\n", sock); @@ -250,6 +252,8 @@ void *context_loop(int sock) { * to support HTTP/1.1 "persistent" connections by looping back to * the top of this function. For now, we'll just close. */ + printf(" Lingering...\n"); + sleep(10); printf(" Closing socket\n"); close(sock); diff --git a/webcit/tcp_sockets.c b/webcit/tcp_sockets.c index 34781617d..017e1ea73 100644 --- a/webcit/tcp_sockets.c +++ b/webcit/tcp_sockets.c @@ -33,7 +33,7 @@ int serv_sock; RETSIGTYPE timeout(int signum) { - printf("\rConnection timed out.\n"); + fprintf(stderr, "Connection timed out.\n"); exit(3); } @@ -53,7 +53,7 @@ int connectsock(char *host, char *service, char *protocol) sin.sin_port = pse->s_port; } else if ((sin.sin_port = htons((u_short)atoi(service))) == 0) { - fprintf(stderr,"can't get %s service entry\n", service); + fprintf(stderr, "Can't get %s service entry\n", service); return(-1); } @@ -62,13 +62,13 @@ int connectsock(char *host, char *service, char *protocol) bcopy(phe->h_addr,(char *)&sin.sin_addr,phe->h_length); } else if ((sin.sin_addr.s_addr = inet_addr(host))==INADDR_NONE) { - fprintf(stderr,"can't get %s host entry: %s\n", + fprintf(stderr, "Can't get %s host entry: %s\n", host,strerror(errno)); return(-1); } if ((ppe=getprotobyname(protocol))==0) { - fprintf(stderr,"can't get %s protocol entry: %s\n", + fprintf(stderr, "Can't get %s protocol entry: %s\n", protocol,strerror(errno)); return(-1); } @@ -80,7 +80,7 @@ int connectsock(char *host, char *service, char *protocol) s = socket(PF_INET,type,ppe->p_proto); if (s<0) { - fprintf(stderr,"can't create socket: %s\n",strerror(errno)); + fprintf(stderr, "Can't create socket: %s\n", strerror(errno)); return(-1); } @@ -175,7 +175,7 @@ void serv_puts(char *string) { char buf[256]; - sprintf(buf,"%s\n",string); + sprintf(buf,"%s\n", string); serv_write(buf, strlen(buf)); } diff --git a/webcit/webcit.c b/webcit/webcit.c index 9492d8832..33907faae 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -122,7 +122,7 @@ void free_urls(void) { /* * Diagnostic function to display the contents of all variables */ -void dump_vars() { +void dump_vars(void) { struct urlcontent *u; for (u = urlstrings; u != NULL; u = u->next) { @@ -158,7 +158,6 @@ void wprintf(const char *format, ...) { va_start(arg_ptr, format); vsprintf(wptr->w_data, format, arg_ptr); va_end(arg_ptr); - } int wContentLength(void) { -- 2.39.2