* Sebastian Hammer, Adam Dickmeiss
*
* $Log: eventl.c,v $
- * Revision 1.9 1995-06-05 10:53:31 quinn
+ * Revision 1.10 1995-06-16 10:31:33 quinn
+ * Added session timeout.
+ *
+ * Revision 1.9 1995/06/05 10:53:31 quinn
* Added a better SCAN.
*
* Revision 1.8 1995/05/16 08:51:01 quinn
new->fun = cb;
new->next = iochans;
new->force_event = 0;
+ new->last_event = new->max_idle = 0;
iochans = new;
return new;
}
IOCHAN p, nextp;
fd_set in, out, except;
int res, max;
- static struct timeval nullto = {0, 0};
+ static struct timeval nullto = {0, 0}, to = {60*5, 0};
struct timeval *timeout;
FD_ZERO(&in);
FD_ZERO(&out);
FD_ZERO(&except);
- timeout = 0; /* hang on select */
+ timeout = &to; /* hang on select */
max = 0;
for (p = iochans; p; p = p->next)
{
for (p = iochans; p; p = p->next)
{
int force_event = p->force_event;
+ time_t now = time(0);
p->force_event = 0;
if (FD_ISSET(p->fd, &in) || force_event == EVENT_INPUT)
+ {
+ p->last_event = now;
(*p->fun)(p, EVENT_INPUT);
+ }
if (!p->destroyed && (FD_ISSET(p->fd, &out) ||
- force_event == EVENT_OUTPUT))
+ force_event == EVENT_OUTPUT))
+ {
+ p->last_event = now;
(*p->fun)(p, EVENT_OUTPUT);
+ }
if (!p->destroyed && (FD_ISSET(p->fd, &except) ||
force_event == EVENT_EXCEPT))
+ {
+ p->last_event = now;
(*p->fun)(p, EVENT_EXCEPT);
+ }
+ if (!p->destroyed && p->max_idle && now - p->last_event >
+ p->max_idle)
+ (*p->fun)(p, EVENT_TIMEOUT);
}
for (p = iochans; p; p = nextp)
{
for (pr = iochans; pr; pr = pr->next)
if (pr->next == p)
break;
- assert(pr);
+ assert(pr); /* grave error if it weren't there */
pr->next = p->next;
}
if (nextp == p)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: eventl.h,v $
- * Revision 1.6 1995-05-16 08:51:02 quinn
+ * Revision 1.7 1995-06-16 10:31:34 quinn
+ * Added session timeout.
+ *
+ * Revision 1.6 1995/05/16 08:51:02 quinn
* License, documentation, and memory fixes
*
* Revision 1.5 1995/05/15 11:56:37 quinn
IOC_CALLBACK fun;
void *data;
int destroyed;
+ time_t last_event;
+ time_t max_idle;
struct iochan *next;
} *IOCHAN;
#define iochan_setfun(i, d) ((i)->fun = d)
#define iochan_setevent(i, e) ((i)->force_event = (e))
#define iochan_getnext(i) ((i)->next)
+#define iochan_settimeout(i, t) ((i)->max_idle = (t))
IOCHAN iochan_getchan(void);
IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: seshigh.c,v $
- * Revision 1.35 1995-06-15 07:45:14 quinn
+ * Revision 1.36 1995-06-16 10:31:36 quinn
+ * Added session timeout.
+ *
+ * Revision 1.35 1995/06/15 07:45:14 quinn
* Moving to v3.
*
* Revision 1.34 1995/06/14 15:26:46 quinn
request *req;
assert(h && conn && assoc);
+ if (event == EVENT_TIMEOUT)
+ {
+ logf(LOG_LOG, "Timeout - closing connection.");
+ cs_close(conn);
+ destroy_association(assoc);
+ iochan_destroy(h);
+ return;
+ }
if (event & EVENT_INPUT || event & EVENT_WORK) /* input */
{
if (event & EVENT_INPUT)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: session.h,v $
- * Revision 1.8 1995-05-17 08:42:28 quinn
+ * Revision 1.9 1995-06-16 10:31:38 quinn
+ * Added session timeout.
+ *
+ * Revision 1.8 1995/05/17 08:42:28 quinn
* Transfer auth info to backend. Allow backend to reject init gracefully.
*
* Revision 1.7 1995/05/16 08:51:08 quinn
#include <odr.h>
#include <oid.h>
#include <proto.h>
+#include <sys/types.h>
#include <eventl.h>
typedef struct request
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: statserv.c,v $
- * Revision 1.23 1995-06-15 12:30:48 quinn
+ * Revision 1.24 1995-06-16 10:31:39 quinn
+ * Added session timeout.
+ *
+ * Revision 1.23 1995/06/15 12:30:48 quinn
* Setuid-facility.
*
* Revision 1.22 1995/06/15 07:45:17 quinn
LOG_DEFAULT_LEVEL, /* log level */
"", /* no PDUs */
"", /* diagnostic output to stderr */
- "tcp:@:9999", /* default listener port */
- PROTO_Z3950, /* application protocol */
- 60, /* idle timeout (minutes) */
- 1024*1024*4, /* maximum PDU size (approx.) to allow */
+ "tcp:@:9999", /* default listener port */
+ PROTO_Z3950, /* default application protocol */
+ 2*60, /* idle timeout (minutes) */
+ 1024*1024, /* maximum PDU size (approx.) to allow */
"default-config", /* configuration name to pass to backend */
"" /* set user id */
};
exit(1);
}
iochan_setdata(new_chan, newas);
+ iochan_settimeout(new_chan, control_block.idle_timeout * 60);
logf(LOG_LOG, "accepted connection");
}
else
}
type = tcpip_type;
}
-#ifdef USE_XTIMOSI
else if (!strcmp(mode, "osi"))
{
+#ifdef USE_XTIMOSI
if (!(ap = mosi_strtoaddr(addr)))
{
fprintf(stderr, "Address resolution failed for TCP.\n");
exit(1);
}
type = mosi_type;
- }
+#else
+ fprintf(stderr, "OSI Transport not allowed by configuration.\n");
+ exit(1);
#endif
+ }
else
{
fprintf(stderr, "You must specify either 'osi:' or 'tcp:'.\n");
if (!(pw = getpwnam(control_block.setuid)))
{
- logf(LOG_FATAL|LOG_ERRNO, "%s", control_block.setuid);
+ logf(LOG_FATAL, "%s: Unknown user", control_block.setuid);
exit(1);
}
if (setuid(pw->pw_uid) < 0)