Commit e401a93c authored by Francis Ma's avatar Francis Ma Committed by Andrii Grynenko

Move static member inside the scope of the function

Summary: We are seeing crashes which comes from the initialization of the static global variable. This particular variable is used only in a single function that was never invoked. So moving it into the scope of the function will at least solve the problem. The real issue still requires some deep investigation though.

Test Plan: unitest under folly passed

Reviewed By: subodh@fb.com

Subscribers: seanc, njormrod

FB internal diff: D1598048

Tasks: 5316441
parent a04f2681
......@@ -28,7 +28,6 @@ using std::string;
namespace folly {
static IPAddressV4 loopback_addr("127.0.0.0");
// free functions
size_t hash_value(const IPAddressV4& addr) {
......@@ -146,6 +145,7 @@ bool IPAddressV4::inSubnetWithMask(const IPAddressV4& subnet,
}
bool IPAddressV4::isLoopback() const {
static IPAddressV4 loopback_addr("127.0.0.0");
return inSubnetWithMask(loopback_addr, fetchMask(8));
}
......
......@@ -226,6 +226,8 @@ class IPAddressV4 : boost::totally_ordered<IPAddressV4> {
private:
union AddressStorage {
static_assert(sizeof(in_addr) == sizeof(ByteArray4),
"size of in_addr and ByteArray4 are different");
in_addr inAddr_;
ByteArray4 bytes_;
AddressStorage() {
......
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