X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Feventl.c;h=be79cf3e006e68cb248c7db7d05f8a253c4f30d2;hp=dffdbe7121e49ad926147710663e014af2928efe;hb=3d6e2f0931ae87fe01e857d4573d946f6cd8e6f1;hpb=ee6ab2ee3a9ee1a8c65d7272ec7fba1d886f5af0 diff --git a/src/eventl.c b/src/eventl.c index dffdbe7..be79cf3 100644 --- a/src/eventl.c +++ b/src/eventl.c @@ -1,8 +1,7 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2008 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ - /** * \file eventl.c * \brief Implements event loop handling for GFS. @@ -10,6 +9,9 @@ * This source implements the main event loop for the Generic Frontend * Server. */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -29,6 +31,7 @@ #include #include #include +#include #include "eventl.h" #include "session.h" #include @@ -75,7 +78,7 @@ int iochan_is_alive(IOCHAN chan) return 1; } -int iochan_event_loop(IOCHAN *iochans) +int iochan_event_loop(IOCHAN *iochans, int *watch_sig) { do /* loop as long as there are active associations to process */ { @@ -87,11 +90,6 @@ int iochan_event_loop(IOCHAN *iochans) int res; time_t now = time(0); - if (statserv_must_terminate()) - { - for (p = *iochans; p; p = p->next) - p->force_event = EVENT_TIMEOUT; - } for (p = *iochans; p; p = p->next) no_fds++; fds = (struct yaz_poll_fd *) xmalloc(no_fds * sizeof(*fds)); @@ -116,8 +114,9 @@ int iochan_event_loop(IOCHAN *iochans) w = p->max_idle; else w = ftime - now; + /* tv_sec will be minimum wait.. */ if (w < tv_sec) - tv_sec = w; + tv_sec = (int) w; /* can hold it because w < tv_sec */ } fds[i].fd = p->fd; fds[i].input_mask = input_mask; @@ -127,25 +126,16 @@ int iochan_event_loop(IOCHAN *iochans) { if (yaz_errno() == EINTR) { - if (statserv_must_terminate()) - { - for (p = *iochans; p; p = p->next) - p->force_event = EVENT_TIMEOUT; - } xfree(fds); + if (watch_sig && *watch_sig) + break; continue; } else { - /* Destroy the first member in the chain, and try again */ - association *assoc = (association *)iochan_getdata(*iochans); - COMSTACK conn = assoc->client_link; - - cs_close(conn); - destroy_association(assoc); - iochan_destroy(*iochans); - yaz_log(log_level, "error select, destroying iochan %p", - *iochans); + yaz_log(YLOG_WARN|YLOG_ERRNO, "yaz_poll"); + xfree(fds); + continue; } } now = time(0); @@ -215,6 +205,7 @@ int iochan_event_loop(IOCHAN *iochans) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab