Skip to content

Commit

Permalink
Add the proxy listener to the packet list immediately
Browse files Browse the repository at this point in the history
so that we can allocate IDs immediately
  • Loading branch information
alandekok committed May 28, 2014
1 parent c673f2d commit e7167cc
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/main/process.c
Expand Up @@ -1980,6 +1980,7 @@ static int insert_into_proxy_hash(REQUEST *request)

for (tries = 0; tries < 2; tries++) {
rad_listen_t *this;
listen_socket_t *sock;

RDEBUG3("proxy: Trying to allocate ID (%d/2)", tries);
rcode = fr_packet_list_id_alloc(proxy_list,
Expand All @@ -2005,6 +2006,28 @@ static int insert_into_proxy_hash(REQUEST *request)
request->proxy->src_port = 0; /* Use any new socket */
proxy_listener = this;

sock = this->data;
if (!fr_packet_list_socket_add(proxy_list, this->fd,
sock->proto,
&sock->other_ipaddr, sock->other_port,
this)) {

#ifdef HAVE_PTHREAD_H
proxy_no_new_sockets = true;
#endif
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);

/*
* This is bad. However, the
* packet list now supports 256
* open sockets, which should
* minimize this problem.
*/
ERROR("Failed adding proxy socket: %s",
fr_strerror());
goto fail;
}

/*
* Add it to the event loop. Ensure that we have
* only one mutex locked at a time.
Expand Down Expand Up @@ -4080,29 +4103,6 @@ static int event_new_fd(rad_listen_t *this)
* added to the packet list.
*/
case RAD_LISTEN_PROXY:
PTHREAD_MUTEX_LOCK(&proxy_mutex);
if (!fr_packet_list_socket_add(proxy_list, this->fd,
sock->proto,
&sock->other_ipaddr, sock->other_port,
this)) {

#ifdef HAVE_PTHREAD_H
proxy_no_new_sockets = true;
#endif
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);

/*
* This is bad. However, the
* packet list now supports 256
* open sockets, which should
* minimize this problem.
*/
ERROR("Failed adding proxy socket: %s",
fr_strerror());
return 0;
}
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);

#ifdef WITH_TCP
/*
* Add timers to outgoing child sockets, if necessary.
Expand Down

0 comments on commit e7167cc

Please sign in to comment.