changed mux-poll again

This commit is contained in:
hyung-hwan 2020-05-24 17:40:47 +00:00
parent 829267edd7
commit c01a84e20b
2 changed files with 6 additions and 18 deletions

View File

@ -40,14 +40,7 @@ int mio_sys_initmux (mio_t* mio)
{
mio_sys_mux_t* mux = &mio->sysdep->mux;
#if defined(POLL)
mux->devnull = open("/dev/null", O_RDONLY);
if (mux->devnull == -1)
{
mio_seterrwithsyserr (mio, 0, errno);
return -1;
}
#elif defined(USE_EPOLL)
#if defined(USE_EPOLL)
mux->hnd = epoll_create(1000); /* TODO: choose proper initial size? */
if (mux->hnd == -1)
{
@ -82,9 +75,6 @@ void mio_sys_finimux (mio_t* mio)
}
mux->pd.capa = 0;
close (mux->devnull);
mux->devnull = MIO_SYSHND_INVALID;
#elif defined(USE_EPOLL)
close (mux->hnd);
mux->hnd = MIO_SYSHND_INVALID;
@ -128,7 +118,7 @@ int mio_sys_ctrlmux (mio_t* mio, mio_sys_mux_cmd_t cmd, mio_dev_t* dev, int dev_
switch (cmd)
{
case MIO_SYS_MUX_CMD_INSERT:
if (idx != MUX_INDEX_INVALID || idex != MUX_INDEX_SUSPENDED)
if (idx != MUX_INDEX_INVALID) /* not valid index and not MUX_INDEX_SUSPENDED */
{
mio_seterrnum (mio, MIO_EEXIST);
return -1;
@ -177,12 +167,12 @@ int mio_sys_ctrlmux (mio_t* mio, mio_sys_mux_cmd_t cmd, mio_dev_t* dev, int dev_
if (dev_cap & MIO_DEV_CAP_IN_WATCHED) events |= POLLIN;
if (dev_cap & MIO_DEV_CAP_OUT_WATCHED) events |= POLLOUT;
if (idx == MIO_INDEX_INVALID)
if (idx == MUX_INDEX_INVALID)
{
mio_seterrnum (mio, MIO_ENOENT);
return -1;
}
else if (idx == MIO_INDEX_SUSPENDED)
else if (idx == MUX_INDEX_SUSPENDED)
{
if (!events) return 0; /* no change. keep suspended */
goto do_insert;
@ -198,9 +188,10 @@ int mio_sys_ctrlmux (mio_t* mio, mio_sys_mux_cmd_t cmd, mio_dev_t* dev, int dev_
mux->pd.pfd[idx].events = events;
return 0;
}
case MIO_SYS_MUX_CMD_DELETE:
if (idx == MIO_INDEX_INVALID)
if (idx == MUX_INDEX_INVALID)
{
mio_seterrnum (mio, MIO_ENOENT);
return -1;

View File

@ -61,9 +61,6 @@ struct mio_sys_mux_t
mio_oow_t size;
mio_oow_t capa;
} pd; /* poll data */
int devnull;
};
#elif defined(USE_EPOLL)