From: Alan D. Brunelle Date: Wed, 11 Feb 2009 16:42:09 +0000 (-0500) Subject: Added accept as a system call needing resource increases X-Git-Tag: blktrace-1.0.1~30 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=d5302b03b2728a27f14c4f260ce6a5247ea87c6e;p=blktrace.git Added accept as a system call needing resource increases accept(2) opens a socket, and thus needs to handle EMFILE/ENFILE errors like other system calls. --- diff --git a/blktrace.c b/blktrace.c index 7d78e13..8e2d47b 100644 --- a/blktrace.c +++ b/blktrace.c @@ -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,