From: Alan T. DeKok Date: Thu, 26 Mar 2009 22:07:17 +0000 (-0700) Subject: Allow fast clients to send packets, too X-Git-Tag: release_2_1_7~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d720f3de4f32405bd9b0b8e5191d7150819262f1;p=thirdparty%2Ffreeradius-server.git Allow fast clients to send packets, too This is for performance testing. For speed, the server doesn't have locks all over the place. However, this means that when it runs threaded, the client can receive the response, and send a new one using the same ID, before the child thread has a chance to update child_state. This work-around lets everyone be happy --- diff --git a/src/main/event.c b/src/main/event.c index 365b4ade67c..c455f063fbe 100644 --- a/src/main/event.c +++ b/src/main/event.c @@ -2685,6 +2685,26 @@ int received_request(rad_listen_t *listener, struct timeval when; default: + /* + * Special hacks for race conditions. + * The reply is encoded, and therefore + * likely sent. We received a *new* + * packet from the client, likely before + * the next line or two of code which + * updated the child state. In this + * case, just accept the new request. + */ + if ((request->reply->code != 0) && + request->reply->data) { + radlog(L_INFO, "WARNING: Allowing fast client %s port %d - ID: %d for recent request %d.", + client->shortname, + packet->src_port, packet->id, + request->number); + remove_from_request_hash(request); + request = NULL; + break; + } + gettimeofday(&when, NULL); when.tv_sec -= 1;