diff --git a/src/connections.c b/src/connections.c index 8f6149c..5be58d0 100644 --- a/src/connections.c +++ b/src/connections.c @@ -16,6 +16,7 @@ along with this program. If not, see . */ #include +#include #include #include @@ -218,6 +219,7 @@ static long diff(struct timespec *t1, struct timespec *t2) { } int updateConnection(Connection *conn, Sitefile *site) { + size_t totalReceived = 0; for (;;) { char buff[300]; ssize_t received; @@ -229,10 +231,17 @@ int updateConnection(Connection *conn, Sitefile *site) { diff(&conn->lastdata, ¤tTime) > site->timeout) return 1; received = recvStream(conn->stream, buff, sizeof(buff)); - if (received < 0) + if (received < 0) { + char log[200]; + sprintf(log, +"recvStream() returned %ld, with errno %d, received %lu bytes this iteration " +"of updateConnection", + received, errno, totalReceived); return errno != EAGAIN; + } if (received == 0) - return 0; + return 1; + totalReceived += received; memcpy(&conn->lastdata, ¤tTime, sizeof(struct timespec)); for (i = 0; i < received; i++) { if (processChar(conn, buff[i], site)) diff --git a/src/runner.c b/src/runner.c index 31e3f9d..4fa4927 100644 --- a/src/runner.c +++ b/src/runner.c @@ -46,16 +46,12 @@ void *runServer(RunnerArgs *args) { for (;;) { int i; - if (site->timeout == 0) { - poll(fds, connCount, -1); - } - else - poll(fds, connCount, site->timeout); + poll(fds, connCount, -1); { char log[200]; sprintf(log, -"poll() finished with %d connections and a timeout of %d ms", - connCount, site->timeout); +"poll() finished with %d connections", + connCount); createLog(log); }