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
c16b2d17
Commit
c16b2d17
authored
Dec 10, 2019
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove GTimeVal as it is deprecated in GLib
parent
6a6b4f4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
48 deletions
+23
-48
agent/conncheck.c
agent/conncheck.c
+16
-30
agent/conncheck.h
agent/conncheck.h
+1
-1
agent/discovery.c
agent/discovery.c
+5
-16
agent/discovery.h
agent/discovery.h
+1
-1
No files found.
agent/conncheck.c
View file @
c16b2d17
...
...
@@ -80,22 +80,12 @@ static CandidateCheckPair *priv_conn_check_add_for_candidate_pair_matched (
static
gboolean
priv_update_selected_pair
(
NiceAgent
*
agent
,
NiceComponent
*
component
,
CandidateCheckPair
*
pair
);
static
int
priv_timer_expired
(
GTimeVal
*
timer
,
GTimeVal
*
now
)
static
gint64
priv_timer_remainder
(
gint64
timer
,
gint64
now
)
{
return
(
now
->
tv_sec
==
timer
->
tv_sec
)
?
now
->
tv_usec
>=
timer
->
tv_usec
:
now
->
tv_sec
>=
timer
->
tv_sec
;
}
static
unsigned
int
priv_timer_remainder
(
GTimeVal
*
timer
,
GTimeVal
*
now
)
{
unsigned
int
delay
;
if
(
now
->
tv_sec
>
timer
->
tv_sec
||
(
now
->
tv_sec
==
timer
->
tv_sec
&&
now
->
tv_usec
>
timer
->
tv_usec
))
if
(
now
>=
timer
)
return
0
;
delay
=
(
timer
->
tv_sec
-
now
->
tv_sec
)
*
1000
;
delay
+=
((
signed
long
)(
timer
->
tv_usec
-
now
->
tv_usec
))
/
1000
;
return
delay
;
return
timer
-
now
;
}
static
gchar
...
...
@@ -270,12 +260,12 @@ priv_print_conn_check_lists (NiceAgent *agent, const gchar *where, const gchar *
{
GSList
*
i
,
*
k
,
*
l
;
guint
j
,
m
;
GTimeVal
now
;
gint64
now
;
if
(
!
nice_debug_is_verbose
())
return
;
g_get_current_time
(
&
now
);
now
=
g_get_monotonic_time
(
);
#define PRIORITY_LEN 32
...
...
@@ -314,10 +304,10 @@ priv_print_conn_check_lists (NiceAgent *agent, const gchar *where, const gchar *
for
(
l
=
pair
->
stun_transactions
,
m
=
0
;
l
;
l
=
l
->
next
,
m
++
)
{
StunTransaction
*
stun
=
l
->
data
;
nice_debug
(
"Agent %p : *** sc=%d/%d : pair %p : "
"stun#=%d timer=%d/%d %
d
/%dms buf=%p %s"
,
"stun#=%d timer=%d/%d %
"
G_GINT64_FORMAT
"
/%dms buf=%p %s"
,
agent
,
pair
->
stream_id
,
pair
->
component_id
,
pair
,
m
,
stun
->
timer
.
retransmissions
,
stun
->
timer
.
max_retransmissions
,
stun
->
timer
.
delay
-
priv_timer_remainder
(
&
stun
->
next_tick
,
&
now
),
stun
->
timer
.
delay
-
priv_timer_remainder
(
stun
->
next_tick
,
now
),
stun
->
timer
.
delay
,
stun
->
message
.
buffer
,
(
m
==
0
&&
pair
->
retransmit
)
?
"(R)"
:
""
);
...
...
@@ -772,9 +762,9 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen
GSList
*
i
,
*
j
;
CandidateCheckPair
*
pair
;
unsigned
int
timeout
;
GTimeVal
now
;
gint64
now
;
g_get_current_time
(
&
now
);
now
=
g_get_monotonic_time
(
);
/* step: process ongoing STUN transactions */
for
(
i
=
stream
->
conncheck_list
;
i
;
i
=
i
->
next
)
{
...
...
@@ -802,15 +792,14 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen
StunTransaction
*
s
=
j
->
data
;
GSList
*
next
=
j
->
next
;
if
(
priv_timer_expired
(
&
s
->
next_tick
,
&
now
)
)
if
(
now
>=
s
->
next_tick
)
switch
(
stun_timer_refresh
(
&
s
->
timer
))
{
case
STUN_USAGE_TIMER_RETURN_TIMEOUT
:
priv_remove_stun_transaction
(
p
,
s
,
component
);
break
;
case
STUN_USAGE_TIMER_RETURN_RETRANSMIT
:
timeout
=
stun_timer_remainder
(
&
s
->
timer
);
s
->
next_tick
=
now
;
g_time_val_add
(
&
s
->
next_tick
,
timeout
*
1000
);
s
->
next_tick
=
now
+
timeout
*
1000
;
break
;
default:
break
;
...
...
@@ -823,7 +812,7 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen
/* process the first stun transaction of the list */
stun
=
p
->
stun_transactions
->
data
;
if
(
!
priv_timer_expired
(
&
stun
->
next_tick
,
&
now
)
)
if
(
now
<
stun
->
next_tick
)
continue
;
switch
(
stun_timer_refresh
(
&
stun
->
timer
))
{
...
...
@@ -871,16 +860,14 @@ timer_return_timeout:
(
gchar
*
)
stun
->
buffer
);
/* note: convert from milli to microseconds for g_time_val_add() */
stun
->
next_tick
=
now
;
g_time_val_add
(
&
stun
->
next_tick
,
timeout
*
1000
);
stun
->
next_tick
=
now
+
timeout
*
1000
;
return
TRUE
;
case
STUN_USAGE_TIMER_RETURN_SUCCESS
:
timeout
=
stun_timer_remainder
(
&
stun
->
timer
);
/* note: convert from milli to microseconds for g_time_val_add() */
stun
->
next_tick
=
now
;
g_time_val_add
(
&
stun
->
next_tick
,
timeout
*
1000
);
stun
->
next_tick
=
now
+
timeout
*
1000
;
keep_timer_going
=
TRUE
;
break
;
...
...
@@ -2941,8 +2928,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
stun_timer_start
(
&
stun
->
timer
,
timeout
,
agent
->
stun_max_retransmissions
);
}
g_get_current_time
(
&
stun
->
next_tick
);
g_time_val_add
(
&
stun
->
next_tick
,
timeout
*
1000
);
stun
->
next_tick
=
g_get_monotonic_time
()
+
timeout
*
1000
;
/* TCP-ACTIVE candidate must create a new socket before sending
* by connecting to the peer. The new socket is stored in the candidate
...
...
agent/conncheck.h
View file @
c16b2d17
...
...
@@ -75,7 +75,7 @@ typedef struct _StunTransaction StunTransaction;
struct
_StunTransaction
{
GTimeVal
next_tick
;
/* next tick timestamp */
gint64
next_tick
;
/* next tick timestamp */
StunTimer
timer
;
uint8_t
buffer
[
STUN_MAX_MESSAGE_SIZE_IPV6
];
StunMessage
message
;
...
...
agent/discovery.c
View file @
c16b2d17
...
...
@@ -61,13 +61,6 @@
#include "stun/usages/turn.h"
#include "socket.h"
static
inline
int
priv_timer_expired
(
GTimeVal
*
timer
,
GTimeVal
*
now
)
{
return
(
now
->
tv_sec
==
timer
->
tv_sec
)
?
now
->
tv_usec
>=
timer
->
tv_usec
:
now
->
tv_sec
>=
timer
->
tv_sec
;
}
/*
* Frees the CandidateDiscovery structure pointed to
* by 'user data'. Compatible with g_slist_free_full().
...
...
@@ -1172,7 +1165,7 @@ static gboolean priv_discovery_tick_unlocked (NiceAgent *agent)
agent
->
stun_max_retransmissions
);
}
g_get_current_time
(
&
cand
->
next_tick
);
cand
->
next_tick
=
g_get_monotonic_time
(
);
}
else
{
/* case: error in starting discovery, start the next discovery */
nice_debug
(
"Agent %p : Error starting discovery, skipping the item."
,
...
...
@@ -1191,15 +1184,13 @@ static gboolean priv_discovery_tick_unlocked (NiceAgent *agent)
}
if
(
cand
->
done
!=
TRUE
)
{
GTimeVal
now
;
g_get_current_time
(
&
now
);
gint64
now
=
g_get_monotonic_time
();
if
(
cand
->
stun_message
.
buffer
==
NULL
)
{
nice_debug
(
"Agent %p : STUN discovery was cancelled, marking discovery done."
,
agent
);
cand
->
done
=
TRUE
;
}
else
if
(
priv_timer_expired
(
&
cand
->
next_tick
,
&
now
)
)
{
else
if
(
now
>=
cand
->
next_tick
)
{
switch
(
stun_timer_refresh
(
&
cand
->
timer
))
{
case
STUN_USAGE_TIMER_RETURN_TIMEOUT
:
{
...
...
@@ -1230,8 +1221,7 @@ static gboolean priv_discovery_tick_unlocked (NiceAgent *agent)
(
gchar
*
)
cand
->
stun_buffer
);
/* note: convert from milli to microseconds for g_time_val_add() */
cand
->
next_tick
=
now
;
g_time_val_add
(
&
cand
->
next_tick
,
timeout
*
1000
);
cand
->
next_tick
=
now
+
(
timeout
*
1000
);
++
not_done
;
/* note: retry later */
break
;
...
...
@@ -1240,8 +1230,7 @@ static gboolean priv_discovery_tick_unlocked (NiceAgent *agent)
{
unsigned
int
timeout
=
stun_timer_remainder
(
&
cand
->
timer
);
cand
->
next_tick
=
now
;
g_time_val_add
(
&
cand
->
next_tick
,
timeout
*
1000
);
cand
->
next_tick
=
now
+
(
timeout
*
1000
);
++
not_done
;
/* note: retry later */
break
;
...
...
agent/discovery.h
View file @
c16b2d17
...
...
@@ -49,7 +49,7 @@ typedef struct
NiceCandidateType
type
;
/* candidate type STUN or TURN */
NiceSocket
*
nicesock
;
/* XXX: should be taken from local cand: existing socket to use */
NiceAddress
server
;
/* STUN/TURN server address */
GTimeVal
next_tick
;
/* next tick timestamp */
gint64
next_tick
;
/* next tick timestamp */
gboolean
pending
;
/* is discovery in progress? */
gboolean
done
;
/* is discovery complete? */
guint
stream_id
;
...
...
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