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
068f191c
Commit
068f191c
authored
Jan 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/SocketMonitor: add method Steal()
parent
6bf6c921
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
SocketMonitor.cxx
src/event/SocketMonitor.cxx
+11
-3
SocketMonitor.hxx
src/event/SocketMonitor.hxx
+6
-0
No files found.
src/event/SocketMonitor.cxx
View file @
068f191c
...
...
@@ -105,17 +105,25 @@ SocketMonitor::Open(int _fd)
g_source_add_poll
(
&
source
->
base
,
&
poll
);
}
void
SocketMonitor
::
Close
()
int
SocketMonitor
::
Steal
()
{
assert
(
IsDefined
());
Cancel
();
close_socket
(
fd
)
;
int
result
=
fd
;
fd
=
-
1
;
g_source_destroy
(
&
source
->
base
);
g_source_unref
(
&
source
->
base
);
source
=
nullptr
;
return
result
;
}
void
SocketMonitor
::
Close
()
{
close_socket
(
Steal
());
}
src/event/SocketMonitor.hxx
View file @
068f191c
...
...
@@ -73,6 +73,12 @@ public:
void
Open
(
int
_fd
);
/**
* "Steal" the socket descriptor. This abandons the socket
* and puts the responsibility for closing it to the caller.
*/
int
Steal
();
void
Close
();
void
Schedule
(
unsigned
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