/*! \brief * Make the poll call, and call * the callbacks for anything that needs * to be handled */ int ast_io_wait(struct io_context *ioc, int howlong) { int res, x, origcnt; DEBUG(ast_debug(1, "ast_io_wait()\n")); if ((res = ast_poll(ioc->fds, ioc->fdcnt, howlong)) <= 0) { return res; } /* At least one event tripped */ origcnt = ioc->fdcnt; for (x = 0; x < origcnt; x++) { /* Yes, it is possible for an entry to be deleted and still have an event waiting if it occurs after the original calling id */ if (ioc->fds[x].revents && ioc->ior[x].id) { /* There's an event waiting */ ioc->current_ioc = *ioc->ior[x].id; if (ioc->ior[x].callback) { if (!ioc->ior[x].callback(ioc->ior[x].id, ioc->fds[x].fd, ioc->fds[x].revents, ioc->ior[x].data)) { /* Time to delete them since they returned a 0 */ ast_io_remove(ioc, ioc->ior[x].id); } } ioc->current_ioc = -1; } } if (ioc->needshrink) io_shrink(ioc); return res; }
int ast_io_wait(struct io_context *ioc, int howlong) { /* * Make the poll call, and call * the callbacks for anything that needs * to be handled */ int res; int x; int origcnt; DEBUG(ast_log(LOG_DEBUG, "ast_io_wait()\n")); res = poll(ioc->fds, ioc->fdcnt, howlong); if (res > 0) { /* * At least one event */ origcnt = ioc->fdcnt; for(x = 0; x < origcnt; x++) { /* Yes, it is possible for an entry to be deleted and still have an event waiting if it occurs after the original calling id */ if (ioc->fds[x].revents && ioc->ior[x].id) { /* There's an event waiting */ ioc->current_ioc = *ioc->ior[x].id; if (ioc->ior[x].callback) { if (!ioc->ior[x].callback(ioc->ior[x].id, ioc->fds[x].fd, ioc->fds[x].revents, ioc->ior[x].data)) { /* Time to delete them since they returned a 0 */ ast_io_remove(ioc, ioc->ior[x].id); } } ioc->current_ioc = -1; } } if (ioc->needshrink) io_shrink(ioc); } return res; }
static void ast_netsock_destroy(struct ast_netsock *netsock) { ast_io_remove(netsock->ioc, netsock->ioref); close(netsock->sockfd); ast_free(netsock); }