X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Ftcp_sockets.c;h=de63f0ca5cf73baf4c62d8ca4af9dd92be9e9197;hb=371110dcb5394eb1762cc7f16042b666dd21042b;hp=bb4d6015e1b187b8d2f415f2ed4acdb80b9ca2ce;hpb=29d77ba7d45e9f02d8d0ea9cf69d4a68eb4c720c;p=citadel.git diff --git a/webcit/tcp_sockets.c b/webcit/tcp_sockets.c index bb4d6015e..de63f0ca5 100644 --- a/webcit/tcp_sockets.c +++ b/webcit/tcp_sockets.c @@ -18,8 +18,8 @@ /* * Uncomment this to log all communications with the Citadel server - */ #define SERV_TRACE 1 + */ #include "webcit.h" @@ -448,7 +448,8 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) if (is_https) { int ntries = 0; - if (StrLength(Hdr->ReadBuf) > 0) { + if (StrLength(Hdr->ReadBuf) > 0) + { pchs = ChrPtr(Hdr->ReadBuf); pch = strchr(pchs, '\n'); if (pch != NULL) { @@ -471,6 +472,8 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) retval = client_read_sslbuffer(Hdr->ReadBuf, SLEEPING); pchs = ChrPtr(Hdr->ReadBuf); pch = strchr(pchs, '\n'); + if (pch == NULL) + retval = 0; } if (retval == 0) { sleeeeeeeeeep(1); @@ -690,11 +693,6 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout) retval = client_read_sslbuffer(Hdr->ReadBuf, timeout); if (retval >= 0) { StrBufAppendBuf(Target, Hdr->ReadBuf, 0); /* todo: Buf > bytes? */ -#ifdef HTTP_TRACING - write(2, "\033[32m", 5); - write(2, buf, bytes); - write(2, "\033[30m", 5); -#endif return 1; } else { @@ -722,11 +720,6 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout) return retval; } -#ifdef HTTP_TRACING - write(2, "\033[32m", 5); - write(2, buf, bytes); - write(2, "\033[30m", 5); -#endif return 1; } @@ -785,13 +778,6 @@ long end_burst(void) } #endif - -#ifdef HTTP_TRACING - - write(2, "\033[34m", 5); - write(2, ptr, StrLength(WCC->WBuf)); - write(2, "\033[30m", 5); -#endif if (WCC->Hdr->http_sock == -1) return -1; fdflags = fcntl(WC->Hdr->http_sock, F_GETFL); @@ -822,13 +808,6 @@ long end_burst(void) count = StrLength(WCC->WBuf); eptr = ptr + count; -#ifdef HTTP_TRACING - - write(2, "\033[34m", 5); - write(2, ptr, StrLength(WCC->WBuf)); - write(2, "\033[30m", 5); -#endif - while ((ptr < eptr) && (WCC->Hdr->http_sock != -1)) { if ((fdflags & O_NONBLOCK) == O_NONBLOCK) { FD_ZERO(&wset); @@ -933,10 +912,12 @@ SessionDestroyModule_TCPSOCKETS { FreeStrBuf(&sess->CLineBuf); FreeStrBuf(&sess->ReadBuf); + sess->connected = 0; sess->ReadPos = NULL; FreeStrBuf(&sess->MigrateReadLineBuf); if (sess->serv_sock > 0) { syslog(LOG_DEBUG, "Closing socket %d", sess->serv_sock); close(sess->serv_sock); } + sess->serv_sock = -1; }