- update memcached to 1.4.0 ("many improvements have been made, upgrading is

recommended")

from Scott Vokes (MAINTAINER), thanks
This commit is contained in:
jasper 2009-08-07 10:46:41 +00:00
parent 3bd2392a6b
commit 4c60f3ab4b
10 changed files with 228 additions and 16 deletions

View File

@ -1,8 +1,8 @@
# $OpenBSD: Makefile,v 1.8 2009/05/01 02:00:02 sthen Exp $
# $OpenBSD: Makefile,v 1.9 2009/08/07 10:46:41 jasper Exp $
COMMENT= distributed memory object caching system
DISTNAME= memcached-1.2.8
DISTNAME= memcached-1.4.0
CATEGORIES= misc
HOMEPAGE= http://www.danga.com/memcached/
@ -14,15 +14,13 @@ PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
WANTLIB= c event
WANTLIB= c event pthread
MASTER_SITES= ${HOMEPAGE}/dist/
MASTER_SITES0= http://memcached.googlecode.com/files/
MASTER_SITES= http://memcached.googlecode.com/files/
MASTER_SITES0= ${HOMEPAGE}/dist/
CONFIGURE_STYLE= gnu
CONFIGURE_ARGS= --with-libevent=/usr
REGRESS_TARGET= test
CONFIGURE_ARGS= --with-libevent=/usr --disable-coverage
post-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/memcached

View File

@ -1,5 +1,5 @@
MD5 (memcached-1.2.8.tar.gz) = 5aTuBOUXpcrREPKeRJDkqw==
RMD160 (memcached-1.2.8.tar.gz) = iGaGX1e2kU/KmPPPWuCUL36UugA=
SHA1 (memcached-1.2.8.tar.gz) = b5lBTzfMWxpoZtmz7JJUwuvaI3o=
SHA256 (memcached-1.2.8.tar.gz) = njZwKDOpIT1geAGkQyXRCOa4arx6+C/iZczkuW6yJp4=
SIZE (memcached-1.2.8.tar.gz) = 221285
MD5 (memcached-1.4.0.tar.gz) = 12Uey4vzRRRMsXkA2aRshQ==
RMD160 (memcached-1.4.0.tar.gz) = C/KBxpS6JGcsQoXF9lE3svuz9IQ=
SHA1 (memcached-1.4.0.tar.gz) = hIgZd8w0oQOc5hkif/KRDY4ePls=
SHA256 (memcached-1.4.0.tar.gz) = smSPtRT7NvoizetGi46KjUn++Gos+8dzj2MOCbSXfTU=
SIZE (memcached-1.4.0.tar.gz) = 267420

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-configure,v 1.1 2009/08/07 10:46:41 jasper Exp $
use '-pthread' instead of '-lpthread'
--- configure.orig Thu Jul 9 21:13:05 2009
+++ configure Fri Aug 7 12:40:00 2009
@@ -5982,12 +5982,12 @@ return pthread_create ();
return 0;
}
_ACEOF
-for ac_lib in '' pthread; do
+for ac_lib in pthread; do
if test -z "$ac_lib"; then
ac_res="none required"
else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ ac_res=-$ac_lib
+ LIBS="-$ac_lib $ac_func_search_save_LIBS"
fi
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-items_c,v 1.3 2009/08/07 10:46:41 jasper Exp $
--- items.c.orig Thu Jul 9 12:43:42 2009
+++ items.c Sat Jul 11 10:54:34 2009
@@ -379,7 +379,7 @@ char *do_item_cachedump(const unsigned int slabs_clsid
(unsigned long)it->exptime + process_started);
if (bufcurr + len + 6 > memlimit) /* 6 is END\r\n\0 */
break;
- strcpy(buffer + bufcurr, temp);
+ strlcpy(buffer + bufcurr, temp, sizeof(buffer) - bufcurr);
bufcurr += len;
shown++;
it = it->next;
@@ -446,7 +446,7 @@ void do_item_stats_sizes(ADD_STAT add_stats, void *c)
if (histogram[i] != 0) {
char key[8];
int klen = 0;
- klen = sprintf(key, "%d", i * 32);
+ klen = snprintf(key, 8, "%d", i * 32);
assert(klen < sizeof(key));
APPEND_STAT(key, "%u", histogram[i]);
}

View File

@ -0,0 +1,97 @@
$OpenBSD: patch-memcached_c,v 1.6 2009/08/07 10:46:41 jasper Exp $
--- memcached.c.orig Thu Jul 9 13:16:24 2009
+++ memcached.c Sat Jul 11 11:01:39 2009
@@ -93,7 +93,11 @@ static void write_and_free(conn *c, char *buf, int byt
static int ensure_iov_space(conn *c);
static int add_iov(conn *c, const void *buf, int len);
static int add_msghdr(conn *c);
+
+/* OpenBSD has this in sys/types.h already. */
+#ifndef _SYS_ENDIAN_H_
static uint64_t swap64(uint64_t in);
+#endif /* !_SYS_ENDIAN_H_ */
/* time handling */
static void set_current_time(void); /* update the global variable holding
@@ -976,6 +980,7 @@ static void write_bin_response(conn *c, void *d, int h
}
}
+#ifndef _SYS_ENDIAN_H_
/* Byte swap a 64-bit number */
static uint64_t swap64(uint64_t in) {
#ifdef ENDIAN_LITTLE
@@ -991,8 +996,9 @@ static uint64_t swap64(uint64_t in) {
#else
/* big-endian machines don't need byte swapping */
return in;
-#endif
+#endif /* !ENDIAN_LITTLE */
}
+#endif /* !_SYS_ENDIAN_H_ */
static void complete_incr_bin(conn *c) {
item *it;
@@ -1278,12 +1284,14 @@ static void append_ascii_stats(const char *key, const
char *pos = c->stats.buffer + c->stats.offset;
uint32_t nbytes;
+ size_t s_pos = sizeof(pos);
+
if (klen == 0 && vlen == 0) {
- nbytes = sprintf(pos, "END\r\n");
+ nbytes = snprintf(pos, s_pos, "END\r\n");
} else if (vlen == 0) {
- nbytes = sprintf(pos, "STAT %s\r\n", key);
+ nbytes = snprintf(pos, s_pos, "STAT %s\r\n", key);
} else {
- nbytes = sprintf(pos, "STAT %s %s\r\n", key, val);
+ nbytes = snprintf(pos, s_pos, "STAT %s %s\r\n", key, val);
}
c->stats.offset += nbytes;
@@ -2248,6 +2256,7 @@ static inline void process_get_command(conn *c, token_
int stats_get_cmds = 0;
int stats_get_misses = 0;
int stats_get_hits[MAX_NUMBER_OF_SLAB_CLASSES];
+ size_t s_suffix;
assert(c != NULL);
memset(&stats_get_hits, 0, sizeof(stats_get_hits));
@@ -2326,7 +2335,9 @@ static inline void process_get_command(conn *c, token_
return;
}
*(c->suffixlist + i) = suffix;
- sprintf(suffix, " %llu\r\n", (unsigned long long)ITEM_get_cas(it));
+ s_suffix = sizeof(suffix);
+ snprintf(suffix, s_suffix,
+ " %llu\r\n", (unsigned long long)ITEM_get_cas(it));
if (add_iov(c, "VALUE ", 6) != 0 ||
add_iov(c, ITEM_key(it), it->nkey) != 0 ||
add_iov(c, ITEM_suffix(it), it->nsuffix - 2) != 0 ||
@@ -2559,6 +2570,7 @@ enum delta_result_type do_add_delta(conn *c, item *it,
char *ptr;
uint64_t value;
int res;
+ size_t s_buf = sizeof(buf);
ptr = ITEM_data(it);
@@ -2586,7 +2598,7 @@ enum delta_result_type do_add_delta(conn *c, item *it,
}
pthread_mutex_unlock(&c->thread->stats.mutex);
- sprintf(buf, "%llu", (unsigned long long)value);
+ snprintf(buf, s_buf, "%llu", (unsigned long long)value);
res = strlen(buf);
if (res + 2 > it->nbytes) { /* need to realloc */
item *new_it;
@@ -3672,7 +3684,7 @@ static int server_socket_unix(const char *path, int ac
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- strcpy(addr.sun_path, path);
+ strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
old_umask = umask( ~(access_mask&0777));
if (bind(sfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
perror("bind()");

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-memcached_h,v 1.1 2009/08/07 10:46:41 jasper Exp $
--- memcached.h.orig Sat Jul 11 11:06:01 2009
+++ memcached.h Sat Jul 11 11:08:09 2009
@@ -99,9 +99,9 @@
/** Append an indexed stat with a stat name (with format), value format
and value */
-#define APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) \
- klen = sprintf(key_str, name_fmt, num, name); \
- vlen = sprintf(val_str, fmt, val); \
+#define APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) \
+ klen = snprintf(key_str, 128, name_fmt, num, name); \
+ vlen = snprintf(val_str, 128, fmt, val); \
add_stats(key_str, klen, val_str, vlen, c);
/** Common APPEND_NUM_FMT_STAT format. */

View File

@ -0,0 +1,26 @@
$OpenBSD: patch-stats_c,v 1.1 2009/08/07 10:46:41 jasper Exp $
--- stats.c.orig Sat Jul 11 11:03:25 2009
+++ stats.c Sat Jul 11 11:03:54 2009
@@ -322,16 +322,17 @@ static void test_prefix_dump() {
/* Find a key that hashes to the same bucket as "abc" */
for (keynum = 0; keynum < PREFIX_HASH_SIZE * 100; keynum++) {
- sprintf(tmp, "%d", keynum);
+ snprintf(tmp, 500, "%d", keynum);
if (hashval == hash(tmp, strlen(tmp), 0) % PREFIX_HASH_SIZE) {
break;
}
}
stats_prefix_record_set(tmp);
- sprintf(tmp, "PREFIX %d get 0 hit 0 set 1 del 0\r\n"
- "PREFIX abc get 2 hit 1 set 1 del 1\r\n"
- "PREFIX def get 0 hit 0 set 0 del 1\r\n"
- "END\r\n", keynum);
+ snprintf(tmp, 500,
+ "PREFIX %d get 0 hit 0 set 1 del 0\r\n"
+ "PREFIX abc get 2 hit 1 set 1 del 1\r\n"
+ "PREFIX def get 0 hit 0 set 0 del 1\r\n"
+ "END\r\n", keynum);
test_equals_str("stats with two stats in one bucket",
tmp, stats_prefix_dump(&length));
test_equals_int("stats length with two stats in one bucket",

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-testapp_c,v 1.1 2009/08/07 10:46:41 jasper Exp $
--- testapp.c.orig Sat Jul 11 11:05:13 2009
+++ testapp.c Sat Jul 11 11:05:23 2009
@@ -233,8 +233,8 @@ static enum test_return test_safe_strtol(void) {
static enum test_return test_issue_44(void) {
char pidfile[80];
char buffer[256];
- sprintf(pidfile, "/tmp/memcached.%d", getpid());
- sprintf(buffer, "./memcached-debug -p 0 -P %s -d", pidfile);
+ snprintf(pidfile, 80, "/tmp/memcached.%d", getpid());
+ snprintf(buffer, 256, "./memcached-debug -p 0 -P %s -d", pidfile);
assert(system(buffer) == 0);
sleep(1);
FILE *fp = fopen(pidfile, "r");

View File

@ -0,0 +1,15 @@
To start memcached at boot time, add the following to /etc/rc.local:
if [ -x ${PREFIX}/bin/memcached ]; then
echo -n ' memcached'
${PREFIX}/bin/memcached -d \
-u _memcached -P /var/run/memcached.pid
fi
To see further configuration options, run "memcached -h".
Since memcached has no authentication mechanisms, it is designed for
internal use only, and should be firewalled accordingly. You may wish
to add a rule such as the following to /etc/pf.conf:
block on $ext_if proto tcp to ($ext_if) port 11211

View File

@ -1,9 +1,12 @@
@comment $OpenBSD: PLIST,v 1.3 2009/05/01 02:00:02 sthen Exp $
@comment $OpenBSD: PLIST,v 1.4 2009/08/07 10:46:41 jasper Exp $
@newgroup _memcached:637
@newuser _memcached:637:_memcached:daemon:memcache daemon:/var/empty:/sbin/nologin
@bin bin/memcached
@bin bin/memcached-debug
@man man/man1/memcached.1
include/memcached/
include/memcached/protocol_binary.h
share/doc/memcached/
share/doc/memcached/binary-protocol-plan.txt
share/doc/memcached/memory_management.txt
share/doc/memcached/protocol.txt
share/doc/memcached/readme.txt
share/doc/memcached/threads.txt