Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 1746 invoked from network); 7 Feb 2011 17:15:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Feb 2011 17:15:25 -0000 Received: (qmail 89232 invoked by uid 500); 7 Feb 2011 17:15:25 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 89030 invoked by uid 500); 7 Feb 2011 17:15:23 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 89013 invoked by uid 99); 7 Feb 2011 17:15:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Feb 2011 17:15:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Feb 2011 17:15:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7856C23889E1; Mon, 7 Feb 2011 17:14:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1068018 - in /httpd/httpd/trunk: include/ap_slotmem.h modules/slotmem/mod_slotmem_plain.c modules/slotmem/mod_slotmem_shm.c Date: Mon, 07 Feb 2011 17:14:59 -0000 To: cvs@httpd.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110207171459.7856C23889E1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jim Date: Mon Feb 7 17:14:59 2011 New Revision: 1068018 URL: http://svn.apache.org/viewvc?rev=1068018&view=rev Log: Slotmem now provides for the number of "free" slots available. Modified: httpd/httpd/trunk/include/ap_slotmem.h httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c Modified: httpd/httpd/trunk/include/ap_slotmem.h URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_slotmem.h?rev=1068018&r1=1068017&r2=1068018&view=diff ============================================================================== --- httpd/httpd/trunk/include/ap_slotmem.h (original) +++ httpd/httpd/trunk/include/ap_slotmem.h Mon Feb 7 17:14:59 2011 @@ -146,6 +146,14 @@ struct ap_slotmem_provider_t { */ unsigned int (* num_slots)(ap_slotmem_instance_t *s); /** + * return number of free (not used) slots allocated for this entry. + * Valid for slots which are AP_SLOTMEM_TYPE_PREGRAB as well as + * any which use get/release. + * @param s ap_slotmem_instance_t to use. + * @return number of slots + */ + unsigned int (* num_free_slots)(ap_slotmem_instance_t *s); + /** * return slot size allocated for this entry. * @param s ap_slotmem_instance_t to use. * @return size of slot Modified: httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c?rev=1068018&r1=1068017&r2=1068018&view=diff ============================================================================== --- httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c (original) +++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_plain.c Mon Feb 7 17:14:59 2011 @@ -181,6 +181,7 @@ static apr_status_t slotmem_get(ap_slotm if (ret != APR_SUCCESS) { return ret; } + *inuse=1; memcpy(dest, ptr, dest_len); /* bounds check? */ return APR_SUCCESS; } @@ -203,6 +204,7 @@ static apr_status_t slotmem_put(ap_slotm if (ret != APR_SUCCESS) { return ret; } + *inuse=1; memcpy(ptr, src, src_len); /* bounds check? */ return APR_SUCCESS; } @@ -212,6 +214,17 @@ static unsigned int slotmem_num_slots(ap return slot->num; } +static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) +{ + unsigned int i, counter=0; + char *inuse = slot->inuse; + for (i=0; isize; @@ -271,6 +284,7 @@ static const ap_slotmem_provider_t stora &slotmem_get, &slotmem_put, &slotmem_num_slots, + &slotmem_num_free_slots &slotmem_slot_size, &slotmem_grab, &slotmem_release Modified: httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c?rev=1068018&r1=1068017&r2=1068018&view=diff ============================================================================== --- httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c (original) +++ httpd/httpd/trunk/modules/slotmem/mod_slotmem_shm.c Mon Feb 7 17:14:59 2011 @@ -48,6 +48,7 @@ typedef struct { apr_size_t size; /* size of each memory slot */ unsigned int num; /* number of mem slots */ + unsigned int free; /* number of free mem slots */ ap_slotmem_type_t type; /* type-specific flags */ } sharedslotdesc_t; @@ -173,7 +174,7 @@ static void restore_slotmem(void *ptr, c apr_status_t rv; storename = store_filename(pool, name); - + if (storename) { rv = apr_file_open(&fp, storename, APR_READ | APR_WRITE, APR_OS_DEFAULT, pool); @@ -332,7 +333,7 @@ static apr_status_t slotmem_create(ap_sl } ptr = (char *)apr_shm_baseaddr_get(shm); desc.size = item_size; - desc.num = item_num; + desc.free = desc.num = item_num; desc.type = type; memcpy(ptr, &desc, sizeof(desc)); ptr = ptr + AP_SLOTMEM_OFFSET; @@ -341,8 +342,15 @@ static apr_status_t slotmem_create(ap_sl * TODO: Error check the below... What error makes * sense if the restore fails? Any? */ - if (type & AP_SLOTMEM_TYPE_PERSIST) + if (type & AP_SLOTMEM_TYPE_PERSIST) { + unsigned int i, counter=0; + char *inuse = ptr + basesize; restore_slotmem(ptr, fname, dsize, pool); + for (i=0; idesc.num; } +static unsigned int slotmem_num_free_slots(ap_slotmem_instance_t *slot) +{ + if (AP_SLOTMEM_IS_PREGRAB(slot)) + return slot->desc.free; + else { + unsigned int i, counter=0; + char *inuse = slot->inuse; + for (i=0; idesc.num; i++, inuse++) { + if (!*inuse) + counter++; + } + return counter; + } +} + static apr_size_t slotmem_slot_size(ap_slotmem_instance_t *slot) { return slot->desc.size; } -/* - * XXXX: if !AP_SLOTMEM_IS_PREGRAB, then still worry about - * inuse for grab and return? - */ static apr_status_t slotmem_grab(ap_slotmem_instance_t *slot, unsigned int *id) { unsigned int i; @@ -546,6 +567,7 @@ static apr_status_t slotmem_grab(ap_slot } *inuse = 1; *id = i; + slot->desc.free--; return APR_SUCCESS; } @@ -564,6 +586,7 @@ static apr_status_t slotmem_release(ap_s return APR_NOTFOUND; } inuse[id] = 0; + slot->desc.free++; return APR_SUCCESS; } @@ -576,6 +599,7 @@ static const ap_slotmem_provider_t stora &slotmem_get, &slotmem_put, &slotmem_num_slots, + &slotmem_num_free_slots, &slotmem_slot_size, &slotmem_grab, &slotmem_release