Use NULL path for non-abs XML config fname
[yaz-moved-to-github.git] / src / statserv.c
index adf1443..5388730 100644 (file)
@@ -286,9 +286,15 @@ int control_association(association *assoc, const char *host, int force_open)
             int host_match = 0;
             if ( !gfs->host || (host && gfs->host && !strcmp(host, gfs->host)))
                 host_match = 1;
             int host_match = 0;
             if ( !gfs->host || (host && gfs->host && !strcmp(host, gfs->host)))
                 host_match = 1;
-            if (!gfs->listen_ref ||
-                gfs->listen_ref == assoc->client_chan->chan_id)
+            if (!gfs->listen_ref)
                 listen_match = 1;
                 listen_match = 1;
+            else
+            {
+                int i;
+                for (i = 0; gfs->listen_ref[i] != -1; i++)
+                    if (gfs->listen_ref[i] == assoc->client_chan->chan_id)
+                        listen_match = 1;
+            }
             if (listen_match && host_match)
             {
                 if (force_open ||
             if (listen_match && host_match)
             {
                 if (force_open ||
@@ -390,17 +396,27 @@ static void xml_config_read(const char *base_path)
             gfs->server_node_ptr = ptr_server;
             if (listenref)
             {
             gfs->server_node_ptr = ptr_server;
             if (listenref)
             {
-                int id_no;
-                struct gfs_listen *gl = gfs_listen_list;
-                for (id_no = 1; gl; gl = gl->next, id_no++)
-                    if (gl->id && !strcmp(gl->id, listenref))
-                    {
-                        gfs->listen_ref = id_no;
-                        break;
-                    }
-                if (!gl)
-                    yaz_log(YLOG_WARN, "Non-existent listenref '%s' in server "
-                            "config element", listenref);
+                char **refs;
+                int num, i;
+                nmem_strsplit(gfs_nmem, ",", listenref, &refs, &num);
+                gfs->listen_ref = (int*) nmem_malloc(gfs_nmem,
+                                                     sizeof(int) * (num + 1));
+                for (i = 0; i < num; i++)
+                {
+                    int id_no;
+                    struct gfs_listen *gl = gfs_listen_list;
+                    gfs->listen_ref[i] = 0;
+                    for (id_no = 1; gl; gl = gl->next, id_no++)
+                        if (gl->id && !strcmp(gl->id, refs[i]))
+                        {
+                            gfs->listen_ref[i] = id_no;
+                            break;
+                        }
+                    if (!gl)
+                        yaz_log(YLOG_WARN, "Non-existent listenref '%s' "
+                                "in server config element", refs[i]);
+                }
+                gfs->listen_ref[i] = -1;
             }
             for (ptr = ptr_server->children; ptr; ptr = ptr->next)
             {
             }
             for (ptr = ptr_server->children; ptr; ptr = ptr->next)
             {
@@ -507,7 +523,6 @@ static void xml_config_read(const char *base_path)
 
 static void xml_config_open(void)
 {
 
 static void xml_config_open(void)
 {
-    WRBUF base_path;
     const char *last_p;
     const char *fname = control_block.xml_config;
     if (!getcwd(gfs_root_dir, FILENAME_MAX))
     const char *last_p;
     const char *fname = control_block.xml_config;
     if (!getcwd(gfs_root_dir, FILENAME_MAX))
@@ -547,7 +562,6 @@ static void xml_config_open(void)
             }
         }
     }
             }
         }
     }
-    base_path = wrbuf_alloc();
     last_p = strrchr(fname,
 #ifdef WIN32
                      '\\'
     last_p = strrchr(fname,
 #ifdef WIN32
                      '\\'
@@ -556,11 +570,14 @@ static void xml_config_open(void)
 #endif
         );
     if (last_p)
 #endif
         );
     if (last_p)
+    {
+        WRBUF base_path = wrbuf_alloc();
         wrbuf_write(base_path, fname, last_p - fname);
         wrbuf_write(base_path, fname, last_p - fname);
+        xml_config_read(wrbuf_cstr(base_path));
+        wrbuf_destroy(base_path);
+    }
     else
     else
-        wrbuf_puts(base_path, ".");
-    xml_config_read(wrbuf_cstr(base_path));
-    wrbuf_destroy(base_path);
+        xml_config_read(0);
 #endif
 }
 
 #endif
 }