summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b727acf)
Summary: O_TMPFILE flag is not available on older Linux systems (supported starting Linux 3.11). Got complains about it on GitHub (https://fburl.com/9d848m7i) Will use folly::test::TemporaryFile instead.
Reviewed By: yfeldblum
Differential Revision:
D4729733
fbshipit-source-id:
903563825c5b939e35c61725da559e33d21212c4
// Set up listening socket
int lfd = fsp::socket(AF_UNIX, SOCK_STREAM, 0);
ASSERT_NE(lfd, -1);
// Set up listening socket
int lfd = fsp::socket(AF_UNIX, SOCK_STREAM, 0);
ASSERT_NE(lfd, -1);
+ SCOPE_EXIT { close(lfd); };
ASSERT_NE(bind(lfd, (struct sockaddr*)&addr, sizeof(addr)), -1)
<< "Bind failed: " << errno;
ASSERT_NE(bind(lfd, (struct sockaddr*)&addr, sizeof(addr)), -1)
<< "Bind failed: " << errno;
// Accept the connection
int sfd = accept(lfd, nullptr, nullptr);
ASSERT_NE(sfd, -1);
// Accept the connection
int sfd = accept(lfd, nullptr, nullptr);
ASSERT_NE(sfd, -1);
+ SCOPE_EXIT { close(sfd); };
// Instantiate AsyncSocket object for the connected socket
EventBase evb;
// Instantiate AsyncSocket object for the connected socket
EventBase evb;
// Open a temporary file and write a magic string to it
// We'll transfer the file handle to test the message parameters
// callback logic.
// Open a temporary file and write a magic string to it
// We'll transfer the file handle to test the message parameters
// callback logic.
- int tmpfd = open("/var/tmp", O_RDWR | O_TMPFILE);
+ TemporaryFile file(StringPiece(),
+ fs::path(),
+ TemporaryFile::Scope::UNLINK_IMMEDIATELY);
+ int tmpfd = file.fd();
ASSERT_NE(tmpfd, -1) << "Failed to open a temporary file";
std::string magicString("Magic string");
ASSERT_EQ(write(tmpfd, magicString.c_str(), magicString.length()),
ASSERT_NE(tmpfd, -1) << "Failed to open a temporary file";
std::string magicString("Magic string");
ASSERT_EQ(write(tmpfd, magicString.c_str(), magicString.length()),
int fd = 0;
memcpy(&fd, CMSG_DATA(&r_u.cmh), sizeof(int));
ASSERT_NE(fd, 0);
int fd = 0;
memcpy(&fd, CMSG_DATA(&r_u.cmh), sizeof(int));
ASSERT_NE(fd, 0);
+ SCOPE_EXIT { close(fd); };
std::vector<uint8_t> transferredMagicString(magicString.length() + 1, 0);
std::vector<uint8_t> transferredMagicString(magicString.length() + 1, 0);