summaryrefslogtreecommitdiffstats
path: root/nanohttp/nanohttp-server.c
diff options
context:
space:
mode:
authorGravatar rans2004-09-07 18:40:38 +0000
committerGravatar rans2004-09-07 18:40:38 +0000
commite9e02cf4a942250afc7cd41a0629d5f50d70b6f1 (patch)
tree070b52c109d3430960854b38e85b50733cd54edd /nanohttp/nanohttp-server.c
parentfc13964422ceccee84640cdc71a308dd48976560 (diff)
downloadcsoap-e9e02cf4a942250afc7cd41a0629d5f50d70b6f1.tar.gz
csoap-e9e02cf4a942250afc7cd41a0629d5f50d70b6f1.tar.bz2
Made httpd_run run on a thread and added Sleep statements - seems to solve WIndows performance problems
Diffstat (limited to 'nanohttp/nanohttp-server.c')
-rw-r--r--nanohttp/nanohttp-server.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index 0f89edc..edf9290 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.17 2004/09/01 16:03:17 snowdrop Exp $
+* $Id: nanohttp-server.c,v 1.18 2004/09/07 18:40:38 rans Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -412,14 +412,7 @@ httpd_term (int sig)
_httpd_run = 0;
}
-/*
- * -----------------------------------------------------
- * FUNCTION: httpd_run
- * -----------------------------------------------------
- */
-
-int
-httpd_run ()
+static void __httpd_run(void *p)
{
int err;
fd_set fds;
@@ -435,7 +428,7 @@ httpd_run ()
if (err != HSOCKET_OK)
{
log_error2 ("httpd_run(): '%d'", err);
- return err;
+ return;
}
log_verbose2 ("registering termination signal handler (SIGNAL:%d)",
_httpd_terminate_signal);
@@ -447,7 +440,7 @@ httpd_run ()
if (err != HSOCKET_OK)
{
log_error2 ("httpd_run(): '%d'", err);
- return err;
+ return;
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
@@ -455,6 +448,9 @@ httpd_run ()
while (_httpd_run)
{
+#ifdef WIN32
+ Sleep(10);
+#endif
FD_ZERO (&fds);
FD_SET (_httpd_socket, &fds);
@@ -465,14 +461,23 @@ httpd_run ()
{
err = WSAGetLastError ();
log_error1 ("select error");
- return -1;
+ return;
}
#endif
while (_httpd_run && (FD_ISSET (_httpd_socket, &fds)))
+ {
if (!_httpd_run)
+ {
break;
-
+ }
+#ifdef WIN32
+ else
+ {
+ Sleep(10);
+ }
+#endif
+ }
if (hsocket_accept
(_httpd_socket, httpd_session_main, _httpd_connection,
_httpd_max_connections) != 0)
@@ -481,7 +486,30 @@ httpd_run ()
}
}
free (_httpd_connection);
- return 0;
+#ifdef WIN32
+ _endthread ();
+#endif
+}
+
+/*
+ * -----------------------------------------------------
+ * FUNCTION: httpd_run
+ * -----------------------------------------------------
+ */
+
+int
+httpd_run ()
+{
+#ifdef WIN32
+ if (_beginthread (__httpd_run, 0, NULL) == -1)
+ {
+ log_error1 ("httpd_run thread failed to start");
+ return (-1);
+ }
+#else
+ void *p;
+ __httpd_run(p);
+#endif
}
char *