fr_exit_now(EXIT_FAILURE);
}
- if (fr_event_fd_insert(NULL, events, self_pipe[0],
+ if (fr_event_fd_insert(NULL, NULL, events, self_pipe[0],
rs_signal_action,
NULL,
NULL,
*/
if (event->in->type == PCAP_FILE_IN) {
rs_got_packet(events, in_p->fd, 0, event);
- } else if (fr_event_fd_insert(NULL, events, in_p->fd,
+ } else if (fr_event_fd_insert(NULL, NULL, events, in_p->fd,
rs_got_packet,
NULL,
NULL,
switch (what) {
case CURL_POLL_IN:
- if (fr_event_fd_insert(mhandle, mhandle->el, fd,
+ if (fr_event_fd_insert(mhandle, NULL, mhandle->el, fd,
_fr_curl_io_service_readable,
NULL,
_fr_curl_io_service_errored,
break;
case CURL_POLL_OUT:
- if (fr_event_fd_insert(mhandle, mhandle->el, fd,
+ if (fr_event_fd_insert(mhandle, NULL, mhandle->el, fd,
NULL,
_fr_curl_io_service_writable,
_fr_curl_io_service_errored,
break;
case CURL_POLL_INOUT:
- if (fr_event_fd_insert(mhandle, mhandle->el, fd,
+ if (fr_event_fd_insert(mhandle, NULL, mhandle->el, fd,
_fr_curl_io_service_readable,
_fr_curl_io_service_writable,
_fr_curl_io_service_errored,
(void) fcntl(c->pipe[0], F_SETFL, O_NONBLOCK | FD_CLOEXEC);
(void) fcntl(c->pipe[1], F_SETFL, O_NONBLOCK | FD_CLOEXEC);
- if (fr_event_fd_insert(c, el, c->pipe[0], pipe_read, NULL, NULL, c) < 0) {
+ if (fr_event_fd_insert(c, NULL, el, c->pipe[0], pipe_read, NULL, NULL, c) < 0) {
talloc_free(c);
fr_strerror_const_push("Failed adding FD to event list control socket");
return NULL;
app_io = s->listen->app_io;
s->filter = FR_EVENT_FILTER_IO;
- if (fr_event_fd_insert(nr, nr->el, s->listen->fd,
+ if (fr_event_fd_insert(nr, NULL, nr->el, s->listen->fd,
fr_network_read,
s->listen->no_write_callback ? NULL : fr_network_write,
fr_network_error,
if (fr_nonblock(nr->signal_pipe[0]) < 0) goto fail2;
if (fr_nonblock(nr->signal_pipe[1]) < 0) goto fail2;
- if (fr_event_fd_insert(nr, nr->el, nr->signal_pipe[0], _signal_pipe_read, NULL, NULL, nr) < 0) {
+ if (fr_event_fd_insert(nr, NULL, nr->el, nr->signal_pipe[0], _signal_pipe_read, NULL, NULL, nr) < 0) {
fr_strerror_const("Failed inserting event for signal pipe");
goto fail2;
}
return;
}
- ret = fr_event_fd_insert(bind_ctx, el, fd,
+ ret = fr_event_fd_insert(bind_ctx, NULL, el, fd,
NULL,
_ldap_bind_io_write, /* We'll be called again when the conn is open */
_ldap_bind_io_error,
if ((ret != LDAP_OPT_SUCCESS) || (fd < 0)) goto error;
}
c->fd = fd;
- ret = fr_event_fd_insert(bind_ctx, el, fd,
+ ret = fr_event_fd_insert(bind_ctx, NULL, el, fd,
_ldap_bind_io_read,
NULL,
_ldap_bind_io_error,
if ((ldap_get_option(c->handle, LDAP_OPT_DESC, &fd) == LDAP_SUCCESS) && (fd >= 0)) {
int ret;
- ret = fr_event_fd_insert(bind_ctx, el, fd,
+ ret = fr_event_fd_insert(bind_ctx, NULL, el, fd,
NULL,
_ldap_bind_io_write,
_ldap_bind_io_error,
break;
}
- if (fr_event_fd_insert(ldap_conn, el, ldap_conn->fd,
+ if (fr_event_fd_insert(ldap_conn, NULL, el, ldap_conn->fd,
read_fn,
write_fn,
ldap_conn_error,
*/
if (sasl_ctx->rmech) DEBUG3("Continuing SASL mech %s...", sasl_ctx->rmech);
- ret = fr_event_fd_insert(sasl_ctx, el, fd,
+ ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
NULL,
_ldap_sasl_bind_io_write, /* Need to write more SASL stuff */
_ldap_sasl_bind_io_error,
return;
}
- ret = fr_event_fd_insert(sasl_ctx, el, fd,
+ ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
NULL,
_ldap_sasl_bind_io_write, /* We'll be called again when the conn is open */
_ldap_sasl_bind_io_error,
if ((ret != LDAP_OPT_SUCCESS) || (fd < 0)) goto error;
}
c->fd = fd;
- ret = fr_event_fd_insert(sasl_ctx, el, fd,
+ ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
_ldap_sasl_bind_io_read,
NULL,
_ldap_sasl_bind_io_error,
if ((ldap_get_option(c->handle, LDAP_OPT_DESC, &fd) == LDAP_SUCCESS) && (fd >= 0)){
int ret;
- ret = fr_event_fd_insert(sasl_ctx, el, fd,
+ ret = fr_event_fd_insert(sasl_ctx, NULL, el, fd,
NULL,
_ldap_sasl_bind_io_write,
_ldap_sasl_bind_io_error,
return;
}
- ret = fr_event_fd_insert(tls_ctx, el, fd,
+ ret = fr_event_fd_insert(tls_ctx, NULL, el, fd,
NULL,
_ldap_start_tls_io_write, /* We'll be called again when the conn is open */
_ldap_start_tls_io_error,
if ((ret != LDAP_OPT_SUCCESS) || (fd < 0)) goto error;
}
c->fd = fd;
- ret = fr_event_fd_insert(tls_ctx, el, fd,
+ ret = fr_event_fd_insert(tls_ctx, NULL, el, fd,
_ldap_start_tls_io_read,
NULL,
_ldap_start_tls_io_error,
if ((ldap_get_option(c->handle, LDAP_OPT_DESC, &fd) == LDAP_SUCCESS) && (fd >= 0)) {
int ret;
- ret = fr_event_fd_insert(tls_ctx, el, fd,
+ ret = fr_event_fd_insert(tls_ctx, NULL, el, fd,
NULL,
_ldap_start_tls_io_write,
_ldap_start_tls_io_error,
DEBUG4("redis handle %p - Registered for %s%serror events on FD %i",
h, read ? "read+" : "", write ? "write+" : "", c->fd);
- if (fr_event_fd_insert(h, el, c->fd,
+ if (fr_event_fd_insert(h, NULL, el, c->fd,
read ? _redis_io_service_readable : NULL,
write ? _redis_io_service_writable : NULL,
_redis_io_service_errored,
* If connection becomes writable we
* assume it's open.
*/
- if (fr_event_fd_insert(conn, conn->pub.el, fd,
+ if (fr_event_fd_insert(conn, NULL, conn->pub.el, fd,
NULL,
_connection_writable,
_connection_error,
* Accept a maximum of 32k of data from the process.
*/
fr_sbuff_init_talloc(exec->stdout_ctx, &exec->stdout_buff, &exec->stdout_tctx, 128, 32 * 1024);
- if (fr_event_fd_insert(ctx, el, exec->stdout_fd, exec_stdout_read, NULL, NULL, exec) < 0) {
+ if (fr_event_fd_insert(ctx, NULL, el, exec->stdout_fd, exec_stdout_read, NULL, NULL, exec) < 0) {
RPEDEBUG("Failed adding event listening to stdout");
goto fail_and_close;
}
.prefix = exec->stdout_prefix
};
- if (fr_event_fd_insert(ctx, el, exec->stdout_fd, log_request_fd_event,
+ if (fr_event_fd_insert(ctx, NULL, el, exec->stdout_fd, log_request_fd_event,
NULL, NULL, &exec->stdout_uctx) < 0){
RPEDEBUG("Failed adding event listening to stdout");
goto fail_and_close;
.prefix = exec->stderr_prefix
};
- if (fr_event_fd_insert(ctx, el, exec->stderr_fd, log_request_fd_event,
+ if (fr_event_fd_insert(ctx, NULL, el, exec->stderr_fd, log_request_fd_event,
NULL, NULL, &exec->stderr_uctx) < 0) {
RPEDEBUG("Failed adding event listening to stderr");
close(exec->stderr_fd);
}
DEBUG4("Created self-signal pipe. Read end FD %i, write end FD %i", self_pipe[0], self_pipe[1]);
- if (fr_event_fd_insert(NULL, event_list, self_pipe[0],
+ if (fr_event_fd_insert(NULL, NULL, event_list, self_pipe[0],
main_loop_signal_recv,
NULL,
NULL,
break;
case FR_TRUNK_CONN_EVENT_READ:
- TEST_CHECK(fr_event_fd_insert(conn, el, fd, _conn_io_read, NULL, _conn_io_error, tconn) == 0);
+ TEST_CHECK(fr_event_fd_insert(conn, NULL, el, fd, _conn_io_read, NULL, _conn_io_error, tconn) == 0);
break;
case FR_TRUNK_CONN_EVENT_WRITE:
- TEST_CHECK(fr_event_fd_insert(conn, el, fd, NULL, _conn_io_write, _conn_io_error, tconn) == 0);
+ TEST_CHECK(fr_event_fd_insert(conn, NULL, el, fd, NULL, _conn_io_write, _conn_io_error, tconn) == 0);
break;
case FR_TRUNK_CONN_EVENT_BOTH:
- TEST_CHECK(fr_event_fd_insert(conn, el, fd, _conn_io_read, _conn_io_write, _conn_io_error, tconn) == 0);
+ TEST_CHECK(fr_event_fd_insert(conn, NULL, el, fd, _conn_io_read, _conn_io_write, _conn_io_error, tconn) == 0);
break;
default:
/*
* This always needs to be inserted
*/
- TEST_CHECK(fr_event_fd_insert(our_h, el, our_h[1], _conn_io_loopback, NULL, NULL, our_h) == 0);
+ TEST_CHECK(fr_event_fd_insert(our_h, NULL, el, our_h[1], _conn_io_loopback, NULL, NULL, our_h) == 0);
return FR_CONNECTION_STATE_CONNECTED;
}
/*
* Register for events on the file descriptor
*/
- if (fr_event_fd_insert(request, unlang_interpret_event_list(request), fd,
+ if (fr_event_fd_insert(request, NULL, unlang_interpret_event_list(request), fd,
ev->fd_read ? unlang_event_fd_read_handler : NULL,
ev->fd_write ? unlang_event_fd_write_handler : NULL,
ev->fd_error ? unlang_event_fd_error_handler: NULL,
/** Associate I/O callbacks with a file descriptor
*
* @param[in] ctx to bind lifetime of the event to.
+ * @param[out] ef_out Where to store the output event
* @param[in] el to insert fd callback into.
* @param[in] fd to install filters for.
* @param[in] read_fn function to call when fd is readable.
* - -1 on failure.
*/
int _fr_event_fd_insert(NDEBUG_LOCATION_ARGS
- TALLOC_CTX *ctx, fr_event_list_t *el, int fd,
+ TALLOC_CTX *ctx, fr_event_fd_t **ef_out, fr_event_list_t *el, int fd,
fr_event_fd_cb_t read_fn,
fr_event_fd_cb_t write_fn,
fr_event_error_cb_t error,
}
return _fr_event_filter_insert(NDEBUG_LOCATION_VALS
- ctx, NULL, el, fd, FR_EVENT_FILTER_IO, &funcs, error, uctx);
+ ctx, ef_out, el, fd, FR_EVENT_FILTER_IO, &funcs, error, uctx);
}
/** Remove a file descriptor from the event loop
#define fr_event_filter_update(...) _fr_event_filter_update(NDEBUG_LOCATION_EXP __VA_ARGS__)
int _fr_event_fd_insert(NDEBUG_LOCATION_ARGS
- TALLOC_CTX *ctx, fr_event_list_t *el, int fd,
+ TALLOC_CTX *ctx, fr_event_fd_t **ef_out, fr_event_list_t *el, int fd,
fr_event_fd_cb_t read_fn,
fr_event_fd_cb_t write_fn,
fr_event_error_cb_t error,
/*
* Now do stderr...
*/
- if (unlikely(fr_event_fd_insert(NULL, el, stdout_pipe[1], fr_log_fd_event, NULL, NULL, &stdout_ctx) < 0)) {
+ if (unlikely(fr_event_fd_insert(NULL, NULL, el, stdout_pipe[1], fr_log_fd_event, NULL, NULL, &stdout_ctx) < 0)) {
fr_strerror_const_push("Failed adding stdout handler to event loop");
error_2:
dup2(STDOUT_FILENO, stdout_fd); /* Copy back the stdout FD */
stdout_ctx.type = L_ERR;
stdout_ctx.lvl = L_DBG_LVL_OFF; /* Log at all debug levels */
- if (unlikely(fr_event_fd_insert(NULL, el, stderr_pipe[1], fr_log_fd_event, NULL, NULL, &stderr_ctx) < 0)) {
+ if (unlikely(fr_event_fd_insert(NULL, NULL, el, stderr_pipe[1], fr_log_fd_event, NULL, NULL, &stderr_ctx) < 0)) {
fr_strerror_const_push("Failed adding stdout handler to event loop");
error_6:
dup2(STDERR_FILENO, stderr_fd); /* Copy back the stderr FD */
/*
*/
- if (fr_event_fd_insert(uq, uq->el, uq->fd, NULL,
+ if (fr_event_fd_insert(uq, NULL, uq->el, uq->fd, NULL,
udp_queue_writable, NULL, uq) < 0) {
return -1;
}
/*
* Set the callback which will handle the results of this query
*/
- if (fr_event_fd_insert(conn, conn->el, ldap_conn->fd,
+ if (fr_event_fd_insert(conn, NULL, conn->el, ldap_conn->fd,
_proto_ldap_socket_open_read,
NULL,
_proto_ldap_socket_open_error,
* We assume that the outbound socket is always writable.
* If not, too bad. Packets will get lost.
*/
- if (fr_event_fd_insert(t, mctx->el, fd,
+ if (fr_event_fd_insert(t, NULL, mctx->el, fd,
mod_icmp_read,
NULL,
mod_icmp_error,
int fd = *((int *)t->conn->h);
DEBUG3("Marking socket (%i) as idle", fd);
- if (fr_event_fd_insert(t->conn, t->el, fd,
+ if (fr_event_fd_insert(t->conn, NULL, t->el, fd,
_logtee_conn_read,
NULL,
_logtee_conn_error,
int fd = *((int *)t->conn->h);
DEBUG3("Marking socket (%i) as active - Draining requests", fd);
- if (fr_event_fd_insert(t->conn, t->el, fd,
+ if (fr_event_fd_insert(t->conn, NULL, t->el, fd,
_logtee_conn_read,
_logtee_conn_writable,
_logtee_conn_error,
return;
case FR_RETRY_CONTINUE:
- if (fr_event_fd_insert(h, el, h->fd, conn_writable_status_check, NULL,
+ if (fr_event_fd_insert(h, NULL, el, h->fd, conn_writable_status_check, NULL,
conn_error_status_check, conn) < 0) {
PERROR("%s - Failed inserting FD event", h->module_name);
fr_connection_signal_reconnect(conn, FR_CONNECTION_FAILED);
fr_connection_t *conn = talloc_get_type_abort(uctx, fr_connection_t);
udp_handle_t *h = talloc_get_type_abort(conn->h, udp_handle_t);
- if (fr_event_fd_insert(h, el, h->fd, conn_writable_status_check, NULL, conn_error_status_check, conn) < 0) {
+ if (fr_event_fd_insert(h, NULL, el, h->fd, conn_writable_status_check, NULL, conn_error_status_check, conn) < 0) {
PERROR("%s - Failed inserting FD event", h->module_name);
fr_connection_signal_reconnect(conn, FR_CONNECTION_FAILED);
}
* Switch to waiting on read and insert the event
* for the response timeout.
*/
- if (fr_event_fd_insert(h, conn->el, h->fd, conn_readable_status_check, NULL, conn_error_status_check, conn) < 0) {
+ if (fr_event_fd_insert(h, NULL, conn->el, h->fd, conn_readable_status_check, NULL, conn_error_status_check, conn) < 0) {
PERROR("%s - Failed inserting FD event", h->module_name);
goto fail;
}
* one response to bring the connection online,
* otherwise we need inst->num_answers_to_alive
*/
- if (fr_event_fd_insert(h, conn->el, h->fd, NULL,
+ if (fr_event_fd_insert(h, NULL, conn->el, h->fd, NULL,
conn_writable_status_check, conn_error_status_check, conn) < 0) goto fail;
/*
* If we're not doing status-checks, signal the connection
}
- if (fr_event_fd_insert(h, el, h->fd,
+ if (fr_event_fd_insert(h, NULL, el, h->fd,
read_fn,
write_fn,
conn_error,
break;
}
- if (fr_event_fd_insert(h, el, h->fd,
+ if (fr_event_fd_insert(h, NULL, el, h->fd,
read_fn,
write_fn,
conn_error,
* and resume requests which are
* waiting.
*/
- if (fr_event_fd_insert(NULL, el, req_pipe[0], _sigtran_pipe_read, NULL, _sigtran_pipe_error, NULL) < 0) {
+ if (fr_event_fd_insert(NULL, NULL, el, req_pipe[0], _sigtran_pipe_read, NULL, _sigtran_pipe_error, NULL) < 0) {
ERROR("worker - Failed listening on osmocom pipe");
goto error;
}
}
- if (fr_event_fd_insert(h, el, h->fd,
+ if (fr_event_fd_insert(h, NULL, el, h->fd,
read_fn,
write_fn,
conn_error,
DEBUG4("unbound event %p - Registered for read+write events on FD %i", ev, ev->fd);
- if (fr_event_fd_insert(ev, ev->ev_b->el, ev->fd,
+ if (fr_event_fd_insert(ev, NULL, ev->ev_b->el, ev->fd,
_unbound_io_service_readable,
_unbound_io_service_writable,
_unbound_io_service_errored,
DEBUG4("unbound event %p - Registered for read+error events on FD %i", ev, ev->fd);
- if (fr_event_fd_insert(ev, ev->ev_b->el, ev->fd,
+ if (fr_event_fd_insert(ev, NULL, ev->ev_b->el, ev->fd,
_unbound_io_service_readable,
NULL,
_unbound_io_service_errored,
DEBUG4("unbound event %p - Registered for write+error events on FD %i", ev, ev->fd);
- if (fr_event_fd_insert(ev, ev->ev_b->el, ev->fd,
+ if (fr_event_fd_insert(ev, NULL, ev->ev_b->el, ev->fd,
NULL,
_unbound_io_service_writable,
_unbound_io_service_errored,