HTTP server: host=@ listens on IPV6 and IPV4 if possible
[pazpar2-moved-to-github.git] / src / session.c
index ed80133..bb1f6cb 100644 (file)
@@ -631,6 +631,8 @@ static void session_clear_set(struct session *se, struct reclist_sortparms *sp)
     se->total_records = se->total_merged = 0;
     se->num_termlists = 0;
 
+    relevance_clear(se->relevance);
+
     /* reset list of sorted results and clear to relevance search */
     se->sorted_results = nmem_malloc(se->nmem, sizeof(*se->sorted_results));
     se->sorted_results->name = nmem_strdup(se->nmem, sp->name);
@@ -752,7 +754,8 @@ enum pazpar2_error_code session_search(struct session *se,
                                        const char *filter,
                                        const char *limit,
                                        const char **addinfo,
-                                       struct reclist_sortparms *sp)
+                                       struct reclist_sortparms *sp,
+                                       const char *mergekey)
 {
     int live_channels = 0;
     int no_working = 0;
@@ -773,6 +776,12 @@ enum pazpar2_error_code session_search(struct session *se,
     session_enter(se, "session_search");
     se->settings_modified = 0;
 
+    if (mergekey)
+    {
+        xfree(se->mergekey);
+        se->mergekey = *mergekey ? xstrdup(mergekey) : 0;
+    }
+
     session_clear_set(se, sp);
     relevance_destroy(&se->relevance);
 
@@ -1493,7 +1502,7 @@ static int get_mergekey_from_doc(xmlDoc *doc, xmlNode *root, const char *name,
             else if (!strcmp(name, (const char *) type))
             {
                 xmlChar *value = xmlNodeListGetString(doc, n->children, 1);
-                if (value)
+                if (value && *value)
                 {
                     const char *norm_str;
                     pp2_charset_token_t prt =
@@ -1512,10 +1521,11 @@ static int get_mergekey_from_doc(xmlDoc *doc, xmlNode *root, const char *name,
                             wrbuf_puts(norm_wr, norm_str);
                         }
                     }
-                    xmlFree(value);
                     pp2_charset_token_destroy(prt);
                     no_found++;
                 }
+                if (value)
+                    xmlFree(value);
             }
             xmlFree(type);
         }