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