]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] accept: replace some inappropriate Alert() calls with send_log()
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Nov 2010 08:48:16 +0000 (09:48 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Nov 2010 08:51:38 +0000 (09:51 +0100)
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.

src/frontend.c
src/session.c
src/stream_sock.c

index f51a3d9edb03e0112b9580fad43a382c14c11739..cbf617448467c310c03a904dadd8db30db01a9ef 100644 (file)
@@ -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));
index 5432266cd7bb86774ac25b4676097d3d900888fc..d718695d43f3af516fe2975252af4f4472103042 100644 (file)
@@ -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
index 362470216797d5b907e89781b8477abbe8c1e0ae..46dfeba9ba0ae607bb8042938d25100fe8182a6c 100644 (file)
@@ -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;
                }