projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
HTTP Timeouts. Memory leak checks and fixes. Changed member names for
[yaz-moved-to-github.git]
/
server
/
eventl.c
diff --git
a/server/eventl.c
b/server/eventl.c
index
0ba7f4a
..
cc150e7
100644
(file)
--- a/
server/eventl.c
+++ b/
server/eventl.c
@@
-1,9
+1,9
@@
/*
/*
- * Copyright (c) 1995-2001, Index Data
+ * Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: eventl.c,v 1.32 2002-09-25 12:37:07 adam Exp $
+ * $Id: eventl.c,v 1.36 2003-02-17 21:23:31 adam Exp $
*/
#include <stdio.h>
*/
#include <stdio.h>
@@
-57,20
+57,27
@@
int event_loop(IOCHAN *iochans)
IOCHAN p, nextp;
fd_set in, out, except;
int res, max;
IOCHAN p, nextp;
fd_set in, out, except;
int res, max;
- static struct timeval nullto = {0, 0}, to;
- struct timeval *timeout;
+ static struct timeval to;
+ time_t now = time(0);
+ if (statserv_must_terminate())
+ {
+ for (p = *iochans; p; p = p->next)
+ p->force_event = EVENT_TIMEOUT;
+ }
FD_ZERO(&in);
FD_ZERO(&out);
FD_ZERO(&except);
FD_ZERO(&in);
FD_ZERO(&out);
FD_ZERO(&except);
- timeout = &to; /* hang on select */
- to.tv_sec = 5*60;
- to.tv_usec = 0;
+ to.tv_sec = 3600;
+ to.tv_usec = 1;
max = 0;
for (p = *iochans; p; p = p->next)
{
max = 0;
for (p = *iochans; p; p = p->next)
{
+ time_t w, ftime;
+ yaz_log(LOG_LOG, "fd=%d flags=%d force_event=%d",
+ p->fd, p->flags, p->force_event);
if (p->force_event)
if (p->force_event)
- timeout = &nullto; /* polling select */
+ to.tv_sec = 0; /* polling select */
if (p->flags & EVENT_INPUT)
FD_SET(p->fd, &in);
if (p->flags & EVENT_OUTPUT)
if (p->flags & EVENT_INPUT)
FD_SET(p->fd, &in);
if (p->flags & EVENT_OUTPUT)
@@
-79,12
+86,31
@@
int event_loop(IOCHAN *iochans)
FD_SET(p->fd, &except);
if (p->fd > max)
max = p->fd;
FD_SET(p->fd, &except);
if (p->fd > max)
max = p->fd;
+ if (p->max_idle && p->last_event)
+ {
+ ftime = p->last_event + p->max_idle;
+ if (ftime < now)
+ w = p->max_idle;
+ else
+ w = ftime - now;
+ if (w < to.tv_sec)
+ to.tv_sec = w;
+ }
}
}
- res = YAZ_EV_SELECT(max + 1, &in, &out, &except, timeout);
+ yaz_log(LOG_LOG, "select start %d", to.tv_sec);
+ res = YAZ_EV_SELECT(max + 1, &in, &out, &except, &to);
+ yaz_log(LOG_LOG, "select end");
if (res < 0)
{
if (yaz_errno() == EINTR)
if (res < 0)
{
if (yaz_errno() == EINTR)
- continue;
+ {
+ if (statserv_must_terminate())
+ {
+ for (p = *iochans; p; p = p->next)
+ p->force_event = EVENT_TIMEOUT;
+ }
+ continue;
+ }
else
{
/* Destroy the first member in the chain, and try again */
else
{
/* Destroy the first member in the chain, and try again */
@@
-98,10
+124,10
@@
int event_loop(IOCHAN *iochans)
*iochans);
}
}
*iochans);
}
}
+ now = time(0);
for (p = *iochans; p; p = p->next)
{
int force_event = p->force_event;
for (p = *iochans; p; p = p->next)
{
int force_event = p->force_event;
- time_t now = time(0);
p->force_event = 0;
if (!p->destroyed && (FD_ISSET(p->fd, &in) ||
p->force_event = 0;
if (!p->destroyed && (FD_ISSET(p->fd, &in) ||
@@
-122,7
+148,7
@@
int event_loop(IOCHAN *iochans)
p->last_event = now;
(*p->fun)(p, EVENT_EXCEPT);
}
p->last_event = now;
(*p->fun)(p, EVENT_EXCEPT);
}
- if (!p->destroyed && ((p->max_idle && now - p->last_event >
+ if (!p->destroyed && ((p->max_idle && now - p->last_event >=
p->max_idle) || force_event == EVENT_TIMEOUT))
{
p->last_event = now;
p->max_idle) || force_event == EVENT_TIMEOUT))
{
p->last_event = now;