From owner-freebsd-threads@FreeBSD.ORG Mon May 24 13:20:01 2010 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 789CA1065679 for ; Mon, 24 May 2010 13:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (unknown [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3AE3B8FC25 for ; Mon, 24 May 2010 13:20:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o4ODK1mK020935 for ; Mon, 24 May 2010 13:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o4ODK1xI020934; Mon, 24 May 2010 13:20:01 GMT (envelope-from gnats) Resent-Date: Mon, 24 May 2010 13:20:01 GMT Resent-Message-Id: <201005241320.o4ODK1xI020934@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, HaiYu Wu Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FCD61065670 for ; Mon, 24 May 2010 13:13:06 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 5F0C48FC0A for ; Mon, 24 May 2010 13:13:06 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o4ODD50H050616 for ; Mon, 24 May 2010 13:13:05 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o4ODD5gD050615; Mon, 24 May 2010 13:13:05 GMT (envelope-from nobody) Message-Id: <201005241313.o4ODD5gD050615@www.freebsd.org> Date: Mon, 24 May 2010 13:13:05 GMT From: HaiYu Wu To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: threads/146917: open(), accept() are not thread safe X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 May 2010 13:20:01 -0000 >Number: 146917 >Category: threads >Synopsis: open(), accept() are not thread safe >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 24 13:20:00 UTC 2010 >Closed-Date: >Last-Modified: >Originator: HaiYu Wu >Release: FreeBSD 7.3-RELEASE >Organization: Netease Inc. >Environment: FreeBSD onlinegame-10-183 7.3-RELEASE FreeBSD 7.3-RELEASE #0: Sun Mar 21 06:15:01 UTC 2010 root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: My Application is in Freebsd 7.3, has two threads. use -pthread options to gcc(gcc 4.2.1). the Threads's breif flow as bellow: Thread A: is the main thread which deal with the connections, accept connection, read connection and make a request to push into a queue. Thread B: is the work thread which wait for request from the queue, and deal with it. when dealing with the request, sometimes will open a file to write some data. I use system call open() to open file and write(), mostly, both of threads work well. but sometimes write() is failed and the errno is 9. If I migrate the open() operation to the main thread A, never open() in the Thread B, the failure is disappear. So, I doubt that some system call , such as accep(), open(), fopen() which operate the File Descriptor are not thread safe. Is this True ? >How-To-Repeat: above mentioned >Fix: >Release-Note: >Audit-Trail: >Unformatted: