Changeset 506
- Timestamp:
- 04/16/07 14:02:37 (2 years ago)
- Files:
-
- branches/multithreaded/server/daemon.c (modified) (2 diffs)
- branches/multithreaded/server/items.c (modified) (2 diffs)
- branches/multithreaded/server/memcached.c (modified) (5 diffs)
- branches/multithreaded/server/scripts/memcached-tool (modified) (2 diffs)
- branches/multithreaded/server/slabs.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/multithreaded/server/daemon.c
r335 r506 39 39 #include <unistd.h> 40 40 41 int 42 daemon(nochdir, noclose) 43 int nochdir, noclose; 41 int daemon(int nochdir, int noclose) 44 42 { 45 43 int fd; … … 57 55 return (-1); 58 56 59 if ( !nochdir)57 if (nochdir == 0) 60 58 (void)chdir("/"); 61 59 62 if ( !noclose&& (fd = open("/dev/null", O_RDWR, 0)) != -1) {60 if (noclose==0 && (fd = open("/dev/null", O_RDWR, 0)) != -1) { 63 61 (void)dup2(fd, STDIN_FILENO); 64 62 (void)dup2(fd, STDOUT_FILENO); branches/multithreaded/server/items.c
r497 r506 293 293 } 294 294 295 strcpy(buffer + bufcurr, "END\r\n");295 memcpy(buffer + bufcurr, "END\r\n", 6); 296 296 bufcurr += 5; 297 297 … … 315 315 i, sizes[i], i, now - tails[i]->time); 316 316 } 317 strcpy(bufcurr, "END");317 memcpy(bufcurr, "END", 4); 318 318 return; 319 319 } branches/multithreaded/server/memcached.c
r499 r506 669 669 670 670 memcpy(c->wbuf, str, len); 671 memcpy(c->wbuf + len, "\r\n", 2);671 memcpy(c->wbuf + len, "\r\n", 3); 672 672 c->wbytes = len + 2; 673 673 c->wcurr = c->wbuf; … … 964 964 return; 965 965 } 966 strcpy(wbuf + res, "END\r\n");966 memcpy(wbuf + res, "END\r\n", 6); 967 967 c->write_and_free = wbuf; 968 968 c->wcurr = wbuf; … … 1316 1316 } 1317 1317 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); 1319 1319 do_item_replace(it, new_it); 1320 1320 do_item_remove(new_it); /* release our reference */ … … 2431 2431 static void save_pid(const pid_t pid, const char *pid_file) { 2432 2432 FILE *fp; 2433 if ( !pid_file)2433 if (pid_file == NULL) 2434 2434 return; 2435 2435 … … 2447 2447 2448 2448 static void remove_pidfile(const char *pid_file) { 2449 if ( !pid_file)2449 if (pid_file == NULL) 2450 2450 return; 2451 2451 branches/multithreaded/server/scripts/memcached-tool
r213 r506 27 27 undef $mode if $to < 6 || $to > 17; 28 28 print STDERR "ERROR: parameters out of range\n\n" unless $mode; 29 } elsif ($mode eq 'dump') { 30 ; 29 31 } else { 30 32 undef $mode; … … 79 81 } 80 82 83 if ($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 81 130 # display mode: 82 131 branches/multithreaded/server/slabs.c
r493 r506 22 22 #include <errno.h> 23 23 #include <assert.h> 24 #include <stdbool.h> 24 25 25 26 #define POWER_SMALLEST 1 … … 81 82 int res = POWER_SMALLEST; 82 83 83 if (size == 0)84 if (size == 0) 84 85 return 0; 85 86 while (size > slabclass[res].size) … … 317 318 slabclass_t *p, *dp; 318 319 void *iter; 319 int was_busy = 0;320 bool was_busy = false; 320 321 321 322 if (srcid < POWER_SMALLEST || srcid > power_largest || … … 342 343 item *it = (item *)iter; 343 344 if (it->slabs_clsid) { 344 if (it->refcount) was_busy = 1;345 if (it->refcount) was_busy = true; 345 346 item_unlink(it); 346 347 }
