Commit ceebc296 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Back libevent file descriptor transformation with the fd<->socket map

Summary: Currently it's just leaking file descriptors, stop that by backing it with the map.

Reviewed By: yfeldblum

Differential Revision: D10842827

fbshipit-source-id: 434d7463ede1639e0fa2edf0be438aa561b39b16
parent 5ea1ed7e
......@@ -28,6 +28,8 @@
#include <folly/portability/Fcntl.h>
#endif
#include <folly/net/detail/SocketFileDescriptorMap.h>
namespace folly {
#ifdef _MSC_VER
using libevent_fd_t = evutil_socket_t;
......@@ -36,25 +38,11 @@ using libevent_fd_t = int;
#endif
inline libevent_fd_t getLibeventFd(int fd) {
#ifdef _MSC_VER
if (fd == -1) {
return (libevent_fd_t)INVALID_HANDLE_VALUE;
}
return _get_osfhandle(fd);
#else
return fd;
#endif
return netops::detail::SocketFileDescriptorMap::fdToSocket(fd);
}
inline int libeventFdToFd(libevent_fd_t fd) {
#ifdef _MSC_VER
if (fd == (libevent_fd_t)INVALID_HANDLE_VALUE) {
return -1;
}
return _open_osfhandle((intptr_t)fd, O_RDWR | O_BINARY);
#else
return fd;
#endif
return netops::detail::SocketFileDescriptorMap::socketToFd(fd);
}
using EventSetCallback = void (*)(libevent_fd_t, short, void*);
......
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