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
eab1a71d
Commit
eab1a71d
authored
Aug 27, 2014
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keepalive timer fix
Bug: 442683
parent
2c969cfa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
9 deletions
+21
-9
Clients.h
src/Clients.h
+2
-1
MQTTAsync.c
src/MQTTAsync.c
+7
-2
MQTTClient.c
src/MQTTClient.c
+4
-2
MQTTPacket.c
src/MQTTPacket.c
+4
-2
MQTTProtocolClient.c
src/MQTTProtocolClient.c
+4
-2
No files found.
src/Clients.h
View file @
eab1a71d
...
...
@@ -149,7 +149,8 @@ BE*/
typedef
struct
{
int
socket
;
time_t
lastContact
;
time_t
lastSent
;
time_t
lastReceived
;
#if defined(OPENSSL)
SSL
*
ssl
;
SSL_CTX
*
ctx
;
...
...
src/MQTTAsync.c
View file @
eab1a71d
...
...
@@ -886,7 +886,7 @@ void MQTTAsync_writeComplete(int socket)
{
MQTTAsyncs
*
m
=
(
MQTTAsyncs
*
)(
found
->
content
);
time
(
&
(
m
->
c
->
net
.
last
Contac
t
));
time
(
&
(
m
->
c
->
net
.
last
Sen
t
));
/* see if there is a pending write flagged */
if
(
m
->
pending_write
)
...
...
@@ -1428,13 +1428,16 @@ int MQTTAsync_completeConnection(MQTTAsyncs* m, MQTTPacket* pack)
rc
=
MQTTAsync_cleanSession
(
m
->
c
);
if
(
m
->
c
->
outboundMsgs
->
count
>
0
)
{
time_t
now
;
ListElement
*
outcurrent
=
NULL
;
while
(
ListNextElement
(
m
->
c
->
outboundMsgs
,
&
outcurrent
))
{
Messages
*
m
=
(
Messages
*
)(
outcurrent
->
content
);
m
->
lastTouch
=
0
;
}
MQTTProtocol_retry
(
m
->
c
->
net
.
lastContact
,
1
);
time
(
&
(
now
));
MQTTProtocol_retry
(
now
,
1
);
if
(
m
->
c
->
connected
!=
1
)
rc
=
MQTTASYNC_DISCONNECTED
;
}
...
...
@@ -2533,11 +2536,13 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
if
(
!
tostop
&&
*
sock
==
0
&&
(
tp
.
tv_sec
>
0L
||
tp
.
tv_usec
>
0L
))
{
MQTTAsync_sleep
(
100L
);
#if 0
if (s.clientsds->count == 0)
{
if (++nosockets_count == 50) /* 5 seconds with no sockets */
tostop = 1;
}
#endif
}
else
nosockets_count
=
0
;
...
...
src/MQTTClient.c
View file @
eab1a71d
...
...
@@ -896,6 +896,7 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o
rc
=
MQTTClient_cleanSession
(
m
->
c
);
if
(
m
->
c
->
outboundMsgs
->
count
>
0
)
{
time_t
now
;
ListElement
*
outcurrent
=
NULL
;
while
(
ListNextElement
(
m
->
c
->
outboundMsgs
,
&
outcurrent
))
...
...
@@ -903,7 +904,8 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o
Messages
*
m
=
(
Messages
*
)(
outcurrent
->
content
);
m
->
lastTouch
=
0
;
}
MQTTProtocol_retry
(
m
->
c
->
net
.
lastContact
,
1
);
time
(
&
(
now
));
MQTTProtocol_retry
(
now
,
1
);
if
(
m
->
c
->
connected
!=
1
)
rc
=
MQTTCLIENT_DISCONNECTED
;
}
...
...
@@ -1957,7 +1959,7 @@ void MQTTClient_writeComplete(int socket)
{
MQTTClients
*
m
=
(
MQTTClients
*
)(
found
->
content
);
time
(
&
(
m
->
c
->
net
.
last
Contact
));
time
(
&
(
m
->
c
->
net
.
last
Sent
));
}
FUNC_EXIT
;
}
src/MQTTPacket.c
View file @
eab1a71d
...
...
@@ -156,6 +156,8 @@ void* MQTTPacket_Factory(networkHandles* net, int* error)
#endif
}
}
if
(
pack
)
time
(
&
(
net
->
lastReceived
));
exit:
FUNC_EXIT_RC
(
*
error
);
return
pack
;
...
...
@@ -197,7 +199,7 @@ int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buf
rc
=
Socket_putdatas
(
net
->
socket
,
buf
,
buf0len
,
1
,
&
buffer
,
&
buflen
,
&
free
);
if
(
rc
==
TCPSOCKET_COMPLETE
)
time
(
&
(
net
->
last
Contac
t
));
time
(
&
(
net
->
last
Sen
t
));
if
(
rc
!=
TCPSOCKET_INTERRUPTED
)
free
(
buf
);
...
...
@@ -244,7 +246,7 @@ int MQTTPacket_sends(networkHandles* net, Header header, int count, char** buffe
rc
=
Socket_putdatas
(
net
->
socket
,
buf
,
buf0len
,
count
,
buffers
,
buflens
,
frees
);
if
(
rc
==
TCPSOCKET_COMPLETE
)
time
(
&
(
net
->
last
Contac
t
));
time
(
&
(
net
->
last
Sen
t
));
if
(
rc
!=
TCPSOCKET_INTERRUPTED
)
free
(
buf
);
...
...
src/MQTTProtocolClient.c
View file @
eab1a71d
...
...
@@ -514,7 +514,9 @@ void MQTTProtocol_keepalive(time_t now)
{
Clients
*
client
=
(
Clients
*
)(
current
->
content
);
ListNextElement
(
bstate
->
clients
,
&
current
);
if
(
client
->
connected
&&
client
->
keepAliveInterval
>
0
&&
(
difftime
(
now
,
client
->
net
.
lastContact
)
>=
client
->
keepAliveInterval
))
if
(
client
->
connected
&&
client
->
keepAliveInterval
>
0
&&
(
difftime
(
now
,
client
->
net
.
lastSent
)
>=
client
->
keepAliveInterval
||
difftime
(
now
,
client
->
net
.
lastReceived
)
>=
client
->
keepAliveInterval
))
{
if
(
client
->
ping_outstanding
==
0
)
{
...
...
@@ -527,7 +529,7 @@ void MQTTProtocol_keepalive(time_t now)
}
else
{
client
->
net
.
last
Contac
t
=
now
;
client
->
net
.
last
Sen
t
=
now
;
client
->
ping_outstanding
=
1
;
}
}
...
...
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