diff options
author | Chris Goffinet <cg@chrisgoffinet.com> | 2009-03-15 23:08:46 -0700 |
---|---|---|
committer | Chris Goffinet <cg@chrisgoffinet.com> | 2009-03-15 23:08:46 -0700 |
commit | 7d010a855ecccf4960fce4ffa4bd79d686130ca6 (patch) | |
tree | a8cd720797067725faedb00b2c4c6c83cda4a21c | |
parent | 0a7d84694cdbe721aadcc5d327992914fa48dc86 (diff) | |
download | memcached-7d010a855ecccf4960fce4ffa4bd79d686130ca6.tar.gz |
Added support for setting backlog queue on command line
-rw-r--r-- | memcached.c | 13 | ||||
-rw-r--r-- | memcached.h | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/memcached.c b/memcached.c index be9f2c2..8ccb8a6 100644 --- a/memcached.c +++ b/memcached.c @@ -177,6 +177,7 @@ static void settings_init(void) { settings.prefix_delimiter = ':'; settings.detail_enabled = 0; settings.reqs_per_event = 20; + settings.backlog = 1024; } /* @@ -3220,7 +3221,7 @@ void accept_new_conns(const bool do_accept) { for (next = listen_conn; next; next = next->next) { if (do_accept) { update_event(next, EV_READ | EV_PERSIST); - if (listen(next->sfd, 1024) != 0) { + if (listen(next->sfd, settings.backlog) != 0) { perror("listen"); } } @@ -3729,7 +3730,7 @@ static int server_socket(const int port, enum protocol prot) { continue; } else { success++; - if (!IS_UDP(prot) && listen(sfd, 1024) == -1) { + if (!IS_UDP(prot) && listen(sfd, settings.backlog) == -1) { perror("listen()"); close(sfd); freeaddrinfo(ai); @@ -3825,7 +3826,7 @@ static int server_socket_unix(const char *path, int access_mask) { return 1; } umask(old_umask); - if (listen(sfd, 1024) == -1) { + if (listen(sfd, settings.backlog) == -1) { perror("listen()"); close(sfd); return 1; @@ -3919,6 +3920,7 @@ static void usage(void) { " limits the number of requests process for a given con nection\n" " to prevent starvation. default 20\n"); printf("-C Disable use of CAS\n"); + printf("-b Set the backlog queue limit (default 1024)\n"); return; } @@ -4093,7 +4095,7 @@ int main (int argc, char **argv) { setbuf(stderr, NULL); /* process arguments */ - while ((c = getopt(argc, argv, "a:p:s:U:m:Mc:khirvdl:u:P:f:s:n:t:D:LR:C")) != -1) { + while ((c = getopt(argc, argv, "a:p:s:U:m:Mc:khirvdl:u:P:f:s:n:t:D:LR:C:b")) != -1) { switch (c) { case 'a': /* access for unix domain socket, as octal mask (like chmod)*/ @@ -4191,6 +4193,9 @@ int main (int argc, char **argv) { case 'C' : settings.use_cas = false; break; + case 'b' : + settings.backlog = atoi(optarg); + break; default: fprintf(stderr, "Illegal argument \"%c\"\n", c); return 1; diff --git a/memcached.h b/memcached.h index 2378848..2a606a8 100644 --- a/memcached.h +++ b/memcached.h @@ -122,6 +122,7 @@ struct settings { int reqs_per_event; /* Maximum number of io to process on each io-event. */ bool use_cas; + int backlog; }; extern struct stats stats; |