Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
paho.mqtt.c
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eclipse
paho.mqtt.c
Commits
05641d82
Commit
05641d82
authored
May 04, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce keepalive check interval for low keepalive values #156
parent
b82797a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
MQTTAsync.c
src/MQTTAsync.c
+17
-1
MQTTClient.c
src/MQTTClient.c
+17
-2
No files found.
src/MQTTAsync.c
View file @
05641d82
...
...
@@ -2154,6 +2154,21 @@ void Protocol_processPublication(Publish* publish, Clients* client)
}
static
int
retryLoopInterval
=
5
;
static
void
setRetryLoopInterval
(
int
keepalive
)
{
int
proposed
=
keepalive
/
10
;
if
(
proposed
<
1
)
proposed
=
1
;
else
if
(
proposed
>
5
)
proposed
=
5
;
if
(
proposed
<
retryLoopInterval
)
retryLoopInterval
=
proposed
;
}
int
MQTTAsync_connect
(
MQTTAsync
handle
,
const
MQTTAsync_connectOptions
*
options
)
{
MQTTAsyncs
*
m
=
handle
;
...
...
@@ -2222,6 +2237,7 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
}
m
->
c
->
keepAliveInterval
=
options
->
keepAliveInterval
;
setRetryLoopInterval
(
options
->
keepAliveInterval
);
m
->
c
->
cleansession
=
options
->
cleansession
;
m
->
c
->
maxInflightMessages
=
options
->
maxInflight
;
if
(
options
->
struct_version
>=
3
)
...
...
@@ -2736,7 +2752,7 @@ static void MQTTAsync_retry(void)
FUNC_ENTRY
;
time
(
&
(
now
));
if
(
difftime
(
now
,
last
)
>
5
)
if
(
difftime
(
now
,
last
)
>
retryLoopInterval
)
{
time
(
&
(
last
));
MQTTProtocol_keepalive
(
now
);
...
...
src/MQTTClient.c
View file @
05641d82
...
...
@@ -167,7 +167,6 @@ void MQTTClient_init(void)
static
volatile
int
initialized
=
0
;
static
List
*
handles
=
NULL
;
static
time_t
last
;
static
int
running
=
0
;
static
int
tostop
=
0
;
static
thread_id_type
run_id
=
0
;
...
...
@@ -1007,6 +1006,20 @@ exit:
return
rc
;
}
static
int
retryLoopInterval
=
5
;
static
void
setRetryLoopInterval
(
int
keepalive
)
{
int
proposed
=
keepalive
/
10
;
if
(
proposed
<
1
)
proposed
=
1
;
else
if
(
proposed
>
5
)
proposed
=
5
;
if
(
proposed
<
retryLoopInterval
)
retryLoopInterval
=
proposed
;
}
static
int
MQTTClient_connectURI
(
MQTTClient
handle
,
MQTTClient_connectOptions
*
options
,
const
char
*
serverURI
)
{
...
...
@@ -1021,6 +1034,7 @@ static int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* o
start
=
MQTTClient_start_clock
();
m
->
c
->
keepAliveInterval
=
options
->
keepAliveInterval
;
setRetryLoopInterval
(
options
->
keepAliveInterval
);
m
->
c
->
cleansession
=
options
->
cleansession
;
m
->
c
->
maxInflightMessages
=
(
options
->
reliable
)
?
1
:
10
;
...
...
@@ -1625,11 +1639,12 @@ exit:
static
void
MQTTClient_retry
(
void
)
{
static
time_t
last
=
0L
;
time_t
now
;
FUNC_ENTRY
;
time
(
&
(
now
));
if
(
difftime
(
now
,
last
)
>
5
)
if
(
difftime
(
now
,
last
)
>
retryLoopInterval
)
{
time
(
&
(
last
));
MQTTProtocol_keepalive
(
now
);
...
...
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