static void request_post_handler(REQUEST *request);
static void wait_a_bit(void *ctx);
static void event_poll_fd(void *ctx);
+static void event_socket_handler(fr_event_list_t *xel, UNUSED int fd, void *ctx);
static void NEVER_RETURNS _rad_panic(const char *file, unsigned int line,
const char *msg)
rad_listen_t *proxy_listener;
/*
- * Allocate a new proxy fd. This function adds it
- * into the list of listeners.
- *
- * FIXME!: Call event_fd_insert()! Otherwise this
- * FD will never be used in select()!
- *
- * We probably want to add RADIUS_SIGNAL_SELF_FD,
- * which tells us to walk over the listeners,
- * adding a new FD.
- *
- * Hmm... maybe do this for the detail file, too.
- * that will simplify some of the rest of the code.
+ * Allocate a new proxy fd. This function adds
+ * it to the tail of the list of listeners. With
+ * some care, this can be thread-safe.
*/
proxy_listener = proxy_new_listener();
if (!proxy_listener) {
found = -1;
proxy = proxy_listener->fd;
for (i = 0; i < 32; i++) {
- DEBUG2("PROXY %d %d", i, proxy_fds[(proxy + i) & 0x1f]);
-
/*
* Found a free entry. Save the socket,
* and remember where we saved it.
if (!fr_packet_list_socket_add(proxy_list, proxy_listener->fd)) {
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
DEBUG2("ERROR: Failed to create a new socket for proxying requests.");
- return 0; /* leak proxy_listener */
+ return 0;
}
DEBUG2("ERROR: Failed to create a new socket for proxying requests.");
return 0;
}
+
+ /*
+ * Signal the main thread to add the new FD to the list
+ * of listening FD's.
+ */
+ radius_signal_self(RADIUS_SIGNAL_SELF_NEW_FD);
}
rad_assert(request->proxy->sockfd >= 0);
fr_event_loop_exit(el, 0x80);
}
+
+ if ((flag & RADIUS_SIGNAL_SELF_NEW_FD) != 0) {
+ rad_listen_t *this;
+
+ for (this = mainconfig.listen;
+ this != NULL;
+ this = this->next) {
+ if (this->type != RAD_LISTEN_PROXY) continue;
+
+ if (!fr_event_fd_insert(el, 0, this->fd,
+ event_socket_handler, this)) {
+ radlog(L_ERR, "Failed remembering handle for proxy socket!");
+ _exit(1);
+ }
+ }
+ }
}
#ifdef __MINGW32__