351 |
351 |
352 return serverconfig; |
352 return serverconfig; |
353 } |
353 } |
354 |
354 |
355 int migrate_server_conf(ServerConfiguration *old_cfg, ServerConfiguration *new_cfg) { |
355 int migrate_server_conf(ServerConfiguration *old_cfg, ServerConfiguration *new_cfg) { |
|
356 old_cfg->next = new_cfg; |
|
357 cfg_ref(new_cfg); // new cfg should not be freed until old cfg is freed |
|
358 |
356 // compare old/new listeners and set next listener, if they are using |
359 // compare old/new listeners and set next listener, if they are using |
357 // the same socket |
360 // the same socket |
358 CxIterator old_listeners = cxListIterator(old_cfg->listeners, 0); |
361 CxIterator old_listeners = cxListIterator(old_cfg->listeners, 0); |
359 cx_foreach(HttpListener*, oldls, old_listeners) { |
362 cx_foreach(HttpListener*, oldls, old_listeners) { |
360 if(oldls->next) { |
363 if(oldls->next) { |
361 continue; |
364 continue; |
362 } |
365 } |
363 |
366 |
364 CxIterator new_listeners = cxListIterator(new_cfg->listeners, 0); |
367 CxIterator new_listeners = cxListIterator(new_cfg->listeners, 0); |
365 cx_foreach(HttpListener*, newls, new_listeners) { |
368 cx_foreach(HttpListener*, newls, new_listeners) { |
366 if(http_listener_socket_eq(oldls, newls)) { |
369 if(http_listener_socket_eq(oldls, newls)) { |
367 oldls->next = newls; |
370 http_listener_set_next(oldls, newls); |
368 break; |
371 break; |
369 } |
372 } |
370 } |
373 } |
371 } |
374 } |
372 |
375 |