[memcached] bradfitz,
r312: fixes from Nathan Neulinger <nneul@umr.e...
commits at code.sixapart.com
commits at code.sixapart.com
Mon Aug 21 20:12:20 UTC 2006
fixes from Nathan Neulinger <nneul at umr.edu> to make his unix domain
socket patch work with the UDP mode. the two patches kinda conflicted before.
U branches/facebook/memcached.c
Modified: branches/facebook/memcached.c
===================================================================
--- branches/facebook/memcached.c 2006-08-21 20:05:32 UTC (rev 311)
+++ branches/facebook/memcached.c 2006-08-21 20:12:19 UTC (rev 312)
@@ -87,7 +87,7 @@
stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0;
stats.curr_bytes = stats.bytes_read = stats.bytes_written = 0;
stats.started = time(0);
-}
+}
void stats_reset(void) {
stats.total_items = stats.total_conns = 0;
stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0;
@@ -117,7 +117,7 @@
int add_msghdr(conn *c)
{
struct msghdr *msg;
-
+
if (c->msgsize == c->msgused) {
msg = realloc(c->msglist, c->msgsize * 2 * sizeof(struct msghdr));
if (! msg)
@@ -1200,7 +1200,16 @@
c->rcurr = c->rbuf = new_rbuf;
c->rsize *= 2;
}
- c->request_addr_size = sizeof(c->request_addr);
+
+ /* unix socket mode doesn't need this, so zeroed out. but why
+ * is this done for every command? presumably for UDP
+ * mode. */
+ if (c->request_addr.sa_family != AF_UNSPEC) {
+ c->request_addr_size = sizeof(c->request_addr);
+ } else {
+ c->request_addr_size = 0;
+ }
+
res = read(c->sfd, c->rbuf + c->rbytes, c->rsize - c->rbytes);
if (res > 0) {
stats.bytes_read += res;
@@ -1599,7 +1608,7 @@
setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof(flags));
}
- /*
+ /*
* the memset call clears nonstandard fields in some impementations
* that otherwise mess things up.
*/
@@ -2048,7 +2057,7 @@
exit(1);
}
- if (settings.udpport > 0) {
+ if (settings.udpport > 0 && ! settings.socketpath) {
/* create the UDP listening socket and bind it */
u_socket = server_socket(settings.udpport, 1);
if (u_socket == -1) {
@@ -2057,7 +2066,6 @@
}
}
-
/* lose root privileges if we have them */
if (getuid()== 0 || geteuid()==0) {
if (username==0 || *username=='\0') {
More information about the memcached-commits
mailing list