Happy new year
[yaz-moved-to-github.git] / src / statserv.c
index 8598891..ab15c21 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2010 Index Data
+ * Copyright (C) 1995-2011 Index Data
  * See the file LICENSE for details.
  */
 
@@ -8,6 +8,10 @@
  * \brief Implements GFS logic
  */
 
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -42,8 +46,6 @@
 
 #if YAZ_POSIX_THREADS
 #include <pthread.h>
-#elif YAZ_GNU_THREADS
-#include <pth.h>
 #endif
 
 #include <fcntl.h>
@@ -119,7 +121,8 @@ statserv_options_block control_block = {
     "",                         /* PID fname */
     0,                          /* background daemon */
     "",                         /* SSL certificate filename */
-    ""                          /* XML config filename */
+    "",                         /* XML config filename */
+    1                           /* keepalive */
 };
 
 static int max_sessions = 0;
@@ -947,18 +950,6 @@ static void listener(IOCHAN h, int event)
             pthread_t child_thread;
             pthread_create(&child_thread, 0, new_session, new_line);
             pthread_detach(child_thread);
-#elif YAZ_GNU_THREADS
-            pth_attr_t attr;
-            pth_t child_thread;
-
-            attr = pth_attr_new();
-            pth_attr_set(attr, PTH_ATTR_JOINABLE, FALSE);
-            pth_attr_set(attr, PTH_ATTR_STACK_SIZE, 32*1024);
-            pth_attr_set(attr, PTH_ATTR_NAME, "session");
-            yaz_log(YLOG_DEBUG, "pth_spawn begin");
-            child_thread = pth_spawn(attr, new_session, new_line);
-            yaz_log(YLOG_DEBUG, "pth_spawn finish");
-            pth_attr_destroy(attr);
 #else
             new_session(new_line);
 #endif
@@ -1273,7 +1264,7 @@ int check_options(int argc, char **argv)
 
     get_logbits(1); 
 
-    while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:A:p:DC:f:m:r:",
+    while ((ret = options("1a:iszSTl:v:u:c:w:t:k:Kd:A:p:DC:f:m:r:",
                           argv, argc, &arg)) != -2)
     {
         switch (ret)
@@ -1300,9 +1291,6 @@ int check_options(int argc, char **argv)
 #if YAZ_POSIX_THREADS
             control_block.dynamic = 0;
             control_block.threads = 1;
-#elif YAZ_GNU_THREADS
-            control_block.dynamic = 0;
-            control_block.threads = 1;
 #else
             fprintf(stderr, "%s: Threaded mode not available.\n", me);
             return 1;
@@ -1354,6 +1342,9 @@ int check_options(int argc, char **argv)
             }
             control_block.maxrecordsize = r * 1024;
             break;
+        case 'K':
+            control_block.keepalive = 0;
+            break;
         case 'i':
             control_block.inetd = 1;
             break;