# HG changeset patch # User Olaf Wintermann # Date 1344502540 -7200 # Node ID 96dbfe4f91e5638e23b9bc415625050fd76d96f2 # Parent 280250e45ba6ee50001116cd9c9e504bfd761bf5 improved configuration loading diff -r 280250e45ba6 -r 96dbfe4f91e5 src/server/daemon/config.c --- a/src/server/daemon/config.c Fri May 25 18:16:24 2012 +0200 +++ b/src/server/daemon/config.c Thu Aug 09 10:55:40 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; diff -r 280250e45ba6 -r 96dbfe4f91e5 src/server/ucx/atomic.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/ucx/atomic.c Thu Aug 09 10:55:40 2012 +0200 @@ -0,0 +1,25 @@ +/* + * + */ + +#include + +#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); +} + + diff -r 280250e45ba6 -r 96dbfe4f91e5 src/server/ucx/atomic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/ucx/atomic.h Thu Aug 09 10:55:40 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 + +#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 */ + diff -r 280250e45ba6 -r 96dbfe4f91e5 src/server/ucx/objs.mk --- a/src/server/ucx/objs.mk Fri May 25 18:16:24 2012 +0200 +++ b/src/server/ucx/objs.mk Thu Aug 09 10:55:40 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) diff -r 280250e45ba6 -r 96dbfe4f91e5 templates/bin/reconfig.template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/bin/reconfig.template Thu Aug 09 10:55:40 2012 +0200 @@ -0,0 +1,6 @@ +#!/bin/sh + +PID=`cat /tmp/webserver-rw6pgl8b/pid` + +kill -SIGUSR1 $PID +