net/UniqueSocketDescriptor: use AdoptTag in the constructors that adopt ownership
This makes it a little bit harder to use the ownershop-adopting constructors accidently.
This commit is contained in:
parent
131263cbe3
commit
765a6a2f20
@ -49,7 +49,7 @@ listen_systemd_activation(ClientListener &listener)
|
||||
|
||||
for (int i = SD_LISTEN_FDS_START, end = SD_LISTEN_FDS_START + n;
|
||||
i != end; ++i)
|
||||
listener.AddFD(UniqueSocketDescriptor(i));
|
||||
listener.AddFD(UniqueSocketDescriptor{AdoptTag{}, i});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ inline void
|
||||
ServerSocket::OneServerSocket::Accept() noexcept
|
||||
{
|
||||
StaticSocketAddress peer_address;
|
||||
UniqueSocketDescriptor peer_fd(event.GetSocket().AcceptNonBlock(peer_address));
|
||||
UniqueSocketDescriptor peer_fd{AdoptTag{}, event.GetSocket().AcceptNonBlock(peer_address)};
|
||||
if (!peer_fd.IsDefined()) {
|
||||
const SocketErrorMessage msg;
|
||||
FmtError(server_socket_domain,
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "SocketDescriptor.hxx"
|
||||
#include "util/TagStructs.hxx"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "io/UniqueFileDescriptor.hxx"
|
||||
@ -21,17 +22,17 @@ public:
|
||||
UniqueSocketDescriptor() noexcept
|
||||
:SocketDescriptor(SocketDescriptor::Undefined()) {}
|
||||
|
||||
explicit UniqueSocketDescriptor(SocketDescriptor _fd) noexcept
|
||||
explicit UniqueSocketDescriptor(AdoptTag, SocketDescriptor _fd) noexcept
|
||||
:SocketDescriptor(_fd) {}
|
||||
#ifndef _WIN32
|
||||
explicit UniqueSocketDescriptor(FileDescriptor _fd) noexcept
|
||||
explicit UniqueSocketDescriptor(AdoptTag, FileDescriptor _fd) noexcept
|
||||
:SocketDescriptor(_fd) {}
|
||||
|
||||
explicit UniqueSocketDescriptor(UniqueFileDescriptor &&_fd) noexcept
|
||||
:SocketDescriptor(_fd.Release()) {}
|
||||
#endif // !_WIN32
|
||||
|
||||
explicit UniqueSocketDescriptor(int _fd) noexcept
|
||||
explicit UniqueSocketDescriptor(AdoptTag, int _fd) noexcept
|
||||
:SocketDescriptor(_fd) {}
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -75,14 +76,14 @@ public:
|
||||
* @return an "undefined" instance on error
|
||||
*/
|
||||
UniqueSocketDescriptor AcceptNonBlock() const noexcept {
|
||||
return UniqueSocketDescriptor(SocketDescriptor::AcceptNonBlock());
|
||||
return UniqueSocketDescriptor{AdoptTag{}, SocketDescriptor::AcceptNonBlock()};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an "undefined" instance on error
|
||||
*/
|
||||
UniqueSocketDescriptor AcceptNonBlock(StaticSocketAddress &address) const noexcept {
|
||||
return UniqueSocketDescriptor(SocketDescriptor::AcceptNonBlock(address));
|
||||
return UniqueSocketDescriptor{AdoptTag{}, SocketDescriptor::AcceptNonBlock(address)};
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
|
Loading…
x
Reference in New Issue
Block a user