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
76b217f7
Commit
76b217f7
authored
Jan 30, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: check for G_IO_ERR and G_IO_HUP
When we do not explicitly catch G_IO_ERR and G_IO_HUP, GLib can go into an infinite loop, because it won't deliver the socket error to MPD.
parent
c38dd9e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
client.c
src/client.c
+19
-8
No files found.
src/client.c
View file @
76b217f7
...
...
@@ -191,7 +191,8 @@ static void client_init(struct client *client, int fd)
/* we prefer to do buffering */
g_io_channel_set_buffered
(
client
->
channel
,
false
);
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
|
G_IO_ERR
|
G_IO_HUP
,
client_in_event
,
client
);
client
->
lastTime
=
time
(
NULL
);
...
...
@@ -498,13 +499,12 @@ static int client_read(struct client *client)
}
static
gboolean
client_out_event
(
G_GNUC_UNUSED
GIOChannel
*
source
,
G_GNUC_UNUSED
GIOCondition
condition
,
client_out_event
(
G_GNUC_UNUSED
GIOChannel
*
source
,
GIOCondition
condition
,
gpointer
data
);
static
gboolean
client_in_event
(
G_GNUC_UNUSED
GIOChannel
*
source
,
G
_GNUC_UNUSED
G
IOCondition
condition
,
GIOCondition
condition
,
gpointer
data
)
{
struct
client
*
client
=
data
;
...
...
@@ -512,6 +512,11 @@ client_in_event(G_GNUC_UNUSED GIOChannel *source,
assert
(
!
client_is_expired
(
client
));
if
(
condition
!=
G_IO_IN
)
{
client_set_expired
(
client
);
return
false
;
}
client
->
lastTime
=
time
(
NULL
);
ret
=
client_read
(
client
);
...
...
@@ -533,7 +538,8 @@ client_in_event(G_GNUC_UNUSED GIOChannel *source,
if
(
!
g_queue_is_empty
(
client
->
deferred_send
))
{
/* deferred buffers exist: schedule write */
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_OUT
,
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_OUT
|
G_IO_ERR
|
G_IO_HUP
,
client_out_event
,
client
);
return
false
;
}
...
...
@@ -543,14 +549,18 @@ client_in_event(G_GNUC_UNUSED GIOChannel *source,
}
static
gboolean
client_out_event
(
G_GNUC_UNUSED
GIOChannel
*
source
,
G_GNUC_UNUSED
GIOCondition
condition
,
client_out_event
(
G_GNUC_UNUSED
GIOChannel
*
source
,
GIOCondition
condition
,
gpointer
data
)
{
struct
client
*
client
=
data
;
assert
(
!
client_is_expired
(
client
));
if
(
condition
!=
G_IO_OUT
)
{
client_set_expired
(
client
);
return
false
;
}
client_write_deferred
(
client
);
if
(
client_is_expired
(
client
))
{
...
...
@@ -563,7 +573,8 @@ client_out_event(G_GNUC_UNUSED GIOChannel *source,
if
(
g_queue_is_empty
(
client
->
deferred_send
))
{
/* done sending deferred buffers exist: schedule
read */
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
|
G_IO_ERR
|
G_IO_HUP
,
client_in_event
,
client
);
return
false
;
}
...
...
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