Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 1328 invoked from network); 8 Oct 2010 15:45:40 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Oct 2010 15:45:40 -0000 Received: (qmail 90467 invoked by uid 500); 8 Oct 2010 15:45:40 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 90422 invoked by uid 500); 8 Oct 2010 15:45:40 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 90415 invoked by uid 99); 8 Oct 2010 15:45:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Oct 2010 15:45:39 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.161.50] (HELO mail-fx0-f50.google.com) (209.85.161.50) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Oct 2010 15:45:30 +0000 Received: by fxm1 with SMTP id 1so945338fxm.37 for ; Fri, 08 Oct 2010 08:45:09 -0700 (PDT) Received: by 10.223.113.71 with SMTP id z7mr3338807fap.3.1286552708690; Fri, 08 Oct 2010 08:45:08 -0700 (PDT) Received: from zulu.23.e-reka.si (cpe-90-157-200-53.dynamic.amis.net [90.157.200.53]) by mx.google.com with ESMTPS id a6sm1699864faa.20.2010.10.08.08.45.04 (version=SSLv3 cipher=RC4-MD5); Fri, 08 Oct 2010 08:45:05 -0700 (PDT) Message-ID: <4CAF3C7F.5060407@xbc.nu> Date: Fri, 08 Oct 2010 17:45:03 +0200 From: =?UTF-8?B?QnJhbmtvIMSMaWJlag==?= User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: dev@apr.apache.org Subject: Re: apr_file_*() threading issues under Windows! References: <4CAF0FEE.7010503@myarm.com> In-Reply-To: <4CAF0FEE.7010503@myarm.com> X-Enigmail-Version: 1.1.1 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAADBQTFRF IhsbCy0qZjoVOVRoeFxSAIKBzXQiAKaibYiewnk7nn9z0qCTgL3i87Ep6Kx/+tHBsrE+zgAAAjZJ REFUOMvF0jFoE1EYB/CzjWlqIzaTjqVIBifRRWyG0t5iUqlLyFpCeXBgKg5yq6A4degUDJjoUDpc 1Qt4Ux94B11SOLB0KGS4discpbkORTCn9/m9d3fvLhXnvuHu3f+Xx/veyyfZfLSdZHzgicSfeyw4 JISwdz8FT6M8lM8Ceg385Dlhs+cC9sQCDn0B78QCogzwN+sxfHGOIXBbRGkNAM4cZymGtgNsDPgz cByxon3EEm1TLmvAlghoHOO3CZSa+IQ/vF6JV8tgKOMow78gRgL2/+EIvATOUtB3SSdMg4GXgrbn uk0uLiGdoCHKbX4E+t1FUTqn1AtIdPJebssDQ64YANSQyyaQNyUOFs0ijMsMFnOPTahPLXKYowtY 08MfCP7vR7hRnc5zmPK7CDYYbHcbC7tHuyFA94U/1LYZaJpu/sxACHMwvwZljTLY0TbNk4x+zuEt yC3MfCM6uSIvfwur0itFL4FA2Yal8BzLfnYV4EIGwEPAk7o5zIcnvzHMEjwJrrhAKK7on6IrsfRJ 7A53BhaK+CL7fj6+q/sPeOvcDTtoZTxpUYsFeIknrOXep3p3l7Ua+8sZ5FPQKyKwWi+DfROTU7ny C1/9UhpeY7K287WJCzbsNPQm2S6Yk4PSCNhWM2r3nD0K9liYb6yPgCRJhSzPrxUK0yUBVk1VX0lj s7MzGZyp0wImMK/e8rHbz2soL+O+2r1dxfGsAmBcx0lNjS/RUhlUC7gRn1wGMdQ7Vw1/AReW/RN3 xFWdAAAAAElFTkSuQmCC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Are you trying to use the same apr_file_t handle simultaneously in different threads? AFAIK it was never meant to work that way. On 08.10.2010 14:34, Stefan Ruppert wrote: > Hi all, > > after digging into the apr_file_*() source code for Windows I have > found several issues regading file io and threading under Windows. > > In general is there a document which explains which functions are > thread-safe and which not? > > * Allocation of pOverlapped structure is not thread-safe (readwrite.c): > > The allocation of the pOverlapped structure is not guarded by a mutex, > thus this can lead into undefined behavior (memory leak, resource leak > (CreateEvent)) if two threads enters apr_file_read()/apr_file_write() > at the same time! > > Why not allocating this structure within apr_file_open() if XTHREAD > was specified? > > * Usage of the mutex is not consistent. > > Sometimes it is used with if(thefile->flags & APR_FOPEN_XTHREAD) and > sometimes without such an condition! > > * apr_file_flush() for flushing the buffer does not use the mutex at all! > > * apr_file_buffer_set() is broken (buffer.c). > > The mutex is unconditionally used within apr_file_buffer_set(). But a > mutex is only created within apr_file_open() if APR_FOPEN_APPEND or > APR_FOPEN_BUFFERED is specified. > > Also the docs of apr_file_buffer_set() documents that someone can > later add APR_FOPEN_BUFFERED support by calling it. But a mutex is > not created if it was not created by apr_file_open()! > > * The preprocessor APR_HAS_THREADS inconsistently used. > > Within filedup.c APR_HAS_THREADS is used to compile out some calls > to the apr_thread_*() functions and sometimes it is not used. > > Any comments? > > Regards, > Stefan