src/server/daemon/config.c

changeset 33
96dbfe4f91e5
parent 31
280250e45ba6
child 36
450d2d5f4735
equal deleted inserted replaced
31:280250e45ba6 33:96dbfe4f91e5
114 serverconfig->pool = pool_create(); 114 serverconfig->pool = pool_create();
115 serverconfig->listeners = NULL; 115 serverconfig->listeners = NULL;
116 serverconfig->host_vs = ucx_map_new(16); 116 serverconfig->host_vs = ucx_map_new(16);
117 // TODO: init serverconfig stuff 117 // TODO: init serverconfig stuff
118 118
119
120 /*
121 * convert ServerConfig to ServerConfiguration
122 *
123 * its important to do this in the correct order:
124 * LogFile (we want an open log file first to log possible errors)
125 * Runtime
126 * Threadpool
127 * EventHandler
128 * AuthDB
129 * Listener (we set the VirtualServer later)
130 * VirtualServer (dependencies: Listener)
131 */
132
119 /* init logfile first */ 133 /* init logfile first */
120 UcxList *lfl= ucx_map_sstr_get(serverconf->objects, sstrn("LogFile", 7)); 134 UcxList *lfl = ucx_map_sstr_get(serverconf->objects, sstrn("LogFile", 7));
121 if(lfl != NULL) { 135 if(lfl != NULL) {
122 ServerConfigObject *logobj = lfl->data; 136 ServerConfigObject *logobj = lfl->data;
123 if(logobj == NULL) { 137 if(logobj == NULL) {
124 /* error */ 138 /* error */
125 return NULL; 139 return NULL;
133 } else { 147 } else {
134 /* horrible error */ 148 /* horrible error */
135 return NULL; 149 return NULL;
136 } 150 }
137 151
138 /* convert ServerConfig to ServerConfiguration */ 152 UcxList *list = ucx_map_sstr_get(serverconf->objects, sstrn("Runtime", 7));
139 UcxMapIterator iter = ucx_map_iterator(serverconf->objects); 153 UCX_FOREACH(UcxList*, list, elm) {
140 UCX_MAP_FOREACH(UcxList*, list, serverconf->objects, iter) { 154 ServerConfigObject *scfgobj = elm->data;
141 UCX_FOREACH(UcxList*, list, elm) { 155 cfg_handle_runtime(serverconfig, scfgobj);
142 156 }
143 ServerConfigObject *scfgobj = elm->data; 157
144 158 list = ucx_map_sstr_get(serverconf->objects, sstrn("Threadpool", 10));
145 /* handle config object */ 159 UCX_FOREACH(UcxList*, list, elm) {
146 int hr = 0; 160 ServerConfigObject *scfgobj = elm->data;
147 if(!sstrcmp(scfgobj->type, sstr("Runtime"))) { 161 // TODO: threadpool
148 hr = cfg_handle_runtime(serverconfig, scfgobj); 162 }
149 } else if(!sstrcmp(scfgobj->type, sstr("EventHandler"))) { 163
150 hr = cfg_handle_eventhandler(serverconfig, scfgobj); 164 list = ucx_map_sstr_get(serverconf->objects, sstrn("EventHandler", 12));
151 } else if(!sstrcmp(scfgobj->type, sstr("AuthDB"))) { 165 UCX_FOREACH(UcxList*, list, elm) {
152 hr = cfg_handle_authdb(serverconfig, scfgobj); 166 cfg_handle_eventhandler(serverconfig, (ServerConfigObject*)elm->data);
153 } else if(!sstrcmp(scfgobj->type, sstr("Listener"))) { 167 }
154 hr = cfg_handle_listener(serverconfig, scfgobj); 168
155 } else if(!sstrcmp(scfgobj->type, sstr("VirtualServer"))) { 169 list = ucx_map_sstr_get(serverconf->objects, sstrn("AuthDB", 6));
156 hr = cfg_handle_vs(serverconfig, scfgobj); 170 UCX_FOREACH(UcxList*, list, elm) {
157 } 171 ServerConfigObject *scfgobj = elm->data;
158 172 cfg_handle_authdb(serverconfig, scfgobj);
159 173 }
160 /* next object */ 174
161 list = list->next; 175 list = ucx_map_sstr_get(serverconf->objects, sstrn("Listener", 8));
162 } 176 UCX_FOREACH(UcxList*, list, elm) {
177 ServerConfigObject *scfgobj = elm->data;
178 cfg_handle_listener(serverconfig, scfgobj);
179 }
180
181 list = ucx_map_sstr_get(serverconf->objects, sstrn("VirtualServer", 13));
182 UCX_FOREACH(UcxList*, list, elm) {
183 ServerConfigObject *scfgobj = elm->data;
184 cfg_handle_vs(serverconfig, scfgobj);
163 } 185 }
164 186
165 /* check event handler config */ 187 /* check event handler config */
166 if(check_event_handler_cfg() != 0) { 188 if(check_event_handler_cfg() != 0) {
167 /* critical error */ 189 /* critical error */
181 203
182 sstr_t vsname = sstr(listener->default_vs.vs_name); 204 sstr_t vsname = sstr(listener->default_vs.vs_name);
183 205
184 /* search for VirtualServer */ 206 /* search for VirtualServer */
185 int b = 0; 207 int b = 0;
186 iter = ucx_map_iterator(serverconfig->host_vs); 208 UcxMapIterator iter = ucx_map_iterator(serverconfig->host_vs);
187 UCX_MAP_FOREACH(VirtualServer*, vs, serverconfig->host_vs, iter) { 209 UCX_MAP_FOREACH(VirtualServer*, vs, serverconfig->host_vs, iter) {
188 if(!sstrcmp(vsname, vs->name)) { 210 if(!sstrcmp(vsname, vs->name)) {
189 listener->default_vs.vs = vs; 211 listener->default_vs.vs = vs;
190 break; 212 break;
191 } 213 }

mercurial