Added a better SCAN.
[yaz-moved-to-github.git] / server / eventl.c
index 1780a01..42dd1f9 100644 (file)
@@ -1,10 +1,26 @@
 /*
- * Copyright (C) 1994, Index Data I/S 
- * All rights reserved.
+ * Copyright (c) 1995, Index Data
+ * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: eventl.c,v $
- * Revision 1.4  1995-03-14 16:59:48  quinn
+ * Revision 1.9  1995-06-05 10:53:31  quinn
+ * Added a better SCAN.
+ *
+ * Revision 1.8  1995/05/16  08:51:01  quinn
+ * License, documentation, and memory fixes
+ *
+ * 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
 #include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#ifdef _AIX
+#include <sys/select.h>
+#endif
 
 #include <eventl.h>
 
-IOCHAN iochans = 0;
+#include <dmalloc.h>
+
+static IOCHAN iochans = 0;
+
+IOCHAN iochan_getchan(void)
+{
+    return iochans;
+}
 
 IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags)
 {
@@ -78,22 +106,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;