diff --git a/documentation/sitefiles.md b/documentation/sitefiles.md
index bf58f60..991cee6 100644
--- a/documentation/sitefiles.md
+++ b/documentation/sitefiles.md
@@ -34,5 +34,5 @@ sitefiles also allow comments with #
* TLS
* ```key``` - The filepath of the private key to use if transport == TLS
* ```cert``` - The filepath of the certificate to use if transport == TLS
-* ```timeout``` - The amount of time to wait for data before closing the connection in ms
+* ```timeout``` - The amount of time to wait for data before closing the connection in ms. A timeout of 0 means to wait infinitely. (default: 2000)
* ```library``` - the path of a library that is linked in during runtime if ```DYNAMIC_LINKED_PAGES```is set.
diff --git a/src/main.c b/src/main.c
index d318590..f930f6d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,7 +41,7 @@ static void daemonize(char *pidfile) {
break;
default:
pidout = fopen(pidfile, "w");
- fprintf(pidout, "%d\n", getpid());
+ fprintf(pidout, "%d\n", pid);
fclose(pidout);
exit(EXIT_SUCCESS);
}
@@ -218,6 +218,7 @@ NULL
for (;;) {
Stream *stream = acceptStream(listener, O_NONBLOCK);
int lowestThread;
+ createLog("Accepted stream");
if (stream == NULL) {
createLog("Accepting a stream failed");
continue;
diff --git a/src/runner.c b/src/runner.c
index e7da0fb..e6d12de 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -15,6 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+#include
#include
#include
#include
@@ -22,6 +23,7 @@
#include
#include
+#include
#include
#include
#include
@@ -44,7 +46,19 @@ void *runServer(RunnerArgs *args) {
for (;;) {
int i;
- poll(fds, connCount, site->timeout);
+ if (site->timeout == 0) {
+ poll(fds, connCount, -1);
+ }
+ else
+ poll(fds, connCount, site->timeout);
+ {
+ char log[200];
+ sprintf(log,
+"poll() finished with %d connections and a timeout of %d ms",
+ connCount, site->timeout);
+ createLog(log);
+ }
+
for (i = 1; i < connCount; i++) {
if (updateConnection(connections + i, site))
diff --git a/src/sitefile.c b/src/sitefile.c
index 12a90a6..e8d5f84 100644
--- a/src/sitefile.c
+++ b/src/sitefile.c
@@ -193,7 +193,7 @@ Sitefile *parseSitefile(char *path) {
ret->type = TCP;
ret->key = NULL;
ret->cert = NULL;
- ret->timeout = 0;
+ ret->timeout = 2000;
ret->size = 0;
ret->content = malloc(allocatedLength * sizeof(SiteCommand));
#if DYNAMIC_LINKED_PAGES