* Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.84 2006-08-16 14:18:59 adam Exp $
+ * $Id: zoom-c.c,v 1.98 2006-11-08 08:57:34 adam Exp $
*/
/**
* \file zoom-c.c
#include <sys/select.h>
#endif
#ifdef WIN32
+#if FD_SETSIZE < 512
+#define FD_SETSIZE 512
+#endif
#include <winsock.h>
#endif
static zoom_ret do_write_ex(ZOOM_connection c, char *buf_out, int len_out);
static char *cql2pqf(ZOOM_connection c, const char *cql);
-static void initlog()
+static void initlog(void)
{
static int log_level_initialized = 0;
if (!log_level_initialized)
}
}
+void ZOOM_connection_show_task(ZOOM_task task)
+{
+ switch(task->which)
+ {
+ case ZOOM_TASK_SEARCH:
+ yaz_log(YLOG_LOG, "search p=%p", task);
+ break;
+ case ZOOM_TASK_RETRIEVE:
+ yaz_log(YLOG_LOG, "retrieve p=%p", task);
+ break;
+ case ZOOM_TASK_CONNECT:
+ yaz_log(YLOG_LOG, "connect p=%p", task);
+ break;
+ case ZOOM_TASK_SCAN:
+ yaz_log(YLOG_LOG, "scant p=%p", task);
+ break;
+ }
+}
+
+void ZOOM_connection_show_tasks(ZOOM_connection c)
+{
+ ZOOM_task task;
+ yaz_log(YLOG_LOG, "connection p=%p tasks", c);
+ for (task = c->tasks; task; task = task->next)
+ ZOOM_connection_show_task(task);
+}
+
ZOOM_task ZOOM_connection_add_task(ZOOM_connection c, int which)
{
ZOOM_task *taskp = &c->tasks;
return *taskp;
}
+ZOOM_API(int) ZOOM_connection_is_idle(ZOOM_connection c)
+{
+ return c->tasks ? 0 : 1;
+}
+
ZOOM_task ZOOM_connection_insert_task(ZOOM_connection c, int which)
{
ZOOM_task task = (ZOOM_task) xmalloc(sizeof(*task));
{
case ZOOM_TASK_SEARCH:
ZOOM_resultset_destroy(task->u.search.resultset);
+ xfree(task->u.search.syntax);
+ xfree(task->u.search.elementSetName);
break;
case ZOOM_TASK_RETRIEVE:
ZOOM_resultset_destroy(task->u.retrieve.resultset);
+ xfree(task->u.retrieve.syntax);
+ xfree(task->u.retrieve.elementSetName);
break;
case ZOOM_TASK_CONNECT:
break;
ZOOM_connection_remove_task(c);
}
-static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos);
+static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos,
+ const char *syntax,
+ const char *elementSetName);
ZOOM_API(ZOOM_connection)
ZOOM_connection_create(ZOOM_options options)
return c;
}
+
/* set database names. Take local databases (if set); otherwise
take databases given in ZURL (if set); otherwise use Default */
static char **set_DatabaseNames(ZOOM_connection con, ZOOM_options options,
- int *num)
+ int *num, ODR odr)
{
char **databaseNames;
const char *cp = ZOOM_options_get(options, "databaseName");
}
if (!cp)
cp = "Default";
- nmem_strsplit(con->odr_out->mem, "+", cp, &databaseNames, num);
+ nmem_strsplit(odr->mem, "+", cp, &databaseNames, num);
return databaseNames;
}
yaz_log(log_api, "%p ZOOM_connection_connect host=%s portnum=%d",
c, host, portnum);
+ set_ZOOM_error(c, ZOOM_ERROR_NONE, 0);
+ ZOOM_connection_remove_tasks(c);
+
if (c->cs)
{
yaz_log(log_details, "%p ZOOM_connection_connect reconnect ok", c);
c->async = ZOOM_options_get_bool(c->options, "async", 0);
yaz_log(log_details, "%p ZOOM_connection_connect async=%d", c, c->async);
- set_ZOOM_error(c, ZOOM_ERROR_NONE, 0);
-
task = ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
if (!c->async)
}
}
-ZOOM_resultset ZOOM_resultset_create()
+ZOOM_resultset ZOOM_resultset_create(void)
{
int i;
ZOOM_resultset r = (ZOOM_resultset) xmalloc(sizeof(*r));
r->query = 0;
r->connection = 0;
r->next = 0;
+ r->databaseNames = 0;
+ r->num_databaseNames = 0;
return r;
}
ZOOM_task task;
const char *cp;
int start, count;
+ const char *syntax, *elementSetName;
yaz_log(log_api, "%p ZOOM_connection_search set %p query %p", c, r, q);
r->r_sort_spec = q->sort_spec;
cp = ZOOM_options_get(r->options, "schema");
if (cp)
r->schema = xstrdup(cp);
+
+ r->databaseNames = set_DatabaseNames(c, c->options, &r->num_databaseNames,
+ r->odr);
r->connection = c;
task->u.search.resultset = r;
task->u.search.start = start;
task->u.search.count = count;
- ZOOM_resultset_addref(r);
+
+ syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ task->u.search.syntax = syntax ? xstrdup(syntax) : 0;
+ elementSetName = ZOOM_options_get(r->options, "elementSetName");
+ task->u.search.elementSetName = elementSetName
+ ? xstrdup(elementSetName) : 0;
+
+ ZOOM_resultset_addref(r);
(q->refcount)++;
ZOOM_API(size_t)
ZOOM_resultset_size(ZOOM_resultset r)
{
+ yaz_log(log_details, "ZOOM_resultset_size r=%p count=%d",
+ r, r->size);
return r->size;
}
c->state = STATE_IDLE;
}
+static int ZOOM_test_reconnect(ZOOM_connection c)
+{
+ if (!c->reconnect_ok)
+ return 0;
+ do_close(c);
+ c->reconnect_ok = 0;
+ c->tasks->running = 0;
+ ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT);
+ return 1;
+}
+
static void ZOOM_resultset_retrieve(ZOOM_resultset r,
int force_sync, int start, int count)
{
ZOOM_task task;
ZOOM_connection c;
const char *cp;
+ const char *syntax, *elementSetName;
if (!r)
return;
task->u.retrieve.start = start;
task->u.retrieve.count = count;
+ syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ task->u.retrieve.syntax = syntax ? xstrdup(syntax) : 0;
+ elementSetName = ZOOM_options_get(r->options, "elementSetName");
+ task->u.retrieve.elementSetName = elementSetName
+ ? xstrdup(elementSetName) : 0;
+
cp = ZOOM_options_get(r->options, "schema");
if (cp)
{
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_1);
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_2);
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_3);
-
+
/* Index Data's Z39.50 Implementor Id is 81 */
- ireq->implementationId = odr_prepend(c->odr_out,
- ZOOM_options_get(c->options, "implementationId"),
- odr_prepend(c->odr_out, "81", ireq->implementationId));
-
- ireq->implementationName = odr_prepend(c->odr_out,
- ZOOM_options_get(c->options, "implementationName"),
- odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
-
- version = odr_strdup(c->odr_out, "$Revision: 1.84 $");
+ ireq->implementationId =
+ odr_prepend(c->odr_out,
+ ZOOM_options_get(c->options, "implementationId"),
+ odr_prepend(c->odr_out, "81", ireq->implementationId));
+
+ ireq->implementationName =
+ odr_prepend(c->odr_out,
+ ZOOM_options_get(c->options, "implementationName"),
+ odr_prepend(c->odr_out, "ZOOM-C",
+ ireq->implementationName));
+
+ version = odr_strdup(c->odr_out, "$Revision: 1.98 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
- ireq->implementationVersion = odr_prepend(c->odr_out,
- ZOOM_options_get(c->options, "implementationVersion"),
- odr_prepend(c->odr_out, &version[11], ireq->implementationVersion));
-
+ ireq->implementationVersion =
+ odr_prepend(c->odr_out,
+ ZOOM_options_get(c->options, "implementationVersion"),
+ odr_prepend(c->odr_out, &version[11],
+ ireq->implementationVersion));
+
*ireq->maximumRecordSize =
ZOOM_options_get_int(c->options, "maximumRecordSize", 1024*1024);
*ireq->preferredMessageSize =
int *start, *count;
ZOOM_resultset resultset = 0;
Z_SRW_PDU *sr = 0;
- const char *recordPacking = 0;
+ const char *option_val = 0;
if (c->error) /* don't continue on error */
return zoom_complete;
assert(c->tasks);
- if (c->tasks->which == ZOOM_TASK_SEARCH)
+ switch(c->tasks->which)
{
+ case ZOOM_TASK_SEARCH:
resultset = c->tasks->u.search.resultset;
resultset->setname = xstrdup("default");
ZOOM_options_set(resultset->options, "setname", resultset->setname);
start = &c->tasks->u.search.start;
count = &c->tasks->u.search.count;
- }
- else if (c->tasks->which == ZOOM_TASK_RETRIEVE)
- {
+ break;
+ case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
for (i = 0; i < *count; i++)
{
ZOOM_record rec =
- record_cache_lookup(resultset, i + *start);
+ record_cache_lookup(resultset, i + *start,
+ c->tasks->u.retrieve.syntax,
+ c->tasks->u.retrieve.elementSetName);
if (!rec)
break;
else
if (*count == 0)
return zoom_complete;
+ break;
+ default:
+ return zoom_complete;
}
assert(resultset->query);
sr->u.request->maximumRecords = odr_intdup(
c->odr_out, resultset->step>0 ? resultset->step : *count);
sr->u.request->recordSchema = resultset->schema;
-
- recordPacking = ZOOM_resultset_option_get(resultset, "recordPacking");
-
- if (recordPacking)
- sr->u.request->recordPacking = odr_strdup(c->odr_out, recordPacking);
+ option_val = ZOOM_resultset_option_get(resultset, "recordPacking");
+ if (option_val)
+ sr->u.request->recordPacking = odr_strdup(c->odr_out, option_val);
+
+ option_val = ZOOM_resultset_option_get(resultset, "extraArgs");
+ if (option_val)
+ sr->extra_args = odr_strdup(c->odr_out, option_val);
return send_srw(c, sr);
}
#else
return zoom_complete;
}
- search_req->databaseNames =
- set_DatabaseNames(c, r->options, &search_req->num_databaseNames);
+ search_req->databaseNames = r->databaseNames;
+ search_req->num_databaseNames = r->num_databaseNames;
/* get syntax (no need to provide unless piggyback is in effect) */
- syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ syntax = c->tasks->u.search.syntax;
lslb = ZOOM_options_get_int(r->options, "largeSetLowerBound", -1);
ssub = ZOOM_options_get_int(r->options, "smallSetUpperBound", -1);
ZOOM_API(ZOOM_record)
ZOOM_resultset_record_immediate(ZOOM_resultset s,size_t pos)
{
- return record_cache_lookup(s, pos);
+ const char *syntax =
+ ZOOM_options_get(s->options, "preferredRecordSyntax");
+ const char *elementSetName =
+ ZOOM_options_get(s->options, "elementSetName");
+
+ return record_cache_lookup(s, pos, syntax, elementSetName);
}
ZOOM_API(ZOOM_record)
return buf;
}
+ZOOM_API(int)
+ ZOOM_record_error(ZOOM_record rec, const char **cp,
+ const char **addinfo, const char **diagset)
+{
+ Z_NamePlusRecord *npr;
+
+ if (!rec)
+ return 0;
+ npr = rec->npr;
+ if (npr && npr->which == Z_NamePlusRecord_surrogateDiagnostic)
+ {
+ Z_DiagRec *diag_rec = npr->u.surrogateDiagnostic;
+ int error = YAZ_BIB1_UNSPECIFIED_ERROR;
+ const char *add = 0;
+
+ if (diag_rec->which == Z_DiagRec_defaultFormat)
+ {
+ Z_DefaultDiagFormat *ddf = diag_rec->u.defaultFormat;
+ int oclass;
+
+ error = *ddf->condition;
+ switch (ddf->which)
+ {
+ case Z_DefaultDiagFormat_v2Addinfo:
+ add = ddf->u.v2Addinfo;
+ break;
+ case Z_DefaultDiagFormat_v3Addinfo:
+ add = ddf->u.v3Addinfo;
+ break;
+ }
+ if (diagset)
+ *diagset = yaz_z3950oid_to_str(ddf->diagnosticSetId, &oclass);
+ }
+ else
+ {
+ if (diagset)
+ *diagset = "Bib-1";
+ }
+ if (addinfo)
+ *addinfo = add ? add : "";
+ if (cp)
+ *cp = diagbib1_str(error);
+ return error;
+ }
+ return 0;
+}
+
ZOOM_API(const char *)
ZOOM_record_get(ZOOM_record rec, const char *type_spec, int *len)
{
}
static void record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
- int pos)
+ int pos,
+ const char *syntax, const char *elementSetName)
{
ZOOM_record_cache rc;
- const char *elementSetName =
- ZOOM_resultset_option_get(r, "elementSetName");
- const char *syntax =
- ZOOM_resultset_option_get(r, "preferredRecordSyntax");
ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_RECV_RECORD);
ZOOM_connection_put_event(r->connection, event);
r->record_hash[record_hash(pos)] = rc;
}
-static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos)
+static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos,
+ const char *syntax,
+ const char *elementSetName)
{
ZOOM_record_cache rc;
- const char *elementSetName =
- ZOOM_resultset_option_get(r, "elementSetName");
- const char *syntax =
- ZOOM_resultset_option_get(r, "preferredRecordSyntax");
for (rc = r->record_hash[record_hash(pos)]; rc; rc = rc->next)
{
{
ZOOM_resultset resultset;
int *start, *count;
+ const char *syntax = 0, *elementSetName = 0;
if (!c->tasks)
return ;
resultset = c->tasks->u.search.resultset;
start = &c->tasks->u.search.start;
count = &c->tasks->u.search.count;
+ syntax = c->tasks->u.search.syntax;
+ elementSetName = c->tasks->u.search.elementSetName;
break;
case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
count = &c->tasks->u.retrieve.count;
+ syntax = c->tasks->u.retrieve.syntax;
+ elementSetName = c->tasks->u.retrieve.elementSetName;
break;
default:
return;
sr->u.databaseOrSurDiagnostics;
for (i = 0; i<p->num_records; i++)
{
- record_cache_add(resultset, p->records[i], i + *start);
+ record_cache_add(resultset, p->records[i], i + *start,
+ syntax, elementSetName);
}
*count -= i;
*start += i;
/* present response and we didn't get any records! */
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
- record_cache_add(resultset, myrec, *start);
+ record_cache_add(resultset, myrec, *start,
+ syntax, elementSetName);
}
}
else if (present_phase)
/* present response and we didn't get any records! */
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
- record_cache_add(resultset, myrec, *start);
+ record_cache_add(resultset, myrec, *start, syntax, elementSetName);
}
}
}
resultset = c->tasks->u.search.resultset;
start = &c->tasks->u.search.start;
count = &c->tasks->u.search.count;
+ syntax = c->tasks->u.search.syntax;
+ elementSetName = c->tasks->u.search.elementSetName;
break;
case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
count = &c->tasks->u.retrieve.count;
-
- if (*start >= resultset->size)
- {
- yaz_log(log_details, "%p send_present start=%d >= size=%d",
- c, *start, resultset->size);
- return zoom_complete;
- }
- if (*start + *count > resultset->size)
- *count = resultset->size - *start;
+ syntax = c->tasks->u.retrieve.syntax;
+ elementSetName = c->tasks->u.retrieve.elementSetName;
break;
default:
return zoom_complete;
yaz_log(log_details, "%p send_present start=%d count=%d",
c, *start, *count);
- syntax = ZOOM_resultset_option_get(resultset, "preferredRecordSyntax");
- elementSetName = ZOOM_resultset_option_get(resultset, "elementSetName");
-
+ if (*start < 0 || *count < 0 || *start + *count > resultset->size)
+ {
+ set_dset_error(c, YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, "Bib-1",
+ "", 0);
+ }
if (c->error) /* don't continue on error */
return zoom_complete;
- if (*start < 0)
- return zoom_complete;
yaz_log(log_details, "send_present resultset=%p start=%d count=%d",
resultset, *start, *count);
for (i = 0; i < *count; i++)
{
ZOOM_record rec =
- record_cache_lookup(resultset, i + *start);
+ record_cache_lookup(resultset, i + *start, syntax, elementSetName);
if (!rec)
break;
else
c, q, q->query_string);
abort();
}
-
+
scan = (ZOOM_scanset) xmalloc(sizeof(*scan));
scan->connection = c;
scan->odr = odr_createmem(ODR_DECODE);
scan->termListAndStartPoint =
p_query_scan(scan->odr, PROTO_Z3950, &scan->attributeSet, start);
xfree(freeme);
+
+ scan->databaseNames = set_DatabaseNames(c, c->options,
+ &scan->num_databaseNames,
+ scan->odr);
if (scan->termListAndStartPoint != 0)
{
ZOOM_task task = ZOOM_connection_add_task(c, ZOOM_TASK_SCAN);
odr_intdup(c->odr_out,
ZOOM_options_get_int(scan->options, "stepSize", 0));
- req->databaseNames = set_DatabaseNames(c, scan->options,
- &req->num_databaseNames);
+ req->databaseNames = scan->databaseNames;
+ req->num_databaseNames = scan->num_databaseNames;
return send_APDU(c, apdu);
}
Z_External *r = (Z_External *) odr_malloc(p->odr_out, sizeof(*r));
const char *first_db = "Default";
int num_db;
- char **db = set_DatabaseNames(p->connection, p->options, &num_db);
+ char **db = set_DatabaseNames(p->connection, p->options, &num_db,
+ p->odr_out);
if (num_db > 0)
first_db = db[0];
Z_APDU *apdu = 0;
const char *first_db = "Default";
int num_db;
- char **db = set_DatabaseNames(p->connection, p->options, &num_db);
+ char **db = set_DatabaseNames(p->connection, p->options, &num_db, p->odr_out);
const char *action = ZOOM_options_get(p->options, "action");
const char *recordIdOpaque = ZOOM_options_get(p->options, "recordIdOpaque");
const char *recordIdNumber = ZOOM_options_get(p->options, "recordIdNumber");
c, task->which, task->running);
if (c->error != ZOOM_ERROR_NONE)
{
+ yaz_log(YLOG_LOG, "%p ZOOM_connection_exec_task "
+ "removing tasks because of error = %d", c, c->error);
yaz_log(log_details, "%p ZOOM_connection_exec_task "
"removing tasks because of error = %d", c, c->error);
ZOOM_connection_remove_tasks(c);
break;
case Z_APDU_close:
yaz_log(log_api, "%p recv_apdu Close PDU", c);
- if (c->reconnect_ok)
- {
- do_close(c);
- c->tasks->running = 0;
- ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT);
- }
- else
+ if (!ZOOM_test_reconnect(c))
{
set_ZOOM_error(c, ZOOM_ERROR_CONNECTION_LOST, c->host_port);
do_close(c);
NMEM nmem;
ZOOM_Event event;
int *start;
+ const char *syntax, *elementSetName;
if (!c->tasks)
return;
- if (c->tasks->which == ZOOM_TASK_SEARCH)
+ switch(c->tasks->which)
{
+ case ZOOM_TASK_SEARCH:
resultset = c->tasks->u.search.resultset;
start = &c->tasks->u.search.start;
- }
- else if (c->tasks->which == ZOOM_TASK_RETRIEVE)
- {
+ syntax = c->tasks->u.search.syntax;
+ elementSetName = c->tasks->u.search.elementSetName;
+ break;
+ case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
+ syntax = c->tasks->u.retrieve.syntax;
+ elementSetName = c->tasks->u.retrieve.elementSetName;
+ break;
+ default:
+ return;
}
- else
- return ;
-
event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH);
ZOOM_connection_put_event(c, event);
npr->u.databaseRecord->u.octet_aligned->len =
npr->u.databaseRecord->u.octet_aligned->size =
res->records[i].recordData_len;
- record_cache_add(resultset, npr, pos);
+ record_cache_add(resultset, npr, pos, syntax, elementSetName);
}
if (res->num_diagnostics > 0)
{
return 0;
if (r <= 0)
{
- if (c->reconnect_ok)
+ if (ZOOM_test_reconnect(c))
{
- do_close(c);
- c->reconnect_ok = 0;
yaz_log(log_details, "%p do_read reconnect read", c);
- c->tasks->running = 0;
- ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT);
}
else
{
if ((r = cs_put(c->cs, buf_out, len_out)) < 0)
{
yaz_log(log_details, "%p do_write_ex write failed", c);
- if (c->reconnect_ok)
+ if (ZOOM_test_reconnect(c))
{
- do_close(c);
- c->reconnect_ok = 0;
- yaz_log(log_details, "%p do_write_ex reconnect write", c);
- c->tasks->running = 0;
- ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT);
return zoom_pending;
}
if (c->state == STATE_CONNECTING)
return ZOOM_connection_error_x(c, cp, addinfo, 0);
}
-static int ZOOM_connection_do_io(ZOOM_connection c, int mask)
+static void ZOOM_connection_do_io(ZOOM_connection c, int mask)
{
ZOOM_Event event = 0;
int r = cs_look(c->cs);
}
else if (r == CS_CONNECT)
{
- int ret;
- event = ZOOM_Event_create(ZOOM_EVENT_CONNECT);
-
- ret = cs_rcvconnect(c->cs);
+ int ret = ret = cs_rcvconnect(c->cs);
yaz_log(log_details, "%p ZOOM_connection_do_io "
"cs_rcvconnect returned %d", c, ret);
if (ret == 1)
c->mask += ZOOM_SELECT_WRITE;
if (c->cs->io_pending & CS_WANT_READ)
c->mask += ZOOM_SELECT_READ;
- ZOOM_connection_put_event(c, event);
}
else if (ret == 0)
{
+ event = ZOOM_Event_create(ZOOM_EVENT_CONNECT);
ZOOM_connection_put_event(c, event);
get_cert(c);
if (c->proto == PROTO_Z3950)
{
set_ZOOM_error(c, ZOOM_ERROR_CONNECT, c->host_port);
do_close(c);
- ZOOM_connection_put_event(c, event);
}
}
else
{
+ if (mask & ZOOM_SELECT_EXCEPT)
+ {
+ if (ZOOM_test_reconnect(c))
+ {
+ event = ZOOM_Event_create(ZOOM_EVENT_CONNECT);
+ ZOOM_connection_put_event(c, event);
+ }
+ else
+ {
+ set_ZOOM_error(c, ZOOM_ERROR_CONNECTION_LOST, c->host_port);
+ do_close(c);
+ }
+ return;
+ }
if (mask & ZOOM_SELECT_READ)
do_read(c);
if (c->cs && (mask & ZOOM_SELECT_WRITE))
do_write(c);
}
- return 1;
}
ZOOM_API(int)
int max_fd = 0;
yaz_log(log_details, "ZOOM_event(no=%d,cs=%p)", no, cs);
+
for (i = 0; i<no; i++)
{
ZOOM_connection c = cs[i];
ZOOM_Event event;
+
+#if 0
+ if (c)
+ ZOOM_connection_show_tasks(c);
+#endif
+
if (c && (event = ZOOM_connection_get_event(c)))
{
ZOOM_Event_destroy(event);
return 0;
#if HAVE_SYS_POLL_H
- r = poll(pollfds, nfds, (timeout == -1 ? -1 : timeout * 1000));
+ while ((r = poll(pollfds, nfds,
+ (timeout == -1 ? -1 : timeout * 1000))) < 0
+ && errno == EINTR)
+ {
+ ;
+ }
+ if (r < 0)
+ yaz_log(YLOG_WARN|YLOG_ERRNO, "ZOOM_event: poll");
for (i = 0; i<nfds; i++)
{
ZOOM_connection c = poll_cs[i];
#else
tv.tv_sec = timeout;
tv.tv_usec = 0;
+
+ while ((r = select(max_fd+1, &input, &output, &except,
+ (timeout == -1 ? 0 : &tv))) < 0 && errno == EINTR)
+ {
+ ;
+ }
+ if (r < 0)
+ yaz_log(YLOG_WARN|YLOG_ERRNO, "ZOOM_event: select");
+
r = select(max_fd+1, &input, &output, &except, (timeout == -1 ? 0 : &tv));
for (i = 0; i<no; i++)
{