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
2cdfd938
Commit
2cdfd938
authored
Dec 31, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: remember GLib source id
Remove the event source from the GMainLoop object in client_set_expired().
parent
d196ffdf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
client.c
src/client.c
+12
-7
No files found.
src/client.c
View file @
2cdfd938
...
@@ -79,6 +79,7 @@ struct client {
...
@@ -79,6 +79,7 @@ struct client {
int
fd
;
/* file descriptor; -1 if expired */
int
fd
;
/* file descriptor; -1 if expired */
GIOChannel
*
channel
;
GIOChannel
*
channel
;
guint
source_id
;
unsigned
permission
;
unsigned
permission
;
...
@@ -136,6 +137,11 @@ void client_set_permission(struct client *client, unsigned permission)
...
@@ -136,6 +137,11 @@ void client_set_permission(struct client *client, unsigned permission)
static
inline
void
client_set_expired
(
struct
client
*
client
)
static
inline
void
client_set_expired
(
struct
client
*
client
)
{
{
if
(
client
->
source_id
!=
0
)
{
g_source_remove
(
client
->
source_id
);
client
->
source_id
=
0
;
}
if
(
client
->
channel
!=
NULL
)
{
if
(
client
->
channel
!=
NULL
)
{
g_io_channel_unref
(
client
->
channel
);
g_io_channel_unref
(
client
->
channel
);
client
->
channel
=
NULL
;
client
->
channel
=
NULL
;
...
@@ -164,7 +170,8 @@ static void client_init(struct client *client, int fd)
...
@@ -164,7 +170,8 @@ static void client_init(struct client *client, int fd)
set_nonblocking
(
fd
);
set_nonblocking
(
fd
);
client
->
channel
=
g_io_channel_unix_new
(
client
->
fd
);
client
->
channel
=
g_io_channel_unix_new
(
client
->
fd
);
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
client_in_event
,
client
);
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
client_in_event
,
client
);
client
->
lastTime
=
time
(
NULL
);
client
->
lastTime
=
time
(
NULL
);
client
->
cmd_list
=
NULL
;
client
->
cmd_list
=
NULL
;
...
@@ -463,8 +470,7 @@ client_in_event(G_GNUC_UNUSED GIOChannel *source,
...
@@ -463,8 +470,7 @@ client_in_event(G_GNUC_UNUSED GIOChannel *source,
struct
client
*
client
=
data
;
struct
client
*
client
=
data
;
int
ret
;
int
ret
;
if
(
client_is_expired
(
client
))
assert
(
!
client_is_expired
(
client
));
return
false
;
client
->
lastTime
=
time
(
NULL
);
client
->
lastTime
=
time
(
NULL
);
...
@@ -487,7 +493,7 @@ client_in_event(G_GNUC_UNUSED GIOChannel *source,
...
@@ -487,7 +493,7 @@ client_in_event(G_GNUC_UNUSED GIOChannel *source,
if
(
!
g_queue_is_empty
(
client
->
deferred_send
))
{
if
(
!
g_queue_is_empty
(
client
->
deferred_send
))
{
/* deferred buffers exist: schedule write */
/* deferred buffers exist: schedule write */
g_io_add_watch
(
client
->
channel
,
G_IO_OUT
,
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_OUT
,
client_out_event
,
client
);
client_out_event
,
client
);
return
false
;
return
false
;
}
}
...
@@ -503,8 +509,7 @@ client_out_event(G_GNUC_UNUSED GIOChannel *source,
...
@@ -503,8 +509,7 @@ client_out_event(G_GNUC_UNUSED GIOChannel *source,
{
{
struct
client
*
client
=
data
;
struct
client
*
client
=
data
;
if
(
client_is_expired
(
client
))
assert
(
!
client_is_expired
(
client
));
return
false
;
client_write_deferred
(
client
);
client_write_deferred
(
client
);
...
@@ -518,7 +523,7 @@ client_out_event(G_GNUC_UNUSED GIOChannel *source,
...
@@ -518,7 +523,7 @@ client_out_event(G_GNUC_UNUSED GIOChannel *source,
if
(
g_queue_is_empty
(
client
->
deferred_send
))
{
if
(
g_queue_is_empty
(
client
->
deferred_send
))
{
/* done sending deferred buffers exist: schedule
/* done sending deferred buffers exist: schedule
read */
read */
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
client_in_event
,
client
);
client_in_event
,
client
);
return
false
;
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