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
4ad74564
Commit
4ad74564
authored
Jan 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/SocketMonitor: OnSocketReady() returns bool
parent
73f36858
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
10 deletions
+18
-10
InotifySource.cxx
src/InotifySource.cxx
+3
-1
InotifySource.hxx
src/InotifySource.hxx
+1
-1
ServerSocket.cxx
src/ServerSocket.cxx
+3
-2
BufferedSocket.cxx
src/event/BufferedSocket.cxx
+6
-4
BufferedSocket.hxx
src/event/BufferedSocket.hxx
+1
-1
SocketMonitor.hxx
src/event/SocketMonitor.hxx
+4
-1
No files found.
src/InotifySource.cxx
View file @
4ad74564
...
@@ -41,7 +41,7 @@ mpd_inotify_quark(void)
...
@@ -41,7 +41,7 @@ mpd_inotify_quark(void)
return
g_quark_from_static_string
(
"inotify"
);
return
g_quark_from_static_string
(
"inotify"
);
}
}
void
bool
InotifySource
::
OnSocketReady
(
gcc_unused
unsigned
flags
)
InotifySource
::
OnSocketReady
(
gcc_unused
unsigned
flags
)
{
{
void
*
dest
;
void
*
dest
;
...
@@ -79,6 +79,8 @@ InotifySource::OnSocketReady(gcc_unused unsigned flags)
...
@@ -79,6 +79,8 @@ InotifySource::OnSocketReady(gcc_unused unsigned flags)
callback
(
event
->
wd
,
event
->
mask
,
name
,
callback_ctx
);
callback
(
event
->
wd
,
event
->
mask
,
name
,
callback_ctx
);
fifo_buffer_consume
(
buffer
,
sizeof
(
*
event
)
+
event
->
len
);
fifo_buffer_consume
(
buffer
,
sizeof
(
*
event
)
+
event
->
len
);
}
}
return
true
;
}
}
inline
inline
...
...
src/InotifySource.hxx
View file @
4ad74564
...
@@ -68,7 +68,7 @@ public:
...
@@ -68,7 +68,7 @@ public:
void
Remove
(
unsigned
wd
);
void
Remove
(
unsigned
wd
);
private
:
private
:
virtual
void
OnSocketReady
(
unsigned
flags
)
override
;
virtual
bool
OnSocketReady
(
unsigned
flags
)
override
;
};
};
#endif
#endif
src/ServerSocket.cxx
View file @
4ad74564
...
@@ -101,7 +101,7 @@ struct OneServerSocket final : private SocketMonitor {
...
@@ -101,7 +101,7 @@ struct OneServerSocket final : private SocketMonitor {
void
Accept
();
void
Accept
();
private
:
private
:
virtual
void
OnSocketReady
(
unsigned
flags
)
override
;
virtual
bool
OnSocketReady
(
unsigned
flags
)
override
;
};
};
struct
server_socket
{
struct
server_socket
{
...
@@ -205,10 +205,11 @@ OneServerSocket::Accept()
...
@@ -205,10 +205,11 @@ OneServerSocket::Accept()
parent
.
callback_ctx
);
parent
.
callback_ctx
);
}
}
void
bool
OneServerSocket
::
OnSocketReady
(
gcc_unused
unsigned
flags
)
OneServerSocket
::
OnSocketReady
(
gcc_unused
unsigned
flags
)
{
{
Accept
();
Accept
();
return
true
;
}
}
inline
bool
inline
bool
...
...
src/event/BufferedSocket.cxx
View file @
4ad74564
...
@@ -202,21 +202,21 @@ BufferedSocket::ConsumeInput(size_t nbytes)
...
@@ -202,21 +202,21 @@ BufferedSocket::ConsumeInput(size_t nbytes)
fifo_buffer_consume
(
input
,
nbytes
);
fifo_buffer_consume
(
input
,
nbytes
);
}
}
void
bool
BufferedSocket
::
OnSocketReady
(
unsigned
flags
)
BufferedSocket
::
OnSocketReady
(
unsigned
flags
)
{
{
assert
(
IsDefined
());
assert
(
IsDefined
());
if
(
gcc_unlikely
(
flags
&
(
ERROR
|
HANGUP
)))
{
if
(
gcc_unlikely
(
flags
&
(
ERROR
|
HANGUP
)))
{
OnSocketClosed
();
OnSocketClosed
();
return
;
return
false
;
}
}
if
(
flags
&
READ
)
{
if
(
flags
&
READ
)
{
assert
(
input
==
nullptr
||
!
fifo_buffer_is_full
(
input
));
assert
(
input
==
nullptr
||
!
fifo_buffer_is_full
(
input
));
if
(
!
ReadToBuffer
()
||
!
ResumeInput
())
if
(
!
ReadToBuffer
()
||
!
ResumeInput
())
return
;
return
false
;
if
(
input
==
nullptr
||
!
fifo_buffer_is_full
(
input
))
if
(
input
==
nullptr
||
!
fifo_buffer_is_full
(
input
))
ScheduleRead
();
ScheduleRead
();
...
@@ -233,6 +233,8 @@ BufferedSocket::OnSocketReady(unsigned flags)
...
@@ -233,6 +233,8 @@ BufferedSocket::OnSocketReady(unsigned flags)
assert
(
!
output
.
IsEmpty
());
assert
(
!
output
.
IsEmpty
());
if
(
!
WriteFromBuffer
())
if
(
!
WriteFromBuffer
())
return
;
return
false
;
}
}
return
true
;
}
}
src/event/BufferedSocket.hxx
View file @
4ad74564
...
@@ -113,7 +113,7 @@ protected:
...
@@ -113,7 +113,7 @@ protected:
virtual
void
OnSocketClosed
()
=
0
;
virtual
void
OnSocketClosed
()
=
0
;
private
:
private
:
virtual
void
OnSocketReady
(
unsigned
flags
)
override
;
virtual
bool
OnSocketReady
(
unsigned
flags
)
override
;
};
};
#endif
#endif
src/event/SocketMonitor.hxx
View file @
4ad74564
...
@@ -115,7 +115,10 @@ public:
...
@@ -115,7 +115,10 @@ public:
ssize_t
Write
(
const
void
*
data
,
size_t
length
);
ssize_t
Write
(
const
void
*
data
,
size_t
length
);
protected
:
protected
:
virtual
void
OnSocketReady
(
unsigned
flags
)
=
0
;
/**
* @return false if the socket has been closed
*/
virtual
bool
OnSocketReady
(
unsigned
flags
)
=
0
;
public
:
public
:
/* GSource callbacks */
/* GSource callbacks */
...
...
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