Fix corner case when not threaded.
[freeradius.git] / src / main / event.c
index f2323b5..65fcb6b 100644 (file)
@@ -500,7 +500,8 @@ static void wait_for_child_to_die(void *ctx)
                               request->component, request->module);
                } else {
                        request->delay = USEC * request->root->max_request_time;
-                       RDEBUG2("WARNING: Child is still stuck");
+                       RDEBUG2("WARNING: Child is hung after \"max_request_time\" for request %u",
+                               request->number);
                }
                tv_add(&request->when, request->delay);
 
@@ -1231,16 +1232,16 @@ static void wait_a_bit(void *ctx)
        case REQUEST_RUNNING:
                /*
                 *      If we're not thread-capable, OR we're capable,
-                *      but have been told to run without threads,
-                *      complain when the requests is queued for a
-                *      thread, or running in a child thread.
+                *      but have been told to run without threads, and
+                *      the request is still running.  This is usually
+                *      because the request was proxied, and the home
+                *      server didn't respond.
                 */
 #ifdef HAVE_PTHREAD_H
                if (!have_children)
 #endif
                {
-                       rad_assert("We do not have threads, but the request is marked as queued or running in a child thread" == NULL);
-                       break;
+                       goto done;
                }
 
 #ifdef HAVE_PTHREAD_H
@@ -1293,9 +1294,11 @@ static void wait_a_bit(void *ctx)
                 */
                if (have_children &&
                    (pthread_equal(request->child_pid, NO_SUCH_CHILD_PID) == 0)) {
-                       radlog(L_ERR, "WARNING: Unresponsive child in module %s component %s",
-                              request->module ? request->module : "<server core>",
-                              request->component ? request->component : "<server core>");
+                       radlog(L_ERR, "WARNING: Unresponsive child for request %u, in component %s module %s",
+                              request->number,
+                              request->component ? request->component : "<server core>",
+                              request->module ? request->module : "<server core>");
+
                }
                        
                request->delay = USEC;
@@ -1309,6 +1312,7 @@ static void wait_a_bit(void *ctx)
                 *      and clean it up.
                 */
        case REQUEST_DONE:
+       done:
 #ifdef HAVE_PTHREAD_H
                request->child_pid = NO_SUCH_CHILD_PID;
 #endif
@@ -1942,8 +1946,8 @@ static int request_pre_handler(REQUEST *request)
 #ifdef WITH_PROXY
        if (request->proxy) {
                return process_proxy_reply(request);
-#endif
        }
+#endif
 
        return 1;
 }
@@ -2569,8 +2573,11 @@ static void request_post_handler(REQUEST *request)
         *      and it should re-send it.
         *      If configured, encode, sign, and send.
         */
-       if ((request->reply->code != 0) ||
-           (request->listener->type == RAD_LISTEN_DETAIL)) {
+       if ((request->reply->code != 0)
+#ifdef WITH_DETAIL
+           || (request->listener->type == RAD_LISTEN_DETAIL)
+#endif
+           ) {
                DEBUG_PACKET(request, request->reply, 1);
                request->listener->send(request->listener, request);
        }
@@ -2639,6 +2646,7 @@ static void request_post_handler(REQUEST *request)
 }
 
 
+#ifdef WITH_PROXY
 static void rad_retransmit_packet(REQUEST *request)
 {
        char buffer[256];
@@ -2728,7 +2736,7 @@ static int rad_retransmit(REQUEST *request)
 
        return 1;
 }
-
+#endif
 
 static void received_retransmit(REQUEST *request, const RADCLIENT *client)
 {
@@ -3011,7 +3019,10 @@ int received_request(rad_listen_t *listener,
        /*
         *      We may want to quench the new request.
         */
-       if ((listener->type != RAD_LISTEN_DETAIL) &&
+       if (
+#ifdef WITH_DETAIL
+           (listener->type != RAD_LISTEN_DETAIL) &&
+#endif
            !can_handle_new_request(packet, client, root)) {
                return 0;
        }
@@ -3558,7 +3569,7 @@ int event_new_fd(rad_listen_t *this)
                }               
 #ifdef WITH_PROXY
                else {
-                       int count = this->count;
+                       int count;
 
                        /*
                         *      Duplicate code
@@ -3640,7 +3651,10 @@ int event_new_fd(rad_listen_t *this)
         */
        if (this->status == RAD_LISTEN_STATUS_CLOSED) {
                int count = this->count;
+
+#ifdef WITH_DETAIL
                rad_assert(this->type != RAD_LISTEN_DETAIL);
+#endif
 
 #ifdef WITH_PROXY
                /*
@@ -3916,7 +3930,10 @@ static void event_socket_handler(fr_event_list_t *xel, UNUSED int fd,
 
        xel = xel;
 
-       if ((listener->type != RAD_LISTEN_DETAIL) &&
+       if (
+#ifdef WITH_DETAIL
+           (listener->type != RAD_LISTEN_DETAIL) &&
+#endif
            (listener->fd < 0)) {
                char buffer[256];
 
@@ -3936,7 +3953,7 @@ static void event_socket_handler(fr_event_list_t *xel, UNUSED int fd,
        thread_pool_addrequest(request, fun);
 }
 
-
+#ifdef WITH_DETAIL
 /*
  *     This function is called periodically to see if this detail
  *     file is available for reading.
@@ -3968,7 +3985,7 @@ static void event_poll_detail(void *ctx)
                exit(1);
        }
 }
-
+#endif
 
 static void event_status(struct timeval *wake)
 {