Navigation Menu

Skip to content

Commit

Permalink
autoconf/automake support from evan
Browse files Browse the repository at this point in the history
git-svn-id: http://code.sixapart.com/svn/memcached/trunk@20 b0b603af-a30f-0410-a34e-baf09ae79d0b
  • Loading branch information
bradfitz committed Jun 14, 2003
1 parent 1422dff commit 1b53326
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 22 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
@@ -0,0 +1,2 @@
Anatoly Vorobey <mellon@pobox.com>
Brad Fitzpatrick <brad@danga.com>
7 changes: 7 additions & 0 deletions ChangeLog
@@ -0,0 +1,7 @@
Fri, 13 Jun 2003 10:05:51 -0700 Evan Martin <martine@danga.com>

* configure.ac, autogen.sh, Makefile.am: Use autotools.
* items.c, memcached.c: #include <time.h> for time(),
printf time_t as %lu (is this correct?),
minor warnings fixes.

10 changes: 0 additions & 10 deletions Makefile

This file was deleted.

4 changes: 4 additions & 0 deletions Makefile.am
@@ -0,0 +1,4 @@
bin_PROGRAMS = memcached

memcached_SOURCES = memcached.c slabs.c items.c memcached.h

4 changes: 2 additions & 2 deletions README
@@ -1,7 +1,7 @@
Dependencies:

-- Judy, http://judy.sf.net/
-- libevent, http://www.monkey.org/~provos/libevent/
-- Judy, http://judy.sf.net/ (Debian package libjudy-dev)
-- libevent, http://www.monkey.org/~provos/libevent/ (libevent-dev)

If using Linux, you need a kernel with epoll. Sure, libevent will
work with normal select, but it sucks.
Expand Down
18 changes: 18 additions & 0 deletions autogen.sh
@@ -0,0 +1,18 @@
#!/bin/sh

echo "aclocal..."
ACLOCAL=${ACLOCAL:-aclocal-1.7}
$ACLOCAL || exit 1

echo "autoheader..."
AUTOHEADER=${AUTOHEADER:-autoheader}
$AUTOHEADER || exit 1

echo "automake..."
AUTOMAKE=${AUTOMAKE:-automake-1.7}
$AUTOMAKE --gnu --add-missing || exit 1

echo "autoconf..."
AUTOCONF=${AUTOCONF:-autoconf}
$AUTOCONF || exit 1

32 changes: 32 additions & 0 deletions configure.ac
@@ -0,0 +1,32 @@
AC_PREREQ(2.52)
AC_INIT(memcached, 1.0.1, XXXzilla)
AC_CONFIG_SRCDIR(memcached.c)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_CONFIG_HEADER(config.h)

AC_PROG_CC
AC_PROG_INSTALL

dnl Default to building a static executable.
AC_ARG_ENABLE(static,
AC_HELP_STRING([--disable-static],[build a dynamically linked executable]),
, enable_static=yes)
AC_MSG_CHECKING(whether to build a static executable)
if test "$enable_static" = "no"; then
STATIC=
AC_MSG_RESULT(no)
else
CFLAGS="$CFLAGS -static"
AC_MSG_RESULT(yes)
fi

JUDY_URL=http://judy.sf.net
AC_CHECK_HEADERS(Judy.h, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)])
AC_CHECK_LIB(Judy, Judy1Test, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)])

LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
AC_CHECK_LIB(event, event_set, ,
[AC_MSG_ERROR(libevent is required. You can get it from $LIBEVENT_URL)])

AC_CONFIG_FILES(Makefile)
AC_OUTPUT
6 changes: 3 additions & 3 deletions items.c
Expand Up @@ -14,6 +14,7 @@
#include <unistd.h>
#include <netinet/in.h>
#include <errno.h>
#include <time.h>
#include <event.h>
#include <malloc.h>
#include <Judy.h>
Expand Down Expand Up @@ -190,7 +191,7 @@ char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int
break;
if (!it)
break;
sprintf(temp, "ITEM %s [%u b; %u s]\r\n", it->key, it->nbytes - 2, it->time);
sprintf(temp, "ITEM %s [%u b; %lu s]\r\n", it->key, it->nbytes - 2, it->time);
len = strlen(temp);
if (bufcurr + len +5 > memlimit) /* 5 is END\r\n */
break;
Expand Down Expand Up @@ -219,7 +220,7 @@ void item_stats(char *buffer, int buflen) {

for (i=0; i<LARGEST_ID; i++) {
if (tails[i])
bufcurr += sprintf(bufcurr, "STAT items:%u:number %u\r\nSTAT items:%u:age %u\r\n",
bufcurr += sprintf(bufcurr, "STAT items:%u:number %u\r\nSTAT items:%u:age %lu\r\n",
i, sizes[i], i, now - tails[i]->time);
}
strcpy(bufcurr, "END");
Expand All @@ -237,7 +238,6 @@ char* item_stats_sizes(int *bytes) {
if (histogram) free(histogram);
if (buf) free(buf);
return 0;
return;
}

/* build the histogram */
Expand Down
18 changes: 11 additions & 7 deletions memcached.c
Expand Up @@ -15,6 +15,7 @@
* $Id$
*/

#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
Expand All @@ -28,7 +29,9 @@
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <time.h>
#include <event.h>
#include <malloc.h>
#include <Judy.h>
Expand Down Expand Up @@ -293,7 +296,7 @@ void process_stat(conn *c, char *command) {
char *pos = temp;

pos += sprintf(pos, "STAT pid %u\r\n", pid);
pos += sprintf(pos, "STAT uptime %u\r\n", now - stats.started);
pos += sprintf(pos, "STAT uptime %lu\r\n", now - stats.started);
pos += sprintf(pos, "STAT curr_items %u\r\n", stats.curr_items);
pos += sprintf(pos, "STAT total_items %u\r\n", stats.total_items);
pos += sprintf(pos, "STAT bytes %llu\r\n", stats.curr_bytes);
Expand All @@ -306,7 +309,7 @@ void process_stat(conn *c, char *command) {
pos += sprintf(pos, "STAT get_misses %u\r\n", stats.get_misses);
pos += sprintf(pos, "STAT bytes_read %llu\r\n", stats.bytes_read);
pos += sprintf(pos, "STAT bytes_written %llu\r\n", stats.bytes_written);
pos += sprintf(pos, "STAT limit_maxbytes %u\r\n", settings.maxbytes);
pos += sprintf(pos, "STAT limit_maxbytes %llu\r\n", settings.maxbytes);
pos += sprintf(pos, "STAT limit_maxitems %u\r\n", settings.maxitems);
pos += sprintf(pos, "END");
out_string(c, temp);
Expand Down Expand Up @@ -447,7 +450,7 @@ void process_command(conn *c, char *command) {
int len, res;
item *it;

res = sscanf(command, "%s %s %u %u %d\n", s_comm, key, &flags, &expire, &len);
res = sscanf(command, "%s %s %u %lu %d\n", s_comm, key, &flags, &expire, &len);
if (res!=5 || strlen(key)==0 ) {
out_string(c, "CLIENT_ERROR bad command line format");
return;
Expand Down Expand Up @@ -693,7 +696,7 @@ int try_read_network(conn *c) {

int update_event(conn *c, int new_flags) {
if (c->ev_flags == new_flags)
return;
return 0;
if (event_del(&c->event) == -1) return 0;
event_set(&c->event, c->sfd, new_flags, event_handler, (void *)c);
c->ev_flags = new_flags;
Expand Down Expand Up @@ -1061,6 +1064,7 @@ void delete_handler(int fd, short which, void *arg) {
}

void usage(void) {
printf(PACKAGE " " VERSION ".\n");
printf("-p <num> port number to listen on\n");
printf("-l <ip_addr> interface to listen on, default is INDRR_ANY\n");
printf("-s <num> maximum number of items to store, default is unlimited\n");
Expand Down Expand Up @@ -1126,7 +1130,7 @@ int main (int argc, char **argv) {
}
}

/* initialize other stuff stuff */
/* initialize other stuff */
item_init();
event_init();
stats_init();
Expand All @@ -1139,7 +1143,7 @@ int main (int argc, char **argv) {
int res;
res = daemon(0, 0);
if (res == -1) {
fprintf(stderr, "failed to fork() in order to daemonize\n");
fprintf(stderr, "failed to daemon() in order to daemonize\n");
return 1;
}
}
Expand Down Expand Up @@ -1170,6 +1174,6 @@ int main (int argc, char **argv) {
/* enter the loop */
event_loop(0);

return;
return 0;
}

0 comments on commit 1b53326

Please sign in to comment.