event/SocketEvent: rename Steal() to ReleaseSocket()
This commit is contained in:
parent
95bb12880d
commit
ff6e434caf
@ -573,7 +573,7 @@ ProxyDatabase::Disconnect() noexcept
|
|||||||
assert(connection != nullptr);
|
assert(connection != nullptr);
|
||||||
|
|
||||||
idle_event.Cancel();
|
idle_event.Cancel();
|
||||||
socket_event.Steal();
|
socket_event.ReleaseSocket();
|
||||||
|
|
||||||
mpd_connection_free(connection);
|
mpd_connection_free(connection);
|
||||||
connection = nullptr;
|
connection = nullptr;
|
||||||
@ -634,7 +634,7 @@ ProxyDatabase::OnIdle() noexcept
|
|||||||
LogError(std::current_exception());
|
LogError(std::current_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_event.Steal();
|
socket_event.ReleaseSocket();
|
||||||
mpd_connection_free(connection);
|
mpd_connection_free(connection);
|
||||||
connection = nullptr;
|
connection = nullptr;
|
||||||
return;
|
return;
|
||||||
|
@ -37,16 +37,6 @@ SocketEvent::Open(SocketDescriptor _fd) noexcept
|
|||||||
fd = _fd;
|
fd = _fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketDescriptor
|
|
||||||
SocketEvent::Steal() noexcept
|
|
||||||
{
|
|
||||||
assert(IsDefined());
|
|
||||||
|
|
||||||
Cancel();
|
|
||||||
|
|
||||||
return std::exchange(fd, SocketDescriptor::Undefined());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SocketEvent::Close() noexcept
|
SocketEvent::Close() noexcept
|
||||||
{
|
{
|
||||||
|
@ -109,13 +109,12 @@ public:
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open(SocketDescriptor _fd) noexcept;
|
SocketDescriptor ReleaseSocket() noexcept {
|
||||||
|
Cancel();
|
||||||
|
return std::exchange(fd, SocketDescriptor::Undefined());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
void Open(SocketDescriptor _fd) noexcept;
|
||||||
* "Steal" the socket descriptor. This abandons the socket
|
|
||||||
* and returns it.
|
|
||||||
*/
|
|
||||||
SocketDescriptor Steal() noexcept;
|
|
||||||
|
|
||||||
void Close() noexcept;
|
void Close() noexcept;
|
||||||
|
|
||||||
|
@ -403,8 +403,7 @@ NfsConnection::DestroyContext() noexcept
|
|||||||
new leases */
|
new leases */
|
||||||
defer_new_lease.Cancel();
|
defer_new_lease.Cancel();
|
||||||
|
|
||||||
if (socket_event.IsDefined())
|
socket_event.ReleaseSocket();
|
||||||
socket_event.Steal();
|
|
||||||
|
|
||||||
callbacks.ForEach([](CancellableCallback &c){
|
callbacks.ForEach([](CancellableCallback &c){
|
||||||
c.PrepareDestroyContext();
|
c.PrepareDestroyContext();
|
||||||
@ -434,14 +433,14 @@ NfsConnection::ScheduleSocket() noexcept
|
|||||||
|
|
||||||
const int which_events = nfs_which_events(context);
|
const int which_events = nfs_which_events(context);
|
||||||
|
|
||||||
if (which_events == POLLOUT && socket_event.IsDefined())
|
if (which_events == POLLOUT)
|
||||||
/* kludge: if libnfs asks only for POLLOUT, it means
|
/* kludge: if libnfs asks only for POLLOUT, it means
|
||||||
that it is currently waiting for the connect() to
|
that it is currently waiting for the connect() to
|
||||||
finish - rpc_reconnect_requeue() may have been
|
finish - rpc_reconnect_requeue() may have been
|
||||||
called from inside nfs_service(); we must now
|
called from inside nfs_service(); we must now
|
||||||
unregister the old socket and register the new one
|
unregister the old socket and register the new one
|
||||||
instead */
|
instead */
|
||||||
socket_event.Steal();
|
socket_event.ReleaseSocket();
|
||||||
|
|
||||||
if (!socket_event.IsDefined()) {
|
if (!socket_event.IsDefined()) {
|
||||||
SocketDescriptor _fd(nfs_get_fd(context));
|
SocketDescriptor _fd(nfs_get_fd(context));
|
||||||
@ -495,7 +494,7 @@ NfsConnection::OnSocketReady(unsigned flags) noexcept
|
|||||||
which is a sure sign that libnfs will close the
|
which is a sure sign that libnfs will close the
|
||||||
socket, which can lead to a race condition if
|
socket, which can lead to a race condition if
|
||||||
epoll_ctl() is called later */
|
epoll_ctl() is called later */
|
||||||
socket_event.Steal();
|
socket_event.ReleaseSocket();
|
||||||
|
|
||||||
const int result = Service(flags);
|
const int result = Service(flags);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user