From: Willy Tarreau Date: Thu, 11 Nov 2010 08:48:16 +0000 (+0100) Subject: [CLEANUP] accept: replace some inappropriate Alert() calls with send_log() X-Git-Tag: v1.5-dev8~378 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fffe1325dfbab43b6c250c253d0362aa9c5de9c3;p=thirdparty%2Fhaproxy.git [CLEANUP] accept: replace some inappropriate Alert() calls with send_log() Some Alert() messages were remaining in the accept() path, which they would have no chance to be detected. Remove some of them (the impossible ones) and replace the relevant ones with send_log() so that the admin has a chance to catch them. --- diff --git a/src/frontend.c b/src/frontend.c index f51a3d9edb..cbf6174484 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -87,10 +87,9 @@ int frontend_accept(struct session *s) s->srv_error = default_srv_error; /* Adjust some socket options */ - if ((s->listener->addr.ss_family != AF_UNIX) && unlikely(setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)) == -1)) { - Alert("accept(): cannot set the socket in non blocking mode. Giving up\n"); + if ((s->listener->addr.ss_family != AF_UNIX) && + setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)) == -1) goto out_delete_cfd; - } if (s->fe->options & PR_O_TCP_CLI_KA) setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one)); diff --git a/src/session.c b/src/session.c index 5432266cd7..d718695d43 100644 --- a/src/session.c +++ b/src/session.c @@ -57,10 +57,8 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) struct http_txn *txn; struct task *t; - if (unlikely((s = pool_alloc2(pool2_session)) == NULL)) { - Alert("out of memory in event_accept().\n"); + if (unlikely((s = pool_alloc2(pool2_session)) == NULL)) goto out_close; - } /* minimum session initialization required for monitor mode below */ s->flags = 0; @@ -89,10 +87,8 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) LIST_ADDQ(&sessions, &s->list); LIST_INIT(&s->back_refs); - if (unlikely((t = task_new()) == NULL)) { /* disable this proxy for a while */ - Alert("out of memory in event_accept().\n"); + if (unlikely((t = task_new()) == NULL)) goto out_free_session; - } s->term_trace = 0; s->cli_addr = *addr; @@ -211,10 +207,8 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) s->store_count = 0; /* Adjust some socket options */ - if (unlikely(fcntl(cfd, F_SETFL, O_NONBLOCK) == -1)) { - Alert("accept(): cannot set the socket in non blocking mode. Giving up\n"); + if (unlikely(fcntl(cfd, F_SETFL, O_NONBLOCK) == -1)) goto out_free_task; - } txn = &s->txn; /* Those variables will be checked and freed if non-NULL in diff --git a/src/stream_sock.c b/src/stream_sock.c index 3624702167..46dfeba9ba 100644 --- a/src/stream_sock.c +++ b/src/stream_sock.c @@ -1188,7 +1188,9 @@ int stream_sock_accept(int fd) } if (unlikely(cfd >= global.maxsock)) { - Alert("accept(): not enough free sockets. Raise -n argument. Giving up.\n"); + send_log(p, LOG_EMERG, + "Proxy %s reached the configured maximum connection limit. Please check the global 'maxconn' value.\n", + p->id); goto out_close; }