event/ServerSocket: pass UniqueSocketDescriptor by value

Passing it by value is actually smaller (32 bit) than the rvalue
reference (64 bit pointer), and it ensures that the object is consumed
after the call returns, no matter how the methods are implemented.
This commit is contained in:
Max Kellermann
2017-11-10 20:43:14 +01:00
parent 5fd2b7cc79
commit 0ff4350352
8 changed files with 13 additions and 12 deletions

View File

@@ -97,7 +97,7 @@ public:
std::list<ClientMessage> messages;
Client(EventLoop &loop, Partition &partition,
UniqueSocketDescriptor &&fd, int uid, int num);
UniqueSocketDescriptor fd, int uid, int num);
~Client() {
if (FullyBufferedSocket::IsDefined())
@@ -239,7 +239,7 @@ client_manager_init();
void
client_new(EventLoop &loop, Partition &partition,
UniqueSocketDescriptor &&fd, SocketAddress address, int uid);
UniqueSocketDescriptor fd, SocketAddress address, int uid);
/**
* Write a printf-like formatted string to the client.

View File

@@ -42,7 +42,7 @@
static constexpr char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
Client::Client(EventLoop &_loop, Partition &_partition,
UniqueSocketDescriptor &&_fd, int _uid, int _num)
UniqueSocketDescriptor _fd, int _uid, int _num)
:FullyBufferedSocket(_fd.Release(), _loop,
16384, client_max_output_buffer_size),
timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)),
@@ -56,7 +56,7 @@ Client::Client(EventLoop &_loop, Partition &_partition,
void
client_new(EventLoop &loop, Partition &partition,
UniqueSocketDescriptor &&fd, SocketAddress address, int uid)
UniqueSocketDescriptor fd, SocketAddress address, int uid)
{
static unsigned int next_client_num;
const auto remote = ToString(address);