mirror of /home/gitosis/repositories/libev.git
beginners mistake
This commit is contained in:
parent
3b04fc1fbb
commit
3556dbc445
15
ev.c
15
ev.c
|
@ -41,8 +41,6 @@
|
|||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#define HAVE_EPOLL 1
|
||||
|
||||
#ifndef HAVE_MONOTONIC
|
||||
# ifdef CLOCK_MONOTONIC
|
||||
# define HAVE_MONOTONIC 1
|
||||
|
@ -190,6 +188,19 @@ queue_events (W *events, int eventcnt, int type)
|
|||
event (events [i], type);
|
||||
}
|
||||
|
||||
/* called on EBADF to verify fds */
|
||||
static void
|
||||
fd_recheck ()
|
||||
{
|
||||
int fd;
|
||||
|
||||
for (fd = 0; fd < anfdmax; ++fd)
|
||||
if (anfds [fd].wev)
|
||||
if (fcntl (fd, F_GETFD) == -1 && errno == EBADF)
|
||||
while (anfds [fd].head)
|
||||
evio_stop (anfds [fd].head);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static struct ev_timer **timers;
|
||||
|
|
19
ev_select.c
19
ev_select.c
|
@ -49,12 +49,16 @@ select_modify (int fd, int oev, int nev)
|
|||
|
||||
if (vec_max < (fd >> 5) + 1)
|
||||
{
|
||||
vec_max = (fd >> 5) + 1;
|
||||
int new_max = (fd >> 5) + 1;
|
||||
|
||||
vec_ri = (unsigned char *)realloc (vec_ri, vec_max * 4);
|
||||
vec_ro = (unsigned char *)realloc (vec_ro, vec_max * 4); /* could free/malloc */
|
||||
vec_wi = (unsigned char *)realloc (vec_wi, vec_max * 4);
|
||||
vec_wo = (unsigned char *)realloc (vec_wo, vec_max * 4); /* could free/malloc */
|
||||
vec_ri = (unsigned char *)realloc (vec_ri, new_max * 4);
|
||||
vec_ro = (unsigned char *)realloc (vec_ro, new_max * 4); /* could free/malloc */
|
||||
vec_wi = (unsigned char *)realloc (vec_wi, new_max * 4);
|
||||
vec_wo = (unsigned char *)realloc (vec_wo, new_max * 4); /* could free/malloc */
|
||||
|
||||
for (; vec_max < new_max; ++vec_max)
|
||||
((uint32_t *)vec_ri)[vec_max] =
|
||||
((uint32_t *)vec_wi)[vec_max] = 0;
|
||||
}
|
||||
|
||||
vec_ri [offs] |= mask;
|
||||
|
@ -106,6 +110,11 @@ static void select_poll (ev_tstamp timeout)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (res < 0)
|
||||
{
|
||||
if (errno == EBADF)
|
||||
fd_recheck ();
|
||||
}
|
||||
}
|
||||
|
||||
void select_init (int flags)
|
||||
|
|
Loading…
Reference in New Issue