#include <yaz/comstack.h>
#include <yaz/xmalloc.h>
#include "eventl.h"
-#include <yaz/statserv.h>
+
+struct iochan_man_s {
+ IOCHAN channel_list;
+};
+
+iochan_man_t iochan_man_create(void)
+{
+ iochan_man_t man = xmalloc(sizeof(*man));
+ man->channel_list = 0;
+ return man;
+}
+
+void iochan_man_destroy(iochan_man_t *mp)
+{
+ if (*mp)
+ {
+ xfree(*mp);
+ *mp = 0;
+ }
+}
+
+void iochan_add(iochan_man_t man, IOCHAN chan)
+{
+ chan->next = man->channel_list;
+ man->channel_list = chan;
+}
IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags)
{
return new_iochan;
}
-int event_loop(IOCHAN *iochans)
+static int event_loop(IOCHAN *iochans)
{
do /* loop as long as there are active associations to process */
{
return 0;
}
+void iochan_man_events(iochan_man_t man)
+{
+ event_loop(&man->channel_list);
+}
+
/*
* Local variables:
* c-basic-offset: 4
struct iochan *next;
} *IOCHAN;
+typedef struct iochan_man_s *iochan_man_t;
+
+iochan_man_t iochan_man_create(void);
+void iochan_add(iochan_man_t man, IOCHAN chan);
+void iochan_man_events(iochan_man_t man);
+void iochan_man_destroy(iochan_man_t *mp);
+
#define iochan_destroy(i) (void)((i)->destroyed = 1)
#define iochan_getfd(i) ((i)->fd)
#define iochan_setfd(i, f) ((i)->fd = (f))
#define iochan_getfun(i) ((i)->fun)
#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), (i)->last_event = time(0))
#define iochan_activity(i) ((i)->last_event = time(0))
#define iochan_setsocketfun(i, f) ((i)->socketfun = (f))
#define iochan_getmaskfun(i) ((i)->maskfun)
IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
-int event_loop(IOCHAN *iochans);
#endif
// Master list of connections we're handling events to
-static IOCHAN channel_list = 0; /* thread pr */
+static iochan_man_t pazpar2_chan_man = 0; /* thread pr */
+
+void pazpar2_chan_man_start(void)
+{
+ pazpar2_chan_man = iochan_man_create();
+}
void pazpar2_add_channel(IOCHAN chan)
{
- chan->next = channel_list;
- channel_list = chan;
+ assert(pazpar2_chan_man);
+ iochan_add(pazpar2_chan_man, chan);
}
void pazpar2_event_loop()
{
- event_loop(&channel_list);
+ assert(pazpar2_chan_man);
+ iochan_man_events(pazpar2_chan_man);
}
static struct record_metadata *record_metadata_init(
"mode");
return 1;
}
+ pazpar2_chan_man_start();
ret = config_start_listeners(config, listener_override);
if (ret)
return ret; /* error starting http listener */
YAZ_CHECK(p);
if (p)
{
+ iochan_man_t chan_man = iochan_man_create();
IOCHAN chan = iochan_create(thread_fd, iochan_handler,
EVENT_INPUT|EVENT_TIMEOUT);
iochan_settimeout(chan, 1);
iochan_setdata(chan, p);
+ iochan_add(chan_man, chan);
- event_loop(&chan);
+ iochan_man_events(chan_man);
sel_thread_destroy(p);
}
}