Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24239 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41968 invoked by uid 1010); 1 Jul 2006 16:49:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 41953 invoked from network); 1 Jul 2006 16:49:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jul 2006 16:49:33 -0000 X-PHP-List-Original-Sender: pollita@php.net X-Host-Fingerprint: 65.111.164.201 danica.alphaweb.net Linux 2.4/2.6 Received: from ([65.111.164.201:46156] helo=danica.alphaweb.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id EA/C7-15023-B97A6A44 for ; Sat, 01 Jul 2006 12:49:32 -0400 Received: from talos.alphaweb.net ([69.12.155.129] helo=OHRLVN4523SG) by danica.alphaweb.net with esmtpsa (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.50) id 1FwieN-0001Av-IL; Sat, 01 Jul 2006 12:48:55 -0400 Message-ID: <001501c69d2e$4f1a2dd0$07000100@OHRLVN4523SG> To: "Andrew Mather" Cc: References: <200606302354.02272.an.dromeda@btconnect.com> <001301c69cac$39025540$07000100@OHRLVN4523SG> <007701c69cfb$02655ec0$ca5f8a51@VaioCen> Date: Sat, 1 Jul 2006 09:49:13 -0700 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Subject: Re: TSRMLS_D/C persistence From: pollita@php.net ("Sara Golemon") > That also implies then that if I create a handler for eg: an > external stream/file, and keep it as a singleton instance in the > extension, then it could be reasonably called by any number > of different threads. > There's a plan B though. void foo(int bar) { } foo() doesn't have room for trms_ls in its prototype so it just won't be available inside the function right? Wrong. Zend exports TSRMLS_FETCH(); which can recover (through a slightly expensive process) the thread appropriate value for tsrm_ls. Thus: void foo(int bar TSRMLS_DC) { somefoo(bar TSRMLS_CC); } and void foo(int bar) { TSRMLS_FETCH(); somefoo(bar TSRMLS_CC); } Are functionally identical. > ie: any resource callable from a php-extension must be > thread safe... > In order to work in all build environments? Yes. > Would that be a fair comment? (Means my single-threaded > data engine prototype is going to need a serious going over). > Technically, if you *know* that your php-extension will only ever be used in a non-threaded environment (e.g. non-Win32, non-Apache2, non-otherThreadedWebSAPI), then you can be "lazy" and not worry about thread safety (or tsrm_ls in general). I would however *strongly recommend* reworking your library for thread safety so that this problem doesn't become an issue later on. -Sara