diff options
author | Paul Lindner <plindner@hi5.com> | 2007-05-07 21:24:31 +0000 |
---|---|---|
committer | Paul Lindner <plindner@hi5.com> | 2007-05-07 21:24:31 +0000 |
commit | d9b97d8090d2efb213b46e8313768b9faa4f777c (patch) | |
tree | 77e95f918a5c016add094da333b2a7a753997e65 | |
parent | b65aa2ab5d2748fd9d518b86385aa1e037f07021 (diff) | |
download | memcached-d9b97d8090d2efb213b46e8313768b9faa4f777c.tar.gz |
cleanup unistd.h, better spec file, remove warnings from threads.c
git-svn-id: http://code.sixapart.com/svn/memcached/trunk/server@551 b0b603af-a30f-0410-a34e-baf09ae79d0b
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | assoc.c | 1 | ||||
-rw-r--r-- | items.c | 1 | ||||
-rw-r--r-- | memcached.c | 9 | ||||
-rw-r--r-- | memcached.h | 6 | ||||
-rw-r--r-- | memcached.spec | 28 | ||||
-rw-r--r-- | slabs.c | 1 | ||||
-rw-r--r-- | thread.c | 39 |
8 files changed, 51 insertions, 37 deletions
@@ -1,6 +1,9 @@ 2007-05-07 Paul Lindner <lindner@inuus.com> * Fix compilation bug on freebsd 6.x (and maybe others) + * Update RPM spec file per redhat bugzilla #238994 + * Move unistd.h to memcached.h to get rid of warnings + * Add string.h to thread.c to get correctly prototyped strerror() 2007-05-04 Paul Lindner <lindner@inuus.com> @@ -19,7 +19,6 @@ #include <sys/signal.h> #include <sys/resource.h> #include <fcntl.h> -#include <unistd.h> #include <netinet/in.h> #include <errno.h> #include <stdlib.h> @@ -6,7 +6,6 @@ #include <sys/signal.h> #include <sys/resource.h> #include <fcntl.h> -#include <unistd.h> #include <netinet/in.h> #include <errno.h> #include <stdlib.h> diff --git a/memcached.c b/memcached.c index 1efc213..873f0d1 100644 --- a/memcached.c +++ b/memcached.c @@ -35,7 +35,6 @@ std * #include <pwd.h> #include <sys/mman.h> #include <fcntl.h> -#include <unistd.h> #include <netinet/tcp.h> #include <arpa/inet.h> #include <errno.h> @@ -861,9 +860,11 @@ static void process_stat(conn *c, token_t *tokens, const size_t ntokens) { char temp[1024]; pid_t pid = getpid(); char *pos = temp; - struct rusage usage; +#ifndef WIN32 + struct rusage usage; getrusage(RUSAGE_SELF, &usage); +#endif /* !WIN32 */ STATS_LOCK(); pos += sprintf(pos, "STAT pid %u\r\n", pid); @@ -871,8 +872,10 @@ static void process_stat(conn *c, token_t *tokens, const size_t ntokens) { pos += sprintf(pos, "STAT time %ld\r\n", now + stats.started); pos += sprintf(pos, "STAT version " VERSION "\r\n"); pos += sprintf(pos, "STAT pointer_size %d\r\n", 8 * sizeof(void *)); +#ifndef WIN32 pos += sprintf(pos, "STAT rusage_user %ld.%06ld\r\n", usage.ru_utime.tv_sec, usage.ru_utime.tv_usec); pos += sprintf(pos, "STAT rusage_system %ld.%06ld\r\n", usage.ru_stime.tv_sec, usage.ru_stime.tv_usec); +#endif /* !WIN32 */ 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); @@ -926,6 +929,7 @@ static void process_stat(conn *c, token_t *tokens, const size_t ntokens) { #endif /* HAVE_STRUCT_MALLINFO */ #endif /* HAVE_MALLOC_H */ +#if !defined(WIN32) || !defined(__APPLE__) if (strcmp(subcommand, "maps") == 0) { char *wbuf; int wsize = 8192; /* should be enough */ @@ -964,6 +968,7 @@ static void process_stat(conn *c, token_t *tokens, const size_t ntokens) { close(fd); return; } +#endif if (strcmp(subcommand, "cachedump") == 0) { diff --git a/memcached.h b/memcached.h index ab0429c..b6e24de 100644 --- a/memcached.h +++ b/memcached.h @@ -42,6 +42,11 @@ typedef unsigned char uint8_t; #endif +/* unistd.h is here */ +#if HAVE_UNISTD_H +# include <unistd.h> +#endif + /* Time relative to server start. Smaller than time_t on 64-bit systems. */ typedef unsigned int rel_time_t; @@ -246,6 +251,7 @@ void dispatch_conn_new(int sfd, int init_state, int event_flags, int read_buffer /* Lock wrappers for cache functions that are called from main loop. */ char *mt_add_delta(item *item, int incr, unsigned int delta, char *buf); +void mt_assoc_move_next_bucket(void); conn *mt_conn_from_freelist(void); int mt_conn_add_to_freelist(conn *c); char *mt_defer_delete(item *it, time_t exptime); diff --git a/memcached.spec b/memcached.spec index 7ef0a63..f165795 100644 --- a/memcached.spec +++ b/memcached.spec @@ -1,6 +1,6 @@ Name: memcached Version: 1.2.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: High Performance, Distributed Memory Object Cache Group: System Environment/Daemons @@ -11,8 +11,6 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libevent-devel -Requires: libevent -Requires: perl Requires(post): /sbin/chkconfig Requires(preun): /sbin/chkconfig, /sbin/service Requires(postun): /sbin/service @@ -24,16 +22,13 @@ memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. -Available rpmbuild rebuild options : - --with=threads - build a multiprocessor optimized memcached server - %prep %setup -q %build %configure \ - %{?_with_threads:--enable-threads} + --enable-threads make %{?_smp_mflags} @@ -43,18 +38,18 @@ make %{?_smp_mflags} #make test %install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} # Perl script monitoring memcached -install -Dp -m0755 $RPM_BUILD_DIR/%{name}-%{version}/scripts/memcached-tool %{buildroot}%{_bindir}/memcached-tool +install -Dp -m0755 scripts/memcached-tool %{buildroot}%{_bindir}/memcached-tool # Init script -install -Dp -m0755 $RPM_BUILD_DIR/%{name}-%{version}/scripts/memcached.sysv %{buildroot}%{_sysconfdir}/rc.d/init.d/memcached +install -Dp -m0755 scripts/memcached.sysv %{buildroot}%{_initrddir}/memcached # Default configs -mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig -cat <<EOF >$RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/%{name} +mkdir -p %{buildroot}/%{_sysconfdir}/sysconfig +cat <<EOF >%{buildroot}/%{_sysconfdir}/sysconfig/%{name} PORT="11211" USER="nobody" MAXCONN="1024" @@ -63,7 +58,7 @@ OPTIONS="" EOF %clean -rm -rf $RPM_BUILD_ROOT +rm -rf %{buildroot} %post @@ -91,9 +86,12 @@ exit 0 %{_bindir}/memcached %{_bindir}/memcached-debug %{_mandir}/man1/memcached.1* -%{_sysconfdir}/rc.d/init.d/memcached +%{_initrddir}/memcached %changelog +* Mon May 7 2007 Paul Lindner <lindner@inuus.com> - 1.2.2-2 +- Tidyness improvements suggested by Ruben Kerkhof in bugzilla #238994 + * Fri May 4 2007 Paul Lindner <lindner@inuus.com> - 1.2.2-1 - Initial spec file created via rpmdev-newspec @@ -15,7 +15,6 @@ #include <sys/signal.h> #include <sys/resource.h> #include <fcntl.h> -#include <unistd.h> #include <netinet/in.h> #include <errno.h> #include <stdlib.h> @@ -14,6 +14,10 @@ #include <malloc.h> #endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + #ifdef USE_THREADS #include <pthread.h> @@ -112,6 +116,7 @@ static CQ_ITEM *cq_pop(CQ *cq) { /* * Looks for an item on a connection queue, but doesn't block if there isn't * one. + * Returns the item, or NULL if no item is available */ static CQ_ITEM *cq_peek(CQ *cq) { CQ_ITEM *item; @@ -203,7 +208,7 @@ static void create_worker(void *(*func)(void *), void *arg) { pthread_attr_init(&attr); - if (ret = pthread_create(&thread, &attr, func, arg)) { + if ((ret = pthread_create(&thread, &attr, func, arg)) != 0) { fprintf(stderr, "Can't create thread: %s\n", strerror(ret)); exit(1); @@ -283,7 +288,7 @@ static void *worker_libevent(void *arg) { pthread_cond_signal(&init_cond); pthread_mutex_unlock(&init_lock); - event_base_loop(me->base, 0); + return (void*) event_base_loop(me->base, 0); } @@ -300,22 +305,23 @@ static void thread_libevent_process(int fd, short which, void *arg) { if (settings.verbose > 0) fprintf(stderr, "Can't read from libevent pipe\n"); - if (item = cq_peek(&me->new_conn_queue)) { - conn *c = conn_new(item->sfd, item->init_state, item->event_flags, - item->read_buffer_size, item->is_udp, me->base); - if (!c) { - if (item->is_udp) { - fprintf(stderr, "Can't listen for events on UDP socket\n"); - exit(1); + item = cq_peek(&me->new_conn_queue); + + if (NULL != item) { + conn *c = conn_new(item->sfd, item->init_state, item->event_flags, + item->read_buffer_size, item->is_udp, me->base); + if (!c) { + if (item->is_udp) { + fprintf(stderr, "Can't listen for events on UDP socket\n"); + exit(1); + } else { + if (settings.verbose > 0) { + fprintf(stderr, "Can't listen for events on fd %d\n", + item->sfd); + } + close(item->sfd); } - else { - if (settings.verbose > 0) { - fprintf(stderr, "Can't listen for events on fd %d\n", - item->sfd); - } - close(item->sfd); } - } cqi_free(item); } } @@ -562,7 +568,6 @@ void mt_stats_unlock() { */ void thread_init(int nthreads, struct event_base *main_base) { int i; - pthread_t *thread; pthread_mutex_init(&cache_lock, NULL); pthread_mutex_init(&conn_lock, NULL); |