From commits-return-8351-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Fri Jun 08 05:52:43 2007 Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 41528 invoked from network); 8 Jun 2007 05:52:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jun 2007 05:52:42 -0000 Received: (qmail 58260 invoked by uid 500); 8 Jun 2007 05:52:46 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 58224 invoked by uid 500); 8 Jun 2007 05:52:46 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 58207 invoked by uid 99); 8 Jun 2007 05:52:46 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2007 22:52:46 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2007 22:52:42 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 2C51A1A981A; Thu, 7 Jun 2007 22:52:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r545428 - in /apr/apr-util/trunk: include/apr_memcache.h memcache/apr_memcache.c Date: Fri, 08 Jun 2007 05:52:22 -0000 To: commits@apr.apache.org From: pquerna@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070608055222.2C51A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pquerna Date: Thu Jun 7 22:52:21 2007 New Revision: 545428 URL: http://svn.apache.org/viewvc?view=rev&rev=545428 Log: Allow apr_memcache to use a pure CRC32 hash fucntion for server selection. We maintain the _default version, since it is identical to what the Perl memcache Client uses. Fixes PR: 39604 Modified: apr/apr-util/trunk/include/apr_memcache.h apr/apr-util/trunk/memcache/apr_memcache.c Modified: apr/apr-util/trunk/include/apr_memcache.h URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apr_memcache.h?view=diff&rev=545428&r1=545427&r2=545428 ============================================================================== --- apr/apr-util/trunk/include/apr_memcache.h (original) +++ apr/apr-util/trunk/include/apr_memcache.h Thu Jun 7 22:52:21 2007 @@ -116,6 +116,16 @@ const char *data, apr_size_t data_len); +/** + * Pure CRC32 Hash. Used by some clients. + */ +APR_DECLARE(apr_uint32_t) apr_memcache_hash_crc32(void *baton, + const char *data, + apr_size_t data_len); + +/** + * hash compatible with the standard Perl Client. + */ APR_DECLARE(apr_uint32_t) apr_memcache_hash_default(void *baton, const char *data, apr_size_t data_len); Modified: apr/apr-util/trunk/memcache/apr_memcache.c URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/memcache/apr_memcache.c?view=diff&rev=545428&r1=545427&r2=545428 ============================================================================== --- apr/apr-util/trunk/memcache/apr_memcache.c (original) +++ apr/apr-util/trunk/memcache/apr_memcache.c Thu Jun 7 22:52:21 2007 @@ -488,7 +488,7 @@ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; -APR_DECLARE(apr_uint32_t) apr_memcache_hash_default(void *baton, +APR_DECLARE(apr_uint32_t) apr_memcache_hash_crc32(void *baton, const char *data, const apr_size_t data_len) { @@ -499,7 +499,17 @@ for (i = 0; i < data_len; i++) crc = (crc >> 8) ^ crc32tab[(crc ^ (data[i])) & 0xff]; - return ((~crc >> 16) & 0x7fff); + return ~crc; +} + +APR_DECLARE(apr_uint32_t) apr_memcache_hash_default(void *baton, + const char *data, + const apr_size_t data_len) +{ + /* The default Perl Client doesn't actually use just crc32 -- it shifts it again + * like this.... + */ + return ((apr_memcache_hash_crc32(baton, data, data_len) >> 16) & 0x7fff); } APR_DECLARE(apr_uint32_t) apr_memcache_hash(apr_memcache_t *mc,