Thu, 09 Aug 2012 10:55:40 +0200
improved configuration loading
--- 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;
--- /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 <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 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 <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 */ +