summaryrefslogtreecommitdiff
path: root/ev_select.c
diff options
context:
space:
mode:
authorroot <root>2007-10-31 17:55:55 +0000
committerroot <root>2007-10-31 17:55:55 +0000
commitf432e03e319f1ece247021aa0810c4af1cb50042 (patch)
treefac009e395322dd6dd7a30d39043a1d04747eca2 /ev_select.c
parentcaa1fd0cc89d111a00f323bb6eff46f57311aed5 (diff)
beginners mistake
Diffstat (limited to 'ev_select.c')
-rw-r--r--ev_select.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/ev_select.c b/ev_select.c
index 1262f48..46a77e2 100644
--- a/ev_select.c
+++ b/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)