Rob Saccoccio wrote:
I like the concept, but...
+ else if (aprset[i].desc_type == APR_NO_DESC) {
+ pollset[i].fd = -1;
+ continue;
I'm not sure if it's safe to have an fd of -1 in the pollset.
I don't know if its portable but its the right approach on Solaris:
If the value fd is less than zero, events is ignored and
revents is set to 0 in that entry on return from poll().
It doesn't appear to be portable. On Linux, for example,
ERRORS
EBADF An invalid file descriptor was given in one of the
sets.
Alternatively, we could compact the aprset array in
apr_poll_socket_remove(). This can be done in O(1)
You can't do that because you don't own the apr_pollfd_t array, management
of the array is (now) the caller's responsiblity. apr_poll_socket_remove()
and kin are deprecated.
I disagree; the whole point of apr_poll_socket_remove() is
to modify the array. We can't avoid modifying the array--
if we did, the API would no longer be compatible with old
code. We've only deprecated the API, not removed it, so
it still has to work as advertised. Similarly, the
apr_poll_socket_add() function still has to add a descriptor
to the array. These functions can't reallocate the array,
of course, but they definitely have a legitimate need to
modify its contents.
Brian