Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ff6e434c
Commit
ff6e434c
authored
Oct 15, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/SocketEvent: rename Steal() to ReleaseSocket()
parent
95bb1288
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
23 deletions
+11
-23
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+2
-2
SocketEvent.cxx
src/event/SocketEvent.cxx
+0
-10
SocketEvent.hxx
src/event/SocketEvent.hxx
+5
-6
Connection.cxx
src/lib/nfs/Connection.cxx
+4
-5
No files found.
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
ff6e434c
...
@@ -573,7 +573,7 @@ ProxyDatabase::Disconnect() noexcept
...
@@ -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
...
@@ -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
;
...
...
src/event/SocketEvent.cxx
View file @
ff6e434c
...
@@ -37,16 +37,6 @@ SocketEvent::Open(SocketDescriptor _fd) noexcept
...
@@ -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
{
{
...
...
src/event/SocketEvent.hxx
View file @
ff6e434c
...
@@ -109,13 +109,12 @@ public:
...
@@ -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
;
...
...
src/lib/nfs/Connection.cxx
View file @
ff6e434c
...
@@ -403,8 +403,7 @@ NfsConnection::DestroyContext() 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
...
@@ -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
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment