summaryrefslogtreecommitdiff
path: root/extra/memcached
diff options
context:
space:
mode:
authorParabola <dev@list.parabolagnulinux.org>2011-04-05 14:26:38 +0000
committerParabola <dev@list.parabolagnulinux.org>2011-04-05 14:26:38 +0000
commit415856bdd4f48ab4f2732996f0bae58595092bbe (patch)
treeede2018b591f6dfb477fe9341ba17b9bc000fab9 /extra/memcached
Tue Apr 5 14:26:38 UTC 2011
Diffstat (limited to 'extra/memcached')
-rw-r--r--extra/memcached/ChangeLog24
-rw-r--r--extra/memcached/PKGBUILD39
-rw-r--r--extra/memcached/fix-type-punning-issues.patch73
-rw-r--r--extra/memcached/memcached.conf4
-rw-r--r--extra/memcached/memcached.sh63
5 files changed, 203 insertions, 0 deletions
diff --git a/extra/memcached/ChangeLog b/extra/memcached/ChangeLog
new file mode 100644
index 000000000..ad9780fc4
--- /dev/null
+++ b/extra/memcached/ChangeLog
@@ -0,0 +1,24 @@
+2011-02-07 Ionut Biru <ibiru@archlinux.org>
+ * Rebuild 1.4.5 against libeven 2.0.10
+
+2011-01-31 Dan McGee <dan@archlinux.org>
+ * Rebuild 1.4.5 with gcc 4.5.X patch accepted upstream
+
+2009-11-14 Dan McGee <dan@archlinux.org>
+ * Bump to 1.4.3
+ * Added memcached-tool to package
+
+2009-09-13 Dan McGee <dan@archlinux.org>
+ * Bump to 1.4.1
+ * Add new required conf.d option MEMCACHED_USER
+ * Rework the way we store the PID for init script usage
+
+2009-04-12 Dan McGee <dan@archlinux.org>
+ * Bump to 1.2.8
+
+2009-04-05 Dan McGee <dan@archlinux.org>
+ * Bump to 1.2.7
+
+2008-12-13 Dan McGee <dan@archlinux.org>
+ * Added conf file to backup array
+ * Fixed the not quite right default config
diff --git a/extra/memcached/PKGBUILD b/extra/memcached/PKGBUILD
new file mode 100644
index 000000000..8402e28f1
--- /dev/null
+++ b/extra/memcached/PKGBUILD
@@ -0,0 +1,39 @@
+# $Id: PKGBUILD 109292 2011-02-07 17:22:01Z ibiru $
+# Maintainer: Dan McGee <dan@archlinux.org>
+# Contributor: Michael Irwin <6d6469@gmail.com>
+
+pkgname=memcached
+pkgver=1.4.5
+pkgrel=3
+pkgdesc="A distributed memory object caching system"
+arch=(i686 x86_64)
+url="http://memcached.org/"
+license=('GPL')
+depends=('libevent')
+optdepends=('perl: for memcached-tool usage')
+backup=('etc/conf.d/memcached')
+source=(http://memcached.googlecode.com/files/$pkgname-$pkgver.tar.gz
+ memcached.conf
+ memcached.sh
+ fix-type-punning-issues.patch)
+changelog=ChangeLog
+
+build() {
+ cd $srcdir/$pkgname-$pkgver
+ patch -Np1 < $srcdir/fix-type-punning-issues.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd $srcdir/$pkgname-$pkgver
+ make DESTDIR=$pkgdir install
+ install -D -m 755 scripts/memcached-tool $pkgdir/usr/bin/memcached-tool
+ install -D -m 644 $srcdir/$pkgname.conf $pkgdir/etc/conf.d/$pkgname
+ install -D -m 755 $srcdir/$pkgname.sh $pkgdir/etc/rc.d/$pkgname
+}
+
+md5sums=('583441a25f937360624024f2881e5ea8'
+ 'bf15619930dadf0c08669566e4aa809c'
+ '65f88b69cf3112b178725af121327765'
+ 'c4f6da682cb4e7599fede4904021f4ae')
diff --git a/extra/memcached/fix-type-punning-issues.patch b/extra/memcached/fix-type-punning-issues.patch
new file mode 100644
index 000000000..60bb94110
--- /dev/null
+++ b/extra/memcached/fix-type-punning-issues.patch
@@ -0,0 +1,73 @@
+commit df15887584f0025e7b188e408dd3c9f638d68518
+Author: Dan McGee <dan@archlinux.org>
+Date: Tue Nov 2 18:43:00 2010 -0500
+
+ Fix type-punning issues exposed with GCC 4.5.1
+
+ The errors below are due to pointer magic that isn't allowed if following C
+ strict-aliasing rules:
+
+ memcached.c: In function ‘complete_incr_bin’:
+ memcached.c:1023:16: error: dereferencing type-punned pointer will break
+ strict-aliasing rules
+ memcached.c:1044:13: error: dereferencing type-punned pointer will break
+ strict-aliasing rules
+ memcached.c:1061:17: error: dereferencing type-punned pointer will break
+ strict-aliasing rules
+
+ Fix this by introducing a union type that allows access to the uint64_t
+ member as necessary, but doesn't add any additional length to the structure.
+ The size remains the same before and after; the only difference is explict
+ casts are now refactored into union member accesses and all compilers should
+ be happy.
+
+ Signed-off-by: Dan McGee <dan@archlinux.org>
+
+diff --git a/memcached.h b/memcached.h
+index 4a7295b..74a6592 100644
+--- a/memcached.h
++++ b/memcached.h
+@@ -77,18 +77,22 @@
+ #define TAIL_REPAIR_TIME (3 * 3600)
+
+ /* warning: don't use these macros with a function, as it evals its arg twice */
+-#define ITEM_get_cas(i) ((uint64_t)(((i)->it_flags & ITEM_CAS) ? \
+- *(uint64_t*)&((i)->end[0]) : 0x0))
+-#define ITEM_set_cas(i,v) { if ((i)->it_flags & ITEM_CAS) { \
+- *(uint64_t*)&((i)->end[0]) = v; } }
++#define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \
++ (i)->data->cas : (uint64_t)0)
+
+-#define ITEM_key(item) (((char*)&((item)->end[0])) \
++#define ITEM_set_cas(i,v) { \
++ if ((i)->it_flags & ITEM_CAS) { \
++ (i)->data->cas = v; \
++ } \
++}
++
++#define ITEM_key(item) (((char*)&((item)->data)) \
+ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
+
+-#define ITEM_suffix(item) ((char*) &((item)->end[0]) + (item)->nkey + 1 \
++#define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
+
+-#define ITEM_data(item) ((char*) &((item)->end[0]) + (item)->nkey + 1 \
++#define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ + (item)->nsuffix \
+ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
+
+@@ -302,7 +306,12 @@ typedef struct _stritem {
+ uint8_t it_flags; /* ITEM_* above */
+ uint8_t slabs_clsid;/* which slab class we're in */
+ uint8_t nkey; /* key length, w/terminating null and padding */
+- void * end[];
++ /* this odd type prevents type-punning issues when we do
++ * the little shuffle to save space when not using CAS. */
++ union {
++ uint64_t cas;
++ char end;
++ } data[];
+ /* if it_flags & ITEM_CAS we have 8 bytes CAS */
+ /* then null-terminated key */
+ /* then " flags length\r\n" (no terminating null) */
diff --git a/extra/memcached/memcached.conf b/extra/memcached/memcached.conf
new file mode 100644
index 000000000..bf120b059
--- /dev/null
+++ b/extra/memcached/memcached.conf
@@ -0,0 +1,4 @@
+# user to run memcached as; also used for pid file ownership
+MEMCACHED_USER="nobody"
+# see 'memcached -h' for available options
+MEMCACHED_ARGS="-l 127.0.0.1 -t 1"
diff --git a/extra/memcached/memcached.sh b/extra/memcached/memcached.sh
new file mode 100644
index 000000000..9c9727507
--- /dev/null
+++ b/extra/memcached/memcached.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/memcached
+
+PIDFILE='/var/run/memcached.pid'
+
+getpid() {
+ local pid
+ pid=$(cat $PIDFILE 2>/dev/null)
+ # if the process is no longer valid, don't return it
+ if [ -n "$pid" ]; then
+ if ! ps -p $pid >/dev/null; then
+ rm -f $PIDFILE
+ pid=""
+ fi
+ fi
+ echo $pid
+}
+
+PID="$(getpid)"
+
+case "$1" in
+ start)
+ stat_busy "Starting memcached"
+ # memcached is retarded and doesn't write to the pidfile
+ # before it drops permissions
+ if [ -n "$PID" ]; then
+ stat_fail
+ elif [ -z "$MEMCACHED_USER" ]; then
+ echo "MEMCACHED_USER must be defined in /etc/conf.d/memcached"
+ stat_fail
+ else
+ touch $PIDFILE && chown $MEMCACHED_USER $PIDFILE
+ /usr/bin/memcached -d -P $PIDFILE -u $MEMCACHED_USER $MEMCACHED_ARGS
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon memcached
+ stat_done
+ fi
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping memcached"
+ [ ! -z "$PID" ] && kill $PID &> /dev/null
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm -f $PIDFILE
+ rm_daemon memcached
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac