Make check works, no problems (yet) with threads
[pazpar2-moved-to-github.git] / src / connection.c
index d3eaeef..9a29f90 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Pazpar2.
-   Copyright (C) 2006-2012 Index Data
+   Copyright (C) 2006-2013 Index Data
 
 Pazpar2 is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -323,9 +323,8 @@ static void connection_handler(IOCHAN iochan, int event)
     else if (event & EVENT_TIMEOUT)
     {
         ZOOM_connection_fire_event_timeout(co->link);
-        client_lock(cl);
+
         non_block_events(co);
-        client_unlock(cl);
 
         remove_connection_from_host(co);
         yaz_mutex_leave(host->mutex);
@@ -335,13 +334,11 @@ static void connection_handler(IOCHAN iochan, int event)
     {
         yaz_mutex_leave(host->mutex);
 
-        client_lock(cl);
         non_block_events(co);
 
         ZOOM_connection_fire_event_socket(co->link, event);
 
         non_block_events(co);
-        client_unlock(cl);
 
         if (co->link)
         {
@@ -463,13 +460,13 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man)
         return -1;
     }
 
-    if (sru && *sru)
+    if (sru && *sru && !strstr(host->url, "://"))
     {
-        char http_hostport[512];
-        strcpy(http_hostport, "http://");
-        strcat(http_hostport, host->url);
-        yaz_log(YLOG_LOG, "SRU connect to : %s", http_hostport);
-        ZOOM_connection_connect(con->link, http_hostport, 0);
+        WRBUF w = wrbuf_alloc();
+        wrbuf_puts(w, "http://");
+        wrbuf_puts(w, host->url);
+        ZOOM_connection_connect(con->link, wrbuf_cstr(w), 0);
+        wrbuf_destroy(w);
     }
     else
     {