Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB3829B95 for ; Mon, 5 Mar 2012 10:33:55 +0000 (UTC) Received: (qmail 10158 invoked by uid 500); 5 Mar 2012 10:33:55 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 10129 invoked by uid 500); 5 Mar 2012 10:33:55 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 10118 invoked by uid 99); 5 Mar 2012 10:33:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 10:33:55 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [160.78.48.72] (HELO paulista.cce.unipr.it) (160.78.48.72) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 10:33:48 +0000 Received: from paulista.cce.unipr.it (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id F2B411EA0339 for ; Mon, 5 Mar 2012 11:33:27 +0100 (CET) Received: from [160.78.37.3] (pachelbel.biol.unipr.it [160.78.37.3]) by paulista.cce.unipr.it (Postfix) with ESMTP id BC80B1EA0329 for ; Mon, 5 Mar 2012 11:33:27 +0100 (CET) Message-ID: <4F54966C.4020005@unipr.it> Date: Mon, 05 Mar 2012 11:33:16 +0100 From: Massimo Manghi User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: thread ID References: <993_1330619359_4F4FA3DF_993_1203_1_4F4FA3DE.2040900@orange.com> <4F500785.50707@gmail.com> <4F525D23.3020803@kippdata.de> In-Reply-To: <4F525D23.3020803@kippdata.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 03/03/2012 07:04 PM, Rainer Jung wrote: > On 02.03.2012 00:34, Sorin Manolache wrote: >> On 03/02/12 00:21, Ben Noordhuis wrote: >>> On Thu, Mar 1, 2012 at 17:29, wrote: >>>> Hello, >>>> >>>> I would need a memory buffer associated per worker thread (in the >>>> worker >>>> MPM) or to each process (in the prefork MPM). >>>> >>>> In order to do that, I would need a map thread<->buffer. So, I would >>>> need a sort of thread ID/key/handle that stays the same during the >>>> lifetime of the thread and no two threads in the same process can have >>>> the same ID/key/handle. >>>> >>>> What is the most portable way to get this thread ID? >>>> >>>> I thought of r->connection->id. It works but it is not very >>>> portable as >>>> it is not guaranteed that two connections created by the same thread >>>> will have the same id. They do for now. >>>> >>>> If r->connection->sbh was not opaque it would be great, because >>>> sbh->thread_num would be exactly what I need. >>>> >>>> I could also use pthread_self. It works too but, in general, it is not >>>> guaranteed that the worker threads are pthreads. >>>> >>>> >>>> Thank you for your help. >>>> >>>> Sorin >>> >>> What about apr_os_thread_current()? It returns a opaque value that's a >>> pthread_t on Unices and a pseudo-HANDLE on Windows. Read this[1] to >>> understand what that means. >>> >>> As a recovering standards lawyer I should probably point out that >>> pthread_t is an opaque type that's not guaranteed to be convertible to >>> a numeric value (or to anything, really). That said, I've never seen a >>> pthreads implementation where that wasn't the case. >>> >>> [1] >>> http://msdn.microsoft.com/en-us/library/windows/desktop/ms683182%28v=vs.85%29.aspx >>> >>> >> >> Thank you, it's what I need. > > You might also want to check the function log_tid() in server/log.c of > httpd's trunk or 2.4. The thread id gets logged in the error log by > default since 2.4, so that code converts it to a number. > > Regards, > > Rainer true, the ID is logged now, but is the function handling the thread id public? -- Massimo