Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
fb09e1a7
Unverified
Commit
fb09e1a7
authored
5 years ago
by
Sébastien Blin
Browse files
Options
Downloads
Patches
Plain Diff
upnp: remove restartTimers_
Change-Id: I41fc348e6bcc2a0e042fe9355cb86288065300d4
parent
1f9c191b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/upnp/protocol/natpmp/nat_pmp.cpp
+7
-7
7 additions, 7 deletions
src/upnp/protocol/natpmp/nat_pmp.cpp
src/upnp/protocol/natpmp/nat_pmp.h
+0
-1
0 additions, 1 deletion
src/upnp/protocol/natpmp/nat_pmp.h
with
7 additions
and
8 deletions
src/upnp/protocol/natpmp/nat_pmp.cpp
+
7
−
7
View file @
fb09e1a7
...
@@ -67,11 +67,8 @@ NatPmp::NatPmp()
...
@@ -67,11 +67,8 @@ NatPmp::NatPmp()
or
restart_
;
or
restart_
;
});
});
if
(
not
pmpRun_
or
not
pmpIGD_
)
break
;
if
(
not
pmpRun_
or
not
pmpIGD_
)
break
;
auto
now
=
clock
::
now
();
if
(
restart_
)
{
std
::
lock_guard
<
std
::
mutex
>
lkNat
(
natpmpMutex_
);
// If the restart flag is set, wait for 1 second to have passed by to try and reinitialize natpmp.
if
(
restart_
and
(
now
-
restartTimer_
>=
std
::
chrono
::
seconds
(
1
)))
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
natpmpMutex_
);
clearNatPmpHdl
(
natpmpHdl_
);
clearNatPmpHdl
(
natpmpHdl_
);
int
err
=
0
;
int
err
=
0
;
char
localHostBuf
[
INET_ADDRSTRLEN
];
char
localHostBuf
[
INET_ADDRSTRLEN
];
...
@@ -87,7 +84,10 @@ NatPmp::NatPmp()
...
@@ -87,7 +84,10 @@ NatPmp::NatPmp()
}
}
if
(
err
<
0
)
{
if
(
err
<
0
)
{
JAMI_ERR
(
"NAT-PMP: Can't initialize libnatpmp -> %s"
,
getNatPmpErrorStr
(
err
).
c_str
());
JAMI_ERR
(
"NAT-PMP: Can't initialize libnatpmp -> %s"
,
getNatPmpErrorStr
(
err
).
c_str
());
restartTimer_
=
clock
::
now
();
// Retry to re-init nat pmp in 10 seconds
if
(
pmpRun_
)
pmpCv_
.
wait_for
(
lk
,
std
::
chrono
::
seconds
(
10
));
continue
;
}
else
{
}
else
{
char
addrbuf
[
INET_ADDRSTRLEN
];
char
addrbuf
[
INET_ADDRSTRLEN
];
inet_ntop
(
AF_INET
,
&
natpmpHdl_
.
gateway
,
addrbuf
,
sizeof
(
addrbuf
));
inet_ntop
(
AF_INET
,
&
natpmpHdl_
.
gateway
,
addrbuf
,
sizeof
(
addrbuf
));
...
@@ -98,6 +98,7 @@ NatPmp::NatPmp()
...
@@ -98,6 +98,7 @@ NatPmp::NatPmp()
}
}
// Check if we need to update IGD.
// Check if we need to update IGD.
auto
now
=
clock
::
now
();
if
(
pmpIGD_
->
renewal_
<
now
)
{
if
(
pmpIGD_
->
renewal_
<
now
)
{
lk
.
unlock
();
lk
.
unlock
();
searchForPmpIgd
();
searchForPmpIgd
();
...
@@ -172,7 +173,6 @@ NatPmp::clearIgds()
...
@@ -172,7 +173,6 @@ NatPmp::clearIgds()
std
::
lock_guard
<
std
::
mutex
>
lk
(
validIgdMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lk
(
validIgdMutex_
);
pmpIGD_
.
reset
(
new
PMPIGD
());
pmpIGD_
.
reset
(
new
PMPIGD
());
restart_
=
true
;
restart_
=
true
;
restartTimer_
=
clock
::
now
();
}
}
void
void
...
...
This diff is collapsed.
Click to expand it.
src/upnp/protocol/natpmp/nat_pmp.h
+
0
−
1
View file @
fb09e1a7
...
@@ -95,7 +95,6 @@ private:
...
@@ -95,7 +95,6 @@ private:
std
::
thread
pmpThread_
{};
// NatPmp thread.
std
::
thread
pmpThread_
{};
// NatPmp thread.
std
::
atomic_bool
restart_
{
false
};
// Variable to indicate we need to restart natpmp after a connectivity change.
std
::
atomic_bool
restart_
{
false
};
// Variable to indicate we need to restart natpmp after a connectivity change.
time_point
restartTimer_
{
clock
::
now
()};
// Keeps track of time elapsed since restart was triggered.
unsigned
int
restartSearchRetry_
{
0
};
// Keeps track of number of times we try to find an IGD after a connectivity change.
unsigned
int
restartSearchRetry_
{
0
};
// Keeps track of number of times we try to find an IGD after a connectivity change.
std
::
shared_ptr
<
PMPIGD
>
pmpIGD_
{};
// IGD discovered by NatPmp.
std
::
shared_ptr
<
PMPIGD
>
pmpIGD_
{};
// IGD discovered by NatPmp.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment