From owner-freebsd-bugs Wed Feb 13 6:20:11 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B64CB37B400 for ; Wed, 13 Feb 2002 06:20:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g1DEK3988616; Wed, 13 Feb 2002 06:20:03 -0800 (PST) (envelope-from gnats) Date: Wed, 13 Feb 2002 06:20:03 -0800 (PST) Message-Id: <200202131420.g1DEK3988616@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Maxim Konovalov Subject: Re: i386/34536: accept() blocks other threads Reply-To: Maxim Konovalov Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR i386/34536; it has been noted by GNATS. From: Maxim Konovalov To: David Malone Cc: roam@freebsd.org, , Subject: Re: i386/34536: accept() blocks other threads Date: Wed, 13 Feb 2002 17:11:07 +0300 (MSK) Hello, I have finally realized where the problem is. It comes from libc_r/uthread/uthread_exit.c: /* * Enter a loop to set all file descriptors to blocking * if they were not created as non-blocking: */ for (i = 0; i < _thread_dtablesize; i++) { /* Check if this file descriptor is in use: */ if (_thread_fd_table[i] != NULL && !(_thread_fd_table[i]->flags & O_NONBLOCK)) { /* Get the current flags: */ flags = _thread_sys_fcntl(i, F_GETFL, NULL); /* Clear the nonblocking file descriptor flag: */ _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); } } The parent calls exit(2) and changes flags of all open descriptors to ~O_NONBLOCK so the child gets a blocking socket and just blocks on accept(2). I made a patch but I am not sure at all is it correct or not. Btw, who is our libc_r guru I can ask for review? At the moment I have no clue why we should restore files flags at exit(2). Index: libc_r/uthread/uthread_exit.c =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_exit.c,v retrieving revision 1.24 diff -u -r1.24 uthread_exit.c --- libc_r/uthread/uthread_exit.c 2001/11/17 14:28:39 1.24 +++ libc_r/uthread/uthread_exit.c 2002/02/13 13:56:16 @@ -66,6 +66,7 @@ * Enter a loop to set all file descriptors to blocking * if they were not created as non-blocking: */ +#ifdef 0 for (i = 0; i < _thread_dtablesize; i++) { /* Check if this file descriptor is in use: */ if (_thread_fd_table[i] != NULL && @@ -76,6 +77,7 @@ __sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); } } +#endif /* Call the _exit syscall: */ __sys_exit(status); -- Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer phone: +7 (095) 796-9079, mailto:maxim@macomnet.ru To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message