Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 14734 invoked from network); 28 Feb 2011 17:26:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Feb 2011 17:26:55 -0000 Received: (qmail 28694 invoked by uid 500); 28 Feb 2011 17:26:55 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 28233 invoked by uid 500); 28 Feb 2011 17:26:51 -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 28217 invoked by uid 99); 28 Feb 2011 17:26:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Feb 2011 17:26:50 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [94.23.41.186] (HELO mail.ardeek.com) (94.23.41.186) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Feb 2011 17:26:40 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.ardeek.com (Postfix) with ESMTP id 64D2C2B2CF for ; Mon, 28 Feb 2011 18:26:20 +0100 (CET) Received: from mail.ardeek.com ([127.0.0.1]) by localhost (sheldon.ardeek.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wO5JPM8cY8cO for ; Mon, 28 Feb 2011 18:26:19 +0100 (CET) Received: from [192.168.1.22] (unknown [151.60.248.47]) by mail.ardeek.com (Postfix) with ESMTPA id 7FD112B297 for ; Mon, 28 Feb 2011 18:26:19 +0100 (CET) Message-ID: <4D6BDAB9.9090907@simonecaruso.com> Date: Mon, 28 Feb 2011 18:26:17 +0100 From: Simone Caruso User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Help with apr mutex Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi all, I wrote a simple cache inside my module with apr_shm and apr_rmm, but I have problems with apr mutex... I have this peace of code: static apr_global_mutex_t *mtx = NULL; static void module_translate_name(request_rec *r) { if(apr_global_mutex_trylock(mtx) == APR_EBUSY) ap_log_rerror(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, r, "Memory Locked!! "); apr_global_mutex_lock(mtx); element = get_from_cache(); if(element == NULL){ element = insert_into_cache(); strcpy(element.name,"name\0"); } apr_global_mutex_unlock(mtx); } static void module_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { result = apr_global_mutex_create(&mtx, "cache_entries_lck", APR_LOCK_DEFAULT, p); } static void mod_vhost_ldap_child_init(apr_pool_t * p, server_rec * s) { apr_status_t ret; ret = apr_global_mutex_child_init(&mtx, "cache_entries_lck", p); } During my tests with 'ab -c 15 -n 3000' i NEVER get the "Memory Locked" error in logs, plus i get duplicated entries in cache but I don't know why! Does someone have an idea? (please consider i use apr_global_mutex_trylock() only for test) Regards. -- Simone Caruso