Added accept as a system call needing resource increases
authorAlan D. Brunelle <alan.brunelle@hp.com>
Wed, 11 Feb 2009 16:42:09 +0000 (11:42 -0500)
committerAlan D. Brunelle <alan.brunelle@hp.com>
Wed, 11 Feb 2009 16:42:09 +0000 (11:42 -0500)
accept(2) opens a socket, and thus needs to handle EMFILE/ENFILE errors
like other system calls.

blktrace.c

index 7d78e13bf4a3340f4f81bc6e220bd70363ef5725..8e2d47bede291280178280f4c25240f591472413 100644 (file)
@@ -599,6 +599,17 @@ static int my_socket(int domain, int type, int protocol)
        return fd;
 }
 
+static int my_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
+{
+       int fd;
+
+       do {
+               fd = accept(sockfd, addr, addrlen);
+       } while (fd < 0 && handle_open_failure());
+
+       return fd;
+}
+
 static void *my_mmap(void *addr, size_t length, int prot, int flags, int fd,
                     off_t offset)
 {
@@ -2133,7 +2144,7 @@ static void net_add_connection(struct net_server_s *ns)
        struct cl_host *ch;
        socklen_t socklen = sizeof(ns->addr);
 
-       fd = accept(ns->listen_fd, (struct sockaddr *)&ns->addr, &socklen);
+       fd = my_accept(ns->listen_fd, (struct sockaddr *)&ns->addr, &socklen);
        if (fd < 0) {
                /*
                 * This is OK: we just won't accept this connection,