Commit 6065a18c authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Cut debugging code from SocketAddress

Summary:
[Folly] Cut debugging code from `SocketAddress`.

Specifically from its `ExternalUnixAddr` helper class, which is probably not broken.

Reviewed By: simpkins

Differential Revision: D5530685

fbshipit-source-id: adfc46ec1c1a142e9914051e8a97b39f41d71630
parent ccb56f3c
...@@ -543,38 +543,26 @@ class SocketAddress { ...@@ -543,38 +543,26 @@ class SocketAddress {
struct sockaddr_un *addr; struct sockaddr_un *addr;
socklen_t len; socklen_t len;
/* For debugging only, will be removed */
uint64_t magic;
static constexpr uint64_t kMagic = 0x1234faceb00c;
socklen_t pathLength() const { socklen_t pathLength() const {
return socklen_t(len - offsetof(struct sockaddr_un, sun_path)); return socklen_t(len - offsetof(struct sockaddr_un, sun_path));
} }
void init() { void init() {
addr = new sockaddr_un; addr = new struct sockaddr_un;
magic = kMagic;
addr->sun_family = AF_UNIX; addr->sun_family = AF_UNIX;
len = 0; len = 0;
} }
void init(const ExternalUnixAddr &other) { void init(const ExternalUnixAddr &other) {
addr = new sockaddr_un; addr = new struct sockaddr_un;
magic = kMagic;
len = other.len; len = other.len;
memcpy(addr, other.addr, size_t(len)); memcpy(addr, other.addr, size_t(len));
// Fill the rest with 0s, just for safety
memset(reinterpret_cast<char*>(addr) + len, 0,
sizeof(struct sockaddr_un) - len);
} }
void copy(const ExternalUnixAddr &other) { void copy(const ExternalUnixAddr &other) {
CHECK(magic == kMagic);
len = other.len; len = other.len;
memcpy(addr, other.addr, size_t(len)); memcpy(addr, other.addr, size_t(len));
} }
void free() { void free() {
CHECK(magic == kMagic);
delete addr; delete addr;
magic = 0;
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment