merge

Thu, 09 Aug 2012 11:08:49 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 09 Aug 2012 11:08:49 +0200
changeset 34
2b4574e617c0
parent 32
ebba53de8b18 (current diff)
parent 33
96dbfe4f91e5 (diff)
child 35
4417619a9bbd

merge

--- a/src/server/daemon/config.c	Mon Jul 23 15:13:19 2012 +0200
+++ b/src/server/daemon/config.c	Thu Aug 09 11:08:49 2012 +0200
@@ -116,8 +116,22 @@
     serverconfig->host_vs = ucx_map_new(16);
     // TODO: init serverconfig stuff
     
+    
+    /*
+     * convert ServerConfig to ServerConfiguration
+     * 
+     * its important to do this in the correct order:
+     * LogFile (we want an open log file first to log possible errors)
+     * Runtime
+     * Threadpool
+     * EventHandler
+     * AuthDB
+     * Listener (we set the VirtualServer later)
+     * VirtualServer (dependencies: Listener)
+     */
+    
     /* init logfile first */
-    UcxList *lfl= ucx_map_sstr_get(serverconf->objects, sstrn("LogFile", 7));
+    UcxList *lfl = ucx_map_sstr_get(serverconf->objects, sstrn("LogFile", 7));
     if(lfl != NULL) {
         ServerConfigObject *logobj = lfl->data;
         if(logobj == NULL) {
@@ -135,31 +149,39 @@
         return NULL;
     }
     
-    /* convert ServerConfig to ServerConfiguration */
-    UcxMapIterator iter = ucx_map_iterator(serverconf->objects);
-    UCX_MAP_FOREACH(UcxList*, list, serverconf->objects, iter) {
-        UCX_FOREACH(UcxList*, list, elm) {
-            
-            ServerConfigObject *scfgobj = elm->data;
-            
-            /* handle config object */
-            int hr = 0;
-            if(!sstrcmp(scfgobj->type, sstr("Runtime"))) {
-                hr = cfg_handle_runtime(serverconfig, scfgobj);
-            } else if(!sstrcmp(scfgobj->type, sstr("EventHandler"))) {
-                hr = cfg_handle_eventhandler(serverconfig, scfgobj);
-            } else if(!sstrcmp(scfgobj->type, sstr("AuthDB"))) {
-                hr = cfg_handle_authdb(serverconfig, scfgobj);
-            } else if(!sstrcmp(scfgobj->type, sstr("Listener"))) {
-                hr = cfg_handle_listener(serverconfig, scfgobj);
-            } else if(!sstrcmp(scfgobj->type, sstr("VirtualServer"))) {
-                hr = cfg_handle_vs(serverconfig, scfgobj);
-            }
-
-
-            /* next object */
-            list = list->next;
-        }
+    UcxList *list = ucx_map_sstr_get(serverconf->objects, sstrn("Runtime", 7));
+    UCX_FOREACH(UcxList*, list, elm) {
+        ServerConfigObject *scfgobj = elm->data;
+        cfg_handle_runtime(serverconfig, scfgobj);
+    }
+    
+    list = ucx_map_sstr_get(serverconf->objects, sstrn("Threadpool", 10));
+    UCX_FOREACH(UcxList*, list, elm) {
+        ServerConfigObject *scfgobj = elm->data;
+        // TODO: threadpool
+    }
+    
+    list = ucx_map_sstr_get(serverconf->objects, sstrn("EventHandler", 12));
+    UCX_FOREACH(UcxList*, list, elm) {
+        cfg_handle_eventhandler(serverconfig, (ServerConfigObject*)elm->data);
+    }
+    
+    list = ucx_map_sstr_get(serverconf->objects, sstrn("AuthDB", 6));
+    UCX_FOREACH(UcxList*, list, elm) {
+        ServerConfigObject *scfgobj = elm->data;
+        cfg_handle_authdb(serverconfig, scfgobj);
+    }
+    
+    list = ucx_map_sstr_get(serverconf->objects, sstrn("Listener", 8));
+    UCX_FOREACH(UcxList*, list, elm) {
+        ServerConfigObject *scfgobj = elm->data;
+        cfg_handle_listener(serverconfig, scfgobj);
+    }
+    
+    list = ucx_map_sstr_get(serverconf->objects, sstrn("VirtualServer", 13));
+    UCX_FOREACH(UcxList*, list, elm) {
+        ServerConfigObject *scfgobj = elm->data;
+        cfg_handle_vs(serverconfig, scfgobj);
     }
 
     /* check event handler config */
@@ -183,7 +205,7 @@
 
         /* search for VirtualServer */
         int b = 0;
-        iter = ucx_map_iterator(serverconfig->host_vs);
+        UcxMapIterator iter = ucx_map_iterator(serverconfig->host_vs);
         UCX_MAP_FOREACH(VirtualServer*, vs, serverconfig->host_vs, iter) {
             if(!sstrcmp(vsname, vs->name)) {
                 listener->default_vs.vs = vs;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/atomic.c	Thu Aug 09 11:08:49 2012 +0200
@@ -0,0 +1,25 @@
+/*
+ * 
+ */
+
+#include <atomic.h>
+
+#include "atomic.h"
+
+void ucx_atomic_inc_8(volatile uint8_t *t) {
+    atomic_inc_8(t);
+}
+
+void ucx_atomic_inc_16(volatile uint16_t *t) {
+    atomic_inc_16(t);
+}
+
+void ucx_atomic_inc_32(volatile uint32_t *t) {
+    atomic_inc_32(t);
+}
+
+void ucx_atomic_inc_64(volatile uint64_t *t) {
+    atomic_inc_64(t);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/atomic.h	Thu Aug 09 11:08:49 2012 +0200
@@ -0,0 +1,31 @@
+/* 
+ * File:   atomic.h
+ * Author: olaf
+ *
+ * Created on 29. Mai 2012, 09:38
+ */
+
+#ifndef ATOMIC_H
+#define	ATOMIC_H
+
+#include <inttypes.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+void ucx_atomic_inc_8(volatile uint8_t *t);
+
+void ucx_atomic_inc_16(volatile uint16_t *t);
+
+void ucx_atomic_inc_32(volatile uint32_t *t);
+
+void ucx_atomic_inc_64(volatile uint64_t *t);
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* ATOMIC_H */
+
--- a/src/server/ucx/objs.mk	Mon Jul 23 15:13:19 2012 +0200
+++ b/src/server/ucx/objs.mk	Thu Aug 09 11:08:49 2012 +0200
@@ -35,6 +35,7 @@
 UCXOBJ += map.o
 UCXOBJ += mempool.o
 UCXOBJ += string.o
+UCXOBJ += atomic.o
 
 UCXOBJS = $(UCXOBJ:%=$(UCX_OBJPRE)%)
 UCXSOURCE = $(UCXOBJ:%.o=ucx/%.c)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/bin/reconfig.template	Thu Aug 09 11:08:49 2012 +0200
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+PID=`cat /tmp/webserver-rw6pgl8b/pid`
+
+kill -SIGUSR1 $PID
+

mercurial