Changeset 506

Show
Ignore:
Timestamp:
04/16/07 14:02:37 (2 years ago)
Author:
plindner
Message:

Merge in latest changes from trunk.

svn merge -r 500:505 http://code.sixapart.com/svn/memcached/trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/multithreaded/server/daemon.c

    r335 r506  
    3939#include <unistd.h> 
    4040 
    41 int 
    42 daemon(nochdir, noclose) 
    43     int nochdir, noclose; 
     41int daemon(int nochdir, int noclose) 
    4442{ 
    4543    int fd; 
     
    5755        return (-1); 
    5856 
    59     if (!nochdir
     57    if (nochdir == 0
    6058        (void)chdir("/"); 
    6159 
    62     if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { 
     60    if (noclose==0 && (fd = open("/dev/null", O_RDWR, 0)) != -1) { 
    6361        (void)dup2(fd, STDIN_FILENO); 
    6462        (void)dup2(fd, STDOUT_FILENO); 
  • branches/multithreaded/server/items.c

    r497 r506  
    293293    } 
    294294 
    295     strcpy(buffer + bufcurr, "END\r\n"); 
     295    memcpy(buffer + bufcurr, "END\r\n", 6); 
    296296    bufcurr += 5; 
    297297 
     
    315315                               i, sizes[i], i, now - tails[i]->time); 
    316316    } 
    317     strcpy(bufcurr, "END"); 
     317    memcpy(bufcurr, "END", 4); 
    318318    return; 
    319319} 
  • branches/multithreaded/server/memcached.c

    r499 r506  
    669669 
    670670    memcpy(c->wbuf, str, len); 
    671     memcpy(c->wbuf + len, "\r\n", 2); 
     671    memcpy(c->wbuf + len, "\r\n", 3); 
    672672    c->wbytes = len + 2; 
    673673    c->wcurr = c->wbuf; 
     
    964964            return; 
    965965        } 
    966         strcpy(wbuf + res, "END\r\n"); 
     966        memcpy(wbuf + res, "END\r\n", 6); 
    967967        c->write_and_free = wbuf; 
    968968        c->wcurr = wbuf; 
     
    13161316        } 
    13171317        memcpy(ITEM_data(new_it), buf, res); 
    1318         memcpy(ITEM_data(new_it) + res, "\r\n", 2); 
     1318        memcpy(ITEM_data(new_it) + res, "\r\n", 3); 
    13191319        do_item_replace(it, new_it); 
    13201320        do_item_remove(new_it);       /* release our reference */ 
     
    24312431static void save_pid(const pid_t pid, const char *pid_file) { 
    24322432    FILE *fp; 
    2433     if (!pid_file
     2433    if (pid_file == NULL
    24342434        return; 
    24352435 
     
    24472447 
    24482448static void remove_pidfile(const char *pid_file) { 
    2449   if (!pid_file
     2449  if (pid_file == NULL
    24502450      return; 
    24512451 
  • branches/multithreaded/server/scripts/memcached-tool

    r213 r506  
    2727    undef $mode if $to   < 6 || $to   > 17; 
    2828    print STDERR "ERROR: parameters out of range\n\n" unless $mode; 
     29} elsif ($mode eq 'dump') { 
     30    ; 
    2931} else { 
    3032    undef $mode; 
     
    7981} 
    8082 
     83if ($mode eq 'dump') { 
     84    my %items; 
     85    my $totalitems; 
     86 
     87    print $sock "stats items\r\n"; 
     88 
     89    while (<$sock>) { 
     90        last if /^END/; 
     91        if (/^STAT items:(\d*):number (\d*)/) { 
     92            $items{$1} = $2; 
     93            $totalitems += $2; 
     94        } 
     95    } 
     96    print STDERR "Dumping memcache contents\n"; 
     97    print STDERR "  Number of buckets: " . scalar(keys(%items)) . "\n"; 
     98    print STDERR "  Number of items  : $totalitems\n"; 
     99 
     100    foreach my $bucket (sort(keys(%items))) { 
     101        print STDERR "Dumping bucket $bucket - " . $items{$bucket} . " total items\n"; 
     102        print $sock "stats cachedump $bucket $items{$bucket} 1\r\n"; 
     103        my %keyexp; 
     104        while (<$sock>) { 
     105            last if /^END/; 
     106            # return format looks like this 
     107            # ITEM foo [6 b; 1176415152 s] 
     108            if (/^ITEM (\w+) \[.* (\d+) s\]/) { 
     109                $keyexp{$1} = $2; 
     110            } 
     111        } 
     112 
     113        foreach my $k (keys(%keyexp)) { 
     114            my $val; 
     115            print $sock "get $k\r\n"; 
     116            my $response = <$sock>; 
     117            $response =~ /VALUE (\w+) (\d+) (\d+)/; 
     118            my $flags = $2; 
     119            my $len = $3; 
     120            read $sock, $val , $len; 
     121            # get the END 
     122            $_ = <$sock>; 
     123            $_ = <$sock>; 
     124            print "add $k $flags $keyexp{$k} $len\r\n$val\r\n"; 
     125        } 
     126    } 
     127    exit; 
     128} 
     129 
    81130# display mode: 
    82131 
  • branches/multithreaded/server/slabs.c

    r493 r506  
    2222#include <errno.h> 
    2323#include <assert.h> 
     24#include <stdbool.h> 
    2425 
    2526#define POWER_SMALLEST 1 
     
    8182    int res = POWER_SMALLEST; 
    8283 
    83     if(size == 0) 
     84    if (size == 0) 
    8485        return 0; 
    8586    while (size > slabclass[res].size) 
     
    317318    slabclass_t *p, *dp; 
    318319    void *iter; 
    319     int was_busy = 0
     320    bool was_busy = false
    320321 
    321322    if (srcid < POWER_SMALLEST || srcid > power_largest || 
     
    342343        item *it = (item *)iter; 
    343344        if (it->slabs_clsid) { 
    344             if (it->refcount) was_busy = 1
     345            if (it->refcount) was_busy = true
    345346            item_unlink(it); 
    346347        }