src/server/daemon/config.c

changeset 440
d77b8f3e14e2
parent 438
22eca559aded
child 443
ef3c8a0e1fee
--- a/src/server/daemon/config.c	Sat Nov 26 19:14:29 2022 +0100
+++ b/src/server/daemon/config.c	Sat Nov 26 19:15:33 2022 +0100
@@ -349,6 +349,27 @@
     return serverconfig;
 }
 
+int migrate_server_conf(ServerConfiguration *old_cfg, ServerConfiguration *new_cfg) {
+    // compare old/new listeners and set next listener, if they are using
+    // the same socket
+    CxIterator old_listeners = cxListIterator(old_cfg->listeners, 0);
+    cx_foreach(HttpListener*, oldls, old_listeners) {
+        if(oldls->next) {
+            continue;
+        }
+        
+        CxIterator new_listeners = cxListIterator(new_cfg->listeners, 0);
+        cx_foreach(HttpListener*, newls, new_listeners) {
+            if(http_listener_socket_eq(oldls, newls)) {
+                oldls->next = newls;
+                break;
+            }
+        }
+    }
+    
+    return 0;
+}
+
 void cfg_ref(ServerConfiguration *cfg) {
     ws_atomic_inc32(&cfg->ref);
 }

mercurial