Commit b8fdbc94 authored by Mihnea Olteanu's avatar Mihnea Olteanu Committed by Facebook GitHub Bot

Fix stub of sockets for EMSCRIPTEN and XROS

Summary:
The current implementation of function stubs in `SocketFileDescriptorMap.cpp` generates the following build errors:
```
stderr: xplat/folly/net/detail/SocketFileDescriptorMap.cpp:171:3: error: 'socketToFd' has a non-throwing exception specification but can still throw [-Werror,-Wexceptions]
  throw std::logic_error("Not implemented!");
  ^
xplat/folly/net/detail/SocketFileDescriptorMap.cpp:170:30: note: function declared non-throwing here
int SocketFileDescriptorMap::socketToFd(void* sock) noexcept {
```
because the methods are stubbed out to throw and exception even though they are marked as `noexcept`.

To fix the warning the subbing implementation is changed to call `std::terminate()` instead of throwing an exception. According to the language specification (https://en.cppreference.com/w/cpp/language/noexcept_spec) this should not result in any change in run-time behavior, since throwing and exception in a method marked as `noexcept` is effectively a call to `std::terminate()`.

Differential Revision: D29687674

fbshipit-source-id: 77405d8a31e45c8836e8746c9b25e12ef06335c4
parent 653703a3
......@@ -156,19 +156,19 @@ namespace netops {
namespace detail {
int SocketFileDescriptorMap::close(int fd) noexcept {
throw std::logic_error("Not implemented!");
std::terminate();
}
int SocketFileDescriptorMap::close(void* sock) noexcept {
throw std::logic_error("Not implemented!");
std::terminate();
}
void* SocketFileDescriptorMap::fdToSocket(int fd) noexcept {
throw std::logic_error("Not implemented!");
std::terminate();
}
int SocketFileDescriptorMap::socketToFd(void* sock) noexcept {
throw std::logic_error("Not implemented!");
std::terminate();
}
} // namespace detail
......
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