// Copyright status: this file is in the public domain. #include #include #include "lx.h" #include "internal.h" int lx_event_loop(LX_CONN *xc) { xc->flags &= ~XCF_BREAK; while (1) { if (xc->flags & XCF_BREAK) return(0); if (lx__loop_once(xc) < 0) return(-1); } } void lx_break_loop(LX_CONN *xc) { xc->flags |= XCF_BREAK; } int lx__loop_once(LX_CONN *xc) { AIO_LOOP *v; v = xc->io; if (aio_pre_poll_v_of(1,&v) < 0) return(-1); if (aio_do_poll_v_of(1,&v) < 0) { if (errno == EINTR) return(0); return(-1); } aio_post_poll_v_of(1,&v); return(0); }