Permalink
Browse files

Fix build break due to POLLRDHUP not existing on Mac

Summary: fixes hhvm/homebrew-hhvm#110

Reviewed By: fredemmott

Differential Revision: D10240660

fbshipit-source-id: bf9527b7e9246bb8d0adbe29965a9a69c183b636
  • Loading branch information...
ebluestein authored and hhvm-bot committed Oct 8, 2018
1 parent 7d06ea4 commit d180c0def4ffec6c7bd17c034ee0fd816e3e76ab
@@ -435,7 +435,7 @@ void SocketTransport::shutdownSocket(int sockFd, int abortFd) {
return;
}
int eventMask = POLLIN | POLLERR | POLLHUP | POLLRDHUP;
int eventMask = POLLIN | POLLERR | POLLHUP | g_platformPollFlags;
constexpr int abortIdx = 0;
constexpr int readIdx = 1;
@@ -453,8 +453,7 @@ void SocketTransport::shutdownSocket(int sockFd, int abortFd) {
fds[abortIdx].revents != 0 ||
fds[readIdx].revents & POLLERR ||
fds[readIdx].revents & POLLHUP ||
fds[readIdx].revents & POLLRDHUP
) {
fds[readIdx].revents & g_platformPollFlags) {
break;
} else if (fds[readIdx].revents & POLLIN) {
@@ -499,7 +498,7 @@ void SocketTransport::waitForConnection(
// fds[0] will contain the read end of our "abort" pipe. Another thread will
// write data to tihs pipe to signal it's time for this worker to stop
// blocking in poll() and terminate.
int eventMask = POLLIN | POLLERR | POLLHUP | POLLRDHUP;
int eventMask = POLLIN | POLLERR | POLLHUP | g_platformPollFlags;
fds[0].fd = abortFd;
fds[0].events = eventMask;
@@ -591,6 +590,7 @@ void SocketTransport::waitForConnection(
}
bool SocketTransport::validatePeerCreds(int newFd, ClientInfo& info) {
#ifdef SO_PEERCRED
struct ucred ucred = {0};
socklen_t len = sizeof(ucred);
@@ -656,6 +656,9 @@ bool SocketTransport::validatePeerCreds(int newFd, ClientInfo& info) {
info.clientUser = std::string(pw.pw_name);
info.clientPid = ucred.pid;
return pw.pw_name != nullptr && strlen(pw.pw_name) > 0;
#else
return true;
#endif
}
}
@@ -177,11 +177,13 @@ void DebugTransport::processOutgoingMessages() {
pollFds[abortIdx] = {0};
pollFds[abortIdx].fd = m_abortPipeFd[0];
pollFds[abortIdx].events = POLLIN | POLLERR | POLLHUP | POLLRDHUP;
pollFds[abortIdx].events =
POLLIN | POLLERR | POLLHUP | g_platformPollFlags;
pollFds[transportIdx] = {0};
pollFds[transportIdx].fd = fd;
pollFds[transportIdx].events = POLLOUT | POLLERR | POLLHUP | POLLRDHUP;
pollFds[transportIdx].events =
POLLOUT | POLLERR | POLLHUP | g_platformPollFlags;
while (true) {
std::list<std::string> messagesToSend;
@@ -256,7 +258,7 @@ void DebugTransport::processOutgoingMessages() {
} else {
// TransportFD hangup or error.
assert((pollFds[transportIdx].revents &
(POLLERR | POLLHUP | POLLRDHUP)) != 0);
(POLLERR | POLLHUP | g_platformPollFlags)) != 0);
VSDebugLogger::Log(
VSDebugLogger::LogLevelInfo,
"Transport write thread: error event on fd."
@@ -287,7 +289,8 @@ void DebugTransport::processIncomingMessages() {
// Wait for data to be available, or a termination event to occur.
constexpr int abortIdx = 0;
constexpr int transportIdx = 1;
int eventMask = POLLIN | POLLERR | POLLHUP | POLLRDHUP;
int eventMask = POLLIN | POLLERR | POLLHUP | g_platformPollFlags;
struct pollfd pollFds[2];
memset(pollFds, 0, sizeof(pollFds));
pollFds[abortIdx].fd = m_abortPipeFd[0];
@@ -95,6 +95,12 @@ struct DebugTransport {
static constexpr char* OutputLevelStdout = "stdout";
static constexpr char* OutputLevelStderr = "stderr";
#ifdef POLLRDHUP // Linux-only
static constexpr int g_platformPollFlags = POLLRDHUP;
#else
static constexpr int g_platformPollFlags = 0;
#endif
protected:
const std::string wrapOutgoingMessage(

0 comments on commit d180c0d

Please sign in to comment.