X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=server%2Feventl.c;h=b9b88b5f2068dbcdd44c896d0f285e2f861c7742;hp=3d2df2fb343920029b55f28f2895892fe2b2e29d;hb=d32b1dbdc1f0392883547cc9e56c26f384a4c57f;hpb=0a3a8b6400167c2dfd6e6b5f135f6ad4783e554c diff --git a/server/eventl.c b/server/eventl.c index 3d2df2f..b9b88b5 100644 --- a/server/eventl.c +++ b/server/eventl.c @@ -4,7 +4,23 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: eventl.c,v $ - * Revision 1.2 1995-03-14 10:27:59 quinn + * Revision 1.7 1995-03-27 15:02:01 quinn + * Added some includes for better portability + * + * Revision 1.6 1995/03/27 08:34:21 quinn + * Added dynamic server functionality. + * Released bindings to session.c (is now redundant) + * + * Revision 1.5 1995/03/15 08:37:41 quinn + * Now we're pretty much set for nonblocking I/O. + * + * Revision 1.4 1995/03/14 16:59:48 quinn + * Bug-fixes + * + * Revision 1.3 1995/03/14 11:30:14 quinn + * Works better now. + * + * Revision 1.2 1995/03/14 10:27:59 quinn * More work on demo server. * * Revision 1.1 1995/03/10 18:22:44 quinn @@ -17,10 +33,19 @@ #include #include #include +#include +#include #include -IOCHAN iochans = 0; +#include + +static IOCHAN iochans = 0; + +IOCHAN iochan_getchan(void) +{ + return iochans; +} IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags) { @@ -33,6 +58,7 @@ IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags) new->flags = flags; new->fun = cb; new->next = iochans; + new->force_event = 0; iochans = new; return new; } @@ -51,6 +77,7 @@ int event_loop() FD_ZERO(&out); FD_ZERO(&except); timeout = 0; /* hang on select */ + max = 0; for (p = iochans; p; p = p->next) { if (p->force_event) @@ -70,22 +97,24 @@ int event_loop() continue; return 1; } - if (!res) - continue; - for (p = iochans; p; p = nextp) + for (p = iochans; p; p = p->next) { int force_event = p->force_event; p->force_event = 0; - nextp = p->next; if (FD_ISSET(p->fd, &in) || force_event == EVENT_INPUT) (*p->fun)(p, EVENT_INPUT); - if (!p->destroyed && (FD_ISSET(p->fd, &in) || + if (!p->destroyed && (FD_ISSET(p->fd, &out) || force_event == EVENT_OUTPUT)) (*p->fun)(p, EVENT_OUTPUT); if (!p->destroyed && (FD_ISSET(p->fd, &except) || force_event == EVENT_EXCEPT)) (*p->fun)(p, EVENT_EXCEPT); + } + for (p = iochans; p; p = nextp) + { + nextp = p->next; + if (p->destroyed) { IOCHAN tmp = p, pr;