fixed build error with libstdc++

sorry compiled only with libc++
pull/1428/head
dominic 6 years ago
parent 4d920af8fb
commit 618a1597da

@ -3,20 +3,18 @@
#pragma once #pragma once
#include <spdlog/common.h>
#include <spdlog/sinks/base_sink.h>
#include <spdlog/details/null_mutex.h>
#include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <fcntl.h> #include <fcntl.h>
#include <poll.h> #include <memory>
#include <mutex> #include <mutex>
#include <netdb.h>
#include <poll.h>
#include <spdlog/common.h>
#include <spdlog/details/null_mutex.h>
#include <spdlog/sinks/base_sink.h>
#include <string> #include <string>
#include <memory> #include <sys/socket.h>
#include <unistd.h>
#pragma once #pragma once
@ -104,13 +102,30 @@ private:
} }
struct SocketCloser struct SocketCloser
{ {
using pointer = int; SocketCloser(int fd)
void operator()(int socket_fd) : fd_{fd}
{}
int fd_;
~SocketCloser()
{
if (fd_ != -1)
{
::close(fd_);
}
}
int get()
{
return fd_;
}
int release()
{ {
::close(socket_fd); int fd = fd_;
fd_ = -1;
return fd;
} }
}; };
std::unique_ptr<int, SocketCloser> socket_up(socket_rv); SocketCloser socket_up(socket_rv);
socket_rv = -1; socket_rv = -1;
int const oldFlag = ::fcntl(socket_up.get(), F_GETFL); int const oldFlag = ::fcntl(socket_up.get(), F_GETFL);
@ -153,11 +168,10 @@ private:
timeout = std::chrono::nanoseconds{} > timeout ? std::chrono::nanoseconds{} : timeout; timeout = std::chrono::nanoseconds{} > timeout ? std::chrono::nanoseconds{} : timeout;
auto const stoptime = auto const stoptime = timeout > std::chrono::hours(24 * 365 * 100)
timeout > std::chrono::hours(24 * 365 * 100) ? std::chrono::steady_clock::time_point::max()
? std::chrono::steady_clock::time_point::max() : std::chrono::steady_clock::now() + timeout; // TODO could overflow but the program run for
: std::chrono::steady_clock::now() + // ~191 years in that case so that should be OK
timeout; // TODO could overflow but the program run for ~191 years in that case so that should be OK
auto ts = calcTs(timeout); auto ts = calcTs(timeout);

Loading…
Cancel
Save