Log incref/destroy, remove redundant client_incref
[pazpar2-moved-to-github.git] / src / client.c
index 89197f1..0d6112b 100644 (file)
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if HAVE_CONFIG_H
 #include <config.h>
 #endif
-
+#include <pthread.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -350,6 +350,11 @@ static int nativesyntax_to_type(struct session_database *sdb, char *type,
         {
             strcpy(type, "xml");
         }
+        else if (!strncmp(s, "txml", 4))
+        {
+            const char *cp = strchr(s, ';');
+            yaz_snprintf(type, 80, "txml; charset=%s", cp ? cp+1 : "marc-8s");
+        }
         else
             return -1;
         return 0;
@@ -364,6 +369,11 @@ static int nativesyntax_to_type(struct session_database *sdb, char *type,
                 strcpy(type, "xml");
                 return 0;
             }
+            else if (!strcmp(syntax, "TXML"))
+                {
+                    strcpy(type, "txml");
+                    return 0;
+                }
             else if (!strcmp(syntax, "USmarc") || !strcmp(syntax, "MARC21"))
             {
                 strcpy(type, "xml; charset=marc8-s");
@@ -468,16 +478,18 @@ void client_record_response(struct client *cl)
                 if (cl->session == 0)
                     ;
                 else if (ZOOM_record_error(rec, &msg, &addinfo, 0))
+                {
                     yaz_log(YLOG_WARN, "Record error %s (%s): %s (rec #%d)",
-                            error, addinfo, client_get_url(cl),
+                            msg, addinfo, client_get_url(cl),
                             cl->record_offset);
+                }
                 else
                 {
                     struct session_database *sdb = client_get_database(cl);
                     NMEM nmem = nmem_create();
                     const char *xmlrec;
                     char type[80];
-                    yaz_log(YLOG_LOG, "Record ingest begin client=%p session=%p", cl, cl->session);
+
                     if (nativesyntax_to_type(sdb, type, rec))
                         yaz_log(YLOG_WARN, "Failed to determine record type");
                     xmlrec = ZOOM_record_get(rec, type, NULL);
@@ -491,7 +503,6 @@ void client_record_response(struct client *cl)
                                     client_get_url(cl));
                     }
                     nmem_destroy(nmem);
-                    yaz_log(YLOG_LOG, "Record ingest end client=%p session=%p", cl, cl->session);
                 }
             }
             else
@@ -606,15 +617,16 @@ struct client *client_create(void)
 void client_incref(struct client *c)
 {
     pazpar2_incref(&c->ref_count, c->mutex);
-    yaz_log(YLOG_DEBUG, "client_incref %s %d", client_get_url(c), c->ref_count);
+    yaz_log(YLOG_LOG, "client_incref c=%p %s cnt=%d",
+            c, client_get_url(c), c->ref_count);
 }
 
 int client_destroy(struct client *c)
 {
     if (c)
     {
-        yaz_log(YLOG_DEBUG, "client_destroy %s %d",
-                client_get_url(c), c->ref_count);
+        yaz_log(YLOG_LOG, "client_destroy c=%p %s cnt=%d",
+                c, client_get_url(c), c->ref_count);
         if (!pazpar2_decref(&c->ref_count, c->mutex))
         {
             c->next = 0;
@@ -796,7 +808,6 @@ int client_parse_query(struct client *cl, const char *query)
 void client_remove_from_session(struct client *c)
 {
     struct session *se;
-    client_incref(c);
 
     se = c->session;
     assert(se);
@@ -813,7 +824,6 @@ void client_remove_from_session(struct client *c)
         c->session = 0;
         c->next = 0;
     }
-    client_destroy(c);
 }
 
 void client_set_session(struct client *cl, struct session *se)