Changed prototype of yaz_srw_serve to solve threading problem
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 20 Jan 2003 13:04:50 +0000 (13:04 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 20 Jan 2003 13:04:50 +0000 (13:04 +0000)
with srw-gateway.

include/yaz/srw-util.h
srw/srw-server.c
srwapps/srw-gateway.c

index 6e03390..a180c0a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: srw-util.h,v 1.1 2003-01-06 08:20:27 adam Exp $
+/* $Id: srw-util.h,v 1.2 2003-01-20 13:04:50 adam Exp $
    Copyright (C) 2002-2003
    Index Data Aps
 
@@ -29,7 +29,6 @@ char *xslt_map_result_schema(xslt_map_result res);
 const char *yaz_srw_diag_str (int code);
 
 void yaz_srw_serve (struct soap *soap,
-                    void *userinfo,
                     int (*sr_h)(void *userinfo,
                                 struct soap * soap,
                                 xsd__string  *query,
index 2d09052..5a2ab0a 100644 (file)
@@ -47,7 +47,6 @@ int zs__searchRetrieveRequest(struct soap * soap,
 }
 
 void yaz_srw_serve (struct soap *soap,
-                    void *userinfo,
                     int (*sr_h)(void *userinfo,
                                 struct soap * soap,
                                 xsd__string  *query,
@@ -67,8 +66,9 @@ void yaz_srw_serve (struct soap *soap,
 
     info.sr_h = sr_h;
     info.e_h = e_h;
-    info.userinfo = userinfo;
+    info.userinfo = soap->user;
     soap->user = &info;
     soap->namespaces = srw_namespaces;
     soap_serve(soap);
 }
+
index 77591db..aa0f458 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: srw-gateway.c,v 1.1 2003-01-06 08:20:28 adam Exp $
+/* $Id: srw-gateway.c,v 1.2 2003-01-20 13:04:50 adam Exp $
    Copyright (C) 2002-2003
    Index Data Aps
 
@@ -293,6 +293,15 @@ static void target_leave (struct target *l)
     myunlock(&target_mutex);
 }
 
+#if USE_THREADS
+static void *p_serve (void *p)
+{
+    struct soap *soap = p;
+    yaz_srw_serve(soap, searchRetrieve, explain);
+}
+#endif
+
+
 static void standalone(struct soap *soap, const char *host, int port,
                        int max_thr, struct srw_prop *properties)
 {
@@ -365,13 +374,12 @@ static void standalone(struct soap *soap, const char *host, int port,
             soap_thr[i]->user = properties;
 #if USE_THREADS
             if (max_thr <= 1)
-                yaz_srw_serve(soap_thr[i], properties,
+                yaz_srw_serve(soap_thr[i],
                               searchRetrieve, explain);  /* static mode .. */
             else
-                pthread_create(&tid[i], 0, (void*(*)(void*))soap_serve,
-                               soap_thr[i]);
+                pthread_create(&tid[i], 0, p_serve, soap_thr[i]);
 #else
-            yaz_srw_serve(soap_thr[i], properties,
+            yaz_srw_serve(soap_thr[i],
                           searchRetrieve, explain);  /* static mode .. */
 #endif
         }
@@ -419,7 +427,7 @@ int fetchone(struct soap *soap, struct srw_prop *properties,
     {
         return 65;
     }
-    if (!strcmp(schema, "MARC21"))
+    if (!strcmp(schema, "MARC21") || !strcmp(schema, "http://www.loc.gov/marcxml/"))
     {
         *rec_data = soap_malloc (soap, xml_len+1);
         memcpy (*rec_data, xml_rec, xml_len);
@@ -819,7 +827,7 @@ int main(int argc, char **argv)
             yaz_log_init_file(arg);
             break;
         case 'V':
-            puts ("Version: $Id: srw-gateway.c,v 1.1 2003-01-06 08:20:28 adam Exp $"
+            puts ("Version: $Id: srw-gateway.c,v 1.2 2003-01-20 13:04:50 adam Exp $"
 #if SRW_DEBUG
             " DEBUG"
 #endif
@@ -876,7 +884,7 @@ int main(int argc, char **argv)
         soap_init(&soap);
         soap.user = &properties;
 
-        yaz_srw_serve(&soap, &properties, searchRetrieve, explain);
+        yaz_srw_serve(&soap, searchRetrieve, explain);
 
         soap_end(&soap);
         yaz_log (LOG_LOG, "CGI end");