diff options
author | Alex Leone <acleone@gmail.com> | 2013-12-18 20:34:24 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2013-12-20 00:39:47 -0800 |
commit | c6a700a39b1d43509cd3732f6e8d54626cd54b10 (patch) | |
tree | 86957254b8bc09355046df0c7a1885b9260f4ab8 | |
parent | 7c512d097a592c5870dce2f1884529a7e98f521f (diff) | |
download | memcached-c6a700a39b1d43509cd3732f6e8d54626cd54b10.tar.gz |
Fix udp mode when listening on ipv6 addresses.
Previously the memcached could not respond to ipv6 udp packets correctly,
since the client's address was stored in a struct sockaddr (16 bytes on
linux) instead of a struct sockaddr_in6 (28 bytes).
-rw-r--r-- | memcached.c | 3 | ||||
-rw-r--r-- | memcached.h | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/memcached.c b/memcached.c index da5c464..f129865 100644 --- a/memcached.c +++ b/memcached.c @@ -3591,7 +3591,8 @@ static enum try_read_result try_read_udp(conn *c) { c->request_addr_size = sizeof(c->request_addr); res = recvfrom(c->sfd, c->rbuf, c->rsize, - 0, &c->request_addr, &c->request_addr_size); + 0, (struct sockaddr *)&c->request_addr, + &c->request_addr_size); if (res > 8) { unsigned char *buf = (unsigned char *)c->rbuf; pthread_mutex_lock(&c->thread->stats.mutex); diff --git a/memcached.h b/memcached.h index 8d63634..45b3213 100644 --- a/memcached.h +++ b/memcached.h @@ -437,7 +437,7 @@ struct conn { /* data for UDP clients */ int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */ - struct sockaddr request_addr; /* Who sent the most recent request */ + struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request */ socklen_t request_addr_size; unsigned char *hdrbuf; /* udp packet headers */ int hdrsize; /* number of headers' worth of space is allocated */ |