Joan Lledó <joanlluisll...@gmail.com> writes:
> Since Glibc calls the io_select() operation each time the user
> calls send() or recv(), in practice such sockets are just
Too bad there is no lwip_poll function.
Might the LwIP folks be amenable to adding one?
Your size calculations seem wrong.
glibc defines fd_mask = __fd_mask = long int.
FD_SETSIZE is the number of bits that fit in fd_set.
But then lwip_selscan does
size_t setsize = ((maxfdp1 / (8*(int)sizeof(fd_mask))) + 1) > FD_SETSIZE ?
((maxfdp1 / (8*(int)sizeof(fd_mask))) + 1) : FD_SETSIZE;
fd_mask lreadset[setsize], lwriteset[setsize], lexceptset[setsize];
memset(&lreadset, 0, setsize);
which has two bugs:
* It treats FD_SETSIZE as the minimum number of fd_mask elements,
even though it was supposed to be the number of bits.
That seems to waste some memory, but it isn't serious.
* It clears only the first setsize bytes of each array.
It should be doing memset(&lreadset, 0, setsize * sizeof(fd_mask)).
Likewise in the memcpy calls later.
This seems likely to cause real problems.
lwip_io_select_common has similar bugs plus it seems to leak
lreadset, lwriteset, or lexceptset in some cases.
I wonder how hard it would be to implement those select ops in
the translator without hogging a thread for each.