Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
8dce6c13
Commit
8dce6c13
authored
Jan 03, 2014
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Fix racy destruction of pseudotcp object
parent
be7682bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
tests/test-pseudotcp.c
tests/test-pseudotcp.c
+14
-12
No files found.
tests/test-pseudotcp.c
View file @
8dce6c13
...
...
@@ -52,6 +52,8 @@ int total_read = 0;
int
total_wrote
=
0
;
guint
left_clock
=
0
;
guint
right_clock
=
0
;
gboolean
left_closed
;
gboolean
right_closed
;
static
void
adjust_clock
(
PseudoTcpSocket
*
sock
);
...
...
@@ -160,8 +162,7 @@ struct notify_data {
static
gboolean
notify_packet
(
gpointer
user_data
)
{
struct
notify_data
*
data
=
(
struct
notify_data
*
)
user_data
;
if
(
!
data
->
sock
||
(
data
->
sock
!=
left
&&
data
->
sock
!=
right
))
return
FALSE
;
pseudo_tcp_socket_notify_packet
(
data
->
sock
,
data
->
buffer
,
data
->
len
);
adjust_clock
(
data
->
sock
);
...
...
@@ -189,11 +190,10 @@ static PseudoTcpWriteResult write (PseudoTcpSocket *sock,
memcpy
(
data
->
buffer
,
buffer
,
len
);
data
->
len
=
len
;
if
(
sock
==
left
)
{
if
(
sock
==
left
)
data
->
sock
=
right
;
}
else
{
else
data
->
sock
=
left
;
}
g_idle_add
(
notify_packet
,
data
);
...
...
@@ -204,8 +204,6 @@ static PseudoTcpWriteResult write (PseudoTcpSocket *sock,
static
gboolean
notify_clock
(
gpointer
data
)
{
PseudoTcpSocket
*
sock
=
(
PseudoTcpSocket
*
)
data
;
if
(
sock
!=
left
&&
sock
!=
right
)
return
FALSE
;
//g_debug ("Socket %p: Notifying clock", sock);
pseudo_tcp_socket_notify_clock
(
sock
);
adjust_clock
(
sock
);
...
...
@@ -227,13 +225,12 @@ static void adjust_clock (PseudoTcpSocket *sock)
right_clock
=
g_timeout_add
(
timeout
,
notify_clock
,
sock
);
}
}
else
{
g_debug
(
"Socket %p should be destroyed"
,
sock
);
g_object_unref
(
sock
);
g_debug
(
"Socket %p should be destroyed, it's done"
,
sock
);
if
(
sock
==
left
)
left
=
NULL
;
left
_closed
=
TRUE
;
else
right
=
NULL
;
if
(
left
==
right
)
right
_closed
=
TRUE
;
if
(
left
_closed
&&
right_closed
)
g_main_loop_quit
(
mainloop
);
}
}
...
...
@@ -249,6 +246,8 @@ int main (int argc, char *argv[])
pseudo_tcp_set_debug_level
(
PSEUDO_TCP_DEBUG_VERBOSE
);
left_closed
=
right_closed
=
FALSE
;
left
=
pseudo_tcp_socket_new
(
0
,
&
cbs
);
right
=
pseudo_tcp_socket_new
(
0
,
&
cbs
);
g_debug
(
"Left: %p. Right: %p"
,
left
,
right
);
...
...
@@ -267,6 +266,9 @@ int main (int argc, char *argv[])
g_main_loop_run
(
mainloop
);
g_object_unref
(
left
);
g_object_unref
(
right
);
if
(
in
)
fclose
(
in
);
if
(
out
)
...
...
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