Changeset 474
- Timestamp:
- 03/19/07 06:53:52 (2 years ago)
- Files:
-
- branches/multithreaded/server/ChangeLog (modified) (1 diff)
- branches/multithreaded/server/items.c (modified) (5 diffs)
- branches/multithreaded/server/items.h (modified) (1 diff)
- branches/multithreaded/server/memcached.c (modified) (6 diffs)
- branches/multithreaded/server/memcached.h (modified) (1 diff)
- branches/multithreaded/server/t/getset.t (modified) (2 diffs)
- branches/multithreaded/server/t/maxconns.t (copied) (copied from trunk/server/t/maxconns.t)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/multithreaded/server/ChangeLog
r469 r474 1 2007-03-18 Paul Lindner <lindner@mirth.inuus.com> 2 3 4 2007-03-18 Paul Lindner <lindner@inuus.com> 5 6 * Add more test cases using larger buffer sizes up to and greater 7 than 1MB. 8 9 * Remove unused parameter to item_size_ok() 10 11 * Use a single printf() in usage() 12 13 * Add a failing test for conforming with maximum connections. 14 15 2007-03-17 16 * crash fix from Thomas van Gulick <thomas@partyflock.nl> in 17 conn_shrink(), passing &ptr, instead of ptr to realloc(). 18 1 19 2007-03-05 Paul Lindner <lindner@inuus.com> 2 20 * Fix a number of places where (s)printf calls were using unsigned branches/multithreaded/server/items.c
r469 r474 34 34 int i; 35 35 for(i=0; i<LARGEST_ID; i++) { 36 heads[i]= 0;37 tails[i]= 0;36 heads[i]=NULL; 37 tails[i]=NULL; 38 38 sizes[i]=0; 39 39 } … … 64 64 * Returns the total size of the header. 65 65 */ 66 static size_t item_make_header(c har *key, const uint8_t nkey, const int flags, const int nbytes,66 static size_t item_make_header(const uint8_t nkey, const int flags, const int nbytes, 67 67 char *suffix, uint8_t *nsuffix) { 68 68 /* suffix is defined at 40 chars elsewhere.. */ … … 79 79 char suffix[40]; 80 80 81 ntotal = item_make_header( key,nkey + 1, flags, nbytes, suffix, &nsuffix);81 ntotal = item_make_header(nkey + 1, flags, nbytes, suffix, &nsuffix); 82 82 83 83 id = slabs_clsid(ntotal); … … 153 153 * the maximum for a cache entry.) 154 154 */ 155 bool item_size_ok(c har *key, const size_t nkey, const int flags, const int nbytes) {155 bool item_size_ok(const size_t nkey, const int flags, const int nbytes) { 156 156 char prefix[40]; 157 157 uint8_t nsuffix; 158 158 159 return slabs_clsid(item_make_header( key,nkey + 1, flags, nbytes,159 return slabs_clsid(item_make_header(nkey + 1, flags, nbytes, 160 160 prefix, &nsuffix)) != 0; 161 161 } … … 408 408 409 409 /* expires items that are more recent than the oldest_live setting. */ 410 void do_item_flush_expired( ) {410 void do_item_flush_expired(void) { 411 411 int i; 412 412 item *iter, *next; branches/multithreaded/server/items.h
r469 r474 4 4 item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_time_t exptime, const int nbytes); 5 5 void item_free(item *it); 6 bool item_size_ok(c har *key, const size_t nkey, const int flags, const int nbytes);6 bool item_size_ok(const size_t nkey, const int flags, const int nbytes); 7 7 8 8 int do_item_link(item *it); /* may fail if transgresses limits */ branches/multithreaded/server/memcached.c
r469 r474 472 472 473 473 if (c->isize > ITEM_LIST_HIGHWAT) { 474 item **newbuf = (item**) realloc((void*) &c->ilist, ITEM_LIST_INITIAL * sizeof(c->ilist[0]));474 item **newbuf = (item**) realloc((void*)c->ilist, ITEM_LIST_INITIAL * sizeof(c->ilist[0])); 475 475 if (newbuf) { 476 476 c->ilist = newbuf; … … 481 481 482 482 if (c->msgsize > MSG_LIST_HIGHWAT) { 483 struct msghdr *newbuf = (struct msghdr*) realloc((void*) &c->msglist, MSG_LIST_INITIAL * sizeof(c->msglist[0]));483 struct msghdr *newbuf = (struct msghdr*) realloc((void*)c->msglist, MSG_LIST_INITIAL * sizeof(c->msglist[0])); 484 484 if (newbuf) { 485 485 c->msglist = newbuf; … … 490 490 491 491 if (c->iovsize > IOV_LIST_HIGHWAT) { 492 struct iovec* newbuf = (struct iovec *) realloc((void*) &c->iov, IOV_LIST_INITIAL * sizeof(c->iov[0]));492 struct iovec* newbuf = (struct iovec *) realloc((void*)c->iov, IOV_LIST_INITIAL * sizeof(c->iov[0])); 493 493 if (newbuf) { 494 494 c->iov = newbuf; … … 1115 1115 */ 1116 1116 if(key_token->value != NULL) { 1117 ntokens = tokenize_command(key_token->value, tokens, MAX_TOKENS);1117 ntokens = tokenize_command(key_token->value, tokens, MAX_TOKENS); 1118 1118 key_token = tokens; 1119 1119 } … … 1183 1183 1184 1184 if (it == 0) { 1185 if (! item_size_ok( key,nkey, flags, vlen + 2))1185 if (! item_size_ok(nkey, flags, vlen + 2)) 1186 1186 out_string(c, "SERVER_ERROR object too large for cache"); 1187 1187 else … … 2273 2273 static void usage(void) { 2274 2274 printf(PACKAGE " " VERSION "\n"); 2275 printf("-p <num> TCP port number to listen on (default: 11211)\n" );2276 printf("-U <num> UDP port number to listen on (default: 0, off)\n");2277 printf("-s <file> unix socket path to listen on (disables network support)\n");2278 printf("-l <ip_addr> interface to listen on, default is INDRR_ANY\n");2279 printf("-d run as a daemon\n");2280 printf("-r maximize core file limit\n");2281 printf("-u <username> assume identity of <username> (only when run as root)\n");2282 printf("-m <num> max memory to use for items in megabytes, default is 64 MB\n");2283 printf("-M return error on memory exhausted (rather than removing items)\n");2284 printf("-c <num> max simultaneous connections, default is 1024\n");2285 printf("-k lock down all paged memory\n");2286 printf("-v verbose (print errors/warnings while in event loop)\n");2287 printf("-vv very verbose (also print client commands/reponses)\n");2288 printf("-h print this help and exit\n");2289 printf("-i print memcached and libevent license\n");2290 printf("-b run a managed instanced (mnemonic: buckets)\n");2291 printf("-P <file> save PID in <file>, only used with -d option\n");2292 printf("-f <factor> chunk size growth factor, default 1.25\n");2293 printf("-n <bytes> minimum space allocated for key+value+flags, default 48\n");2275 printf("-p <num> TCP port number to listen on (default: 11211)\n" 2276 "-U <num> UDP port number to listen on (default: 0, off)\n" 2277 "-s <file> unix socket path to listen on (disables network support)\n" 2278 "-l <ip_addr> interface to listen on, default is INDRR_ANY\n" 2279 "-d run as a daemon\n" 2280 "-r maximize core file limit\n" 2281 "-u <username> assume identity of <username> (only when run as root)\n" 2282 "-m <num> max memory to use for items in megabytes, default is 64 MB\n" 2283 "-M return error on memory exhausted (rather than removing items)\n" 2284 "-c <num> max simultaneous connections, default is 1024\n" 2285 "-k lock down all paged memory\n" 2286 "-v verbose (print errors/warnings while in event loop)\n" 2287 "-vv very verbose (also print client commands/reponses)\n" 2288 "-h print this help and exit\n" 2289 "-i print memcached and libevent license\n" 2290 "-b run a managed instanced (mnemonic: buckets)\n" 2291 "-P <file> save PID in <file>, only used with -d option\n" 2292 "-f <factor> chunk size growth factor, default 1.25\n" 2293 "-n <bytes> minimum space allocated for key+value+flags, default 48\n"); 2294 2294 #ifdef USE_THREADS 2295 2295 printf("-t <num> number of threads to use, default 4\n"); branches/multithreaded/server/memcached.h
r469 r474 32 32 # include <stdbool.h> 33 33 #else 34 typedef enum {false = 0, true = 1} bool;34 typedef enum {false = 0, true = 1} bool; 35 35 #endif 36 36 branches/multithreaded/server/t/getset.t
r340 r474 2 2 3 3 use strict; 4 use Test::More tests => 14;4 use Test::More tests => 528; 5 5 use FindBin qw($Bin); 6 6 use lib "$Bin/lib"; 7 7 use MemcachedTest; 8 8 9 9 10 my $server = new_memcached(); 10 11 my $sock = $server->sock; 12 11 13 12 14 # set foo (and should get it) … … 49 51 50 52 53 # Test sets up to a large size around 1MB. 54 # Everything up to 1MB - 1k should succeed, everything 1MB +1k should fail. 51 55 56 my $len = 1024; 57 while ($len < 1024*1028) { 58 my $val = "B"x$len; 59 print $sock "set foo_$len 0 0 $len\r\n$val\r\n"; 60 if ($len > (1024*1024)) { 61 is(scalar <$sock>, "SERVER_ERROR object too large for cache\r\n", "failed to store size $len"); 62 } else { 63 is(scalar <$sock>, "STORED\r\n", "stored size $len"); 64 } 65 $len += 2048; 66 } 67
