- yaz_log(YLOG_WARN, "Destroying orphan connection");
- connection_destroy(co);
- return;
- }
-
- if (co->state == Conn_Connecting && event & EVENT_OUTPUT)
- {
- int errcode;
- socklen_t errlen = sizeof(errcode);
-
- if (getsockopt(cs_fileno(co->link), SOL_SOCKET, SO_ERROR, &errcode,
- &errlen) < 0 || errcode != 0)
- {
- client_fatal(cl);
- return;
- }
- else
- {
- yaz_log(YLOG_DEBUG, "Connect OK");
- co->state = Conn_Open;
- if (cl)
- client_set_state(cl, Client_Connected);
- }
- }
-
- else if (event & EVENT_INPUT)
- {
- int len = cs_get(co->link, &co->ibuf, &co->ibufsize);
-
- if (len < 0)
- {
- yaz_log(YLOG_WARN|YLOG_ERRNO, "Error reading from %s",
- client_get_url(cl));
- connection_destroy(co);
- return;
- }
- else if (len == 0)
- {
- yaz_log(YLOG_WARN, "EOF reading from %s", client_get_url(cl));
- connection_destroy(co);
- return;
- }
- else if (len > 1) // We discard input if we have no connection
- {
- co->state = Conn_Open;
-
- if (client_is_our_response(cl))
+ struct client *cl = co->client;
+ int ev;
+ int r = ZOOM_event_nonblock(1, &link);
+ if (!r)
+ break;
+ if (!cl)
+ continue;
+ ev = ZOOM_connection_last_event(link);
+
+#if 1
+ yaz_log(YLOG_DEBUG, "%p Connection ZOOM_EVENT_%s", co, ZOOM_get_event_str(ev));
+#endif
+ switch (ev)
+ {
+ case ZOOM_EVENT_TIMEOUT:
+ break;
+ case ZOOM_EVENT_END: