Set client state to Client_Error on ZOOM errors
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 21 May 2010 09:47:02 +0000 (11:47 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 21 May 2010 09:47:02 +0000 (11:47 +0200)
This sets the state to a proper value -- nice for client statistics
but more importantly ensures that we don't reuse a ZOOM connection
that has a closed connection.

src/connection.c

index 79eb40e..1406811 100644 (file)
@@ -207,10 +207,14 @@ static void non_block_events(struct connection *co)
                 {
                     yaz_log(YLOG_LOG, "Error %s from %s",
                             error, client_get_url(cl));
+                    client_set_diagnostic(cl, err);
+                    client_set_state(cl, Client_Error);
+                }
+                else
+                {
+                    iochan_settimeout(iochan, co->session_timeout);
+                    client_set_state(cl, Client_Idle);
                 }
-                iochan_settimeout(iochan, co->session_timeout);
-                client_set_diagnostic(cl, err);
-                client_set_state(cl, Client_Idle);
                 yaz_cond_broadcast(co->host->cond_ready);
             }
             break;
@@ -287,15 +291,11 @@ static void connection_handler(IOCHAN iochan, int event)
             client_set_state(cl, Client_Error);
             connection_destroy(co);
         }
-        else if (client_get_state(co->client) == Client_Idle)
+        else
         {
             yaz_log(YLOG_LOG,  "idle timeout %s", client_get_url(cl));
             connection_destroy(co);
         }
-        else
-        {
-            yaz_log(YLOG_LOG,  "ignore timeout %s", client_get_url(cl));
-        }
         yaz_mutex_leave(host->mutex);
     }
     else