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
db037c2d
Commit
db037c2d
authored
Oct 10, 2013
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for all msgids used, bug #416747
parent
76684fcb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
8 deletions
+43
-8
MQTTAsync.h
src/MQTTAsync.h
+4
-0
MQTTProtocolClient.c
src/MQTTProtocolClient.c
+39
-8
No files found.
src/MQTTAsync.h
View file @
db037c2d
...
@@ -140,6 +140,10 @@
...
@@ -140,6 +140,10 @@
* Return code: A qos parameter is not 0, 1 or 2
* Return code: A qos parameter is not 0, 1 or 2
*/
*/
#define MQTTASYNC_BAD_QOS -9
#define MQTTASYNC_BAD_QOS -9
/**
* Return code: All 65535 MQTT msgids are being used
*/
#define MQTTASYNC_NO_MORE_MSGIDS -10
/**
/**
* A handle representing an MQTT client. A valid client handle is available
* A handle representing an MQTT client. A valid client handle is available
...
...
src/MQTTProtocolClient.c
View file @
db037c2d
...
@@ -61,16 +61,28 @@ int messageIDCompare(void* a, void* b)
...
@@ -61,16 +61,28 @@ int messageIDCompare(void* a, void* b)
* Assign a new message id for a client. Make sure it isn't already being used and does
* Assign a new message id for a client. Make sure it isn't already being used and does
* not exceed the maximum.
* not exceed the maximum.
* @param client a client structure
* @param client a client structure
* @return the next message id to use
* @return the next message id to use
, or 0 if none available
*/
*/
int
MQTTProtocol_assignMsgId
(
Clients
*
client
)
int
MQTTProtocol_assignMsgId
(
Clients
*
client
)
{
{
int
start_msgid
=
client
->
msgID
;
int
msgid
=
start_msgid
;
FUNC_ENTRY
;
FUNC_ENTRY
;
client
->
msgID
=
(
client
->
msgID
==
MAX_MSG_ID
)
?
1
:
client
->
msgID
+
1
;
msgid
=
(
msgid
==
MAX_MSG_ID
)
?
1
:
msgid
+
1
;
while
(
ListFindItem
(
client
->
outboundMsgs
,
&
(
client
->
msgID
),
messageIDCompare
)
!=
NULL
)
while
(
ListFindItem
(
client
->
outboundMsgs
,
&
msgid
,
messageIDCompare
)
!=
NULL
)
client
->
msgID
=
(
client
->
msgID
==
MAX_MSG_ID
)
?
1
:
client
->
msgID
+
1
;
{
FUNC_EXIT_RC
(
client
->
msgID
);
msgid
=
(
msgid
==
MAX_MSG_ID
)
?
1
:
msgid
+
1
;
return
client
->
msgID
;
if
(
msgid
==
start_msgid
)
{
/* we've tried them all - none free */
msgid
=
0
;
break
;
}
}
if
(
msgid
!=
0
)
client
->
msgID
=
msgid
;
FUNC_EXIT_RC
(
msgid
);
return
msgid
;
}
}
...
@@ -340,9 +352,17 @@ int MQTTProtocol_handlePubrecs(void* pack, int sock)
...
@@ -340,9 +352,17 @@ int MQTTProtocol_handlePubrecs(void* pack, int sock)
Pubrec
*
pubrec
=
(
Pubrec
*
)
pack
;
Pubrec
*
pubrec
=
(
Pubrec
*
)
pack
;
Clients
*
client
=
NULL
;
Clients
*
client
=
NULL
;
int
rc
=
TCPSOCKET_COMPLETE
;
int
rc
=
TCPSOCKET_COMPLETE
;
ListElement
*
elem
=
NULL
;
FUNC_ENTRY
;
FUNC_ENTRY
;
client
=
(
Clients
*
)(
ListFindItem
(
bstate
->
clients
,
&
sock
,
clientSocketCompare
)
->
content
);
elem
=
ListFindItem
(
bstate
->
clients
,
&
sock
,
clientSocketCompare
);
if
(
!
elem
)
{
printf
(
"pubrec: couldn't find client for socket %d
\n
"
,
sock
);
rc
=
SOCKET_ERROR
;
goto
exit
;
}
client
=
(
Clients
*
)(
elem
->
content
);
Log
(
LOG_PROTOCOL
,
15
,
NULL
,
sock
,
client
->
clientID
,
pubrec
->
msgId
);
Log
(
LOG_PROTOCOL
,
15
,
NULL
,
sock
,
client
->
clientID
,
pubrec
->
msgId
);
/* look for the message by message id in the records of outbound messages for this client */
/* look for the message by message id in the records of outbound messages for this client */
...
@@ -372,6 +392,7 @@ int MQTTProtocol_handlePubrecs(void* pack, int sock)
...
@@ -372,6 +392,7 @@ int MQTTProtocol_handlePubrecs(void* pack, int sock)
time
(
&
(
m
->
lastTouch
));
time
(
&
(
m
->
lastTouch
));
}
}
}
}
exit:
free
(
pack
);
free
(
pack
);
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
return
rc
;
return
rc
;
...
@@ -449,9 +470,18 @@ int MQTTProtocol_handlePubcomps(void* pack, int sock)
...
@@ -449,9 +470,18 @@ int MQTTProtocol_handlePubcomps(void* pack, int sock)
Pubcomp
*
pubcomp
=
(
Pubcomp
*
)
pack
;
Pubcomp
*
pubcomp
=
(
Pubcomp
*
)
pack
;
Clients
*
client
=
NULL
;
Clients
*
client
=
NULL
;
int
rc
=
TCPSOCKET_COMPLETE
;
int
rc
=
TCPSOCKET_COMPLETE
;
ListElement
*
elem
=
NULL
;
FUNC_ENTRY
;
FUNC_ENTRY
;
client
=
(
Clients
*
)(
ListFindItem
(
bstate
->
clients
,
&
sock
,
clientSocketCompare
)
->
content
);
elem
=
ListFindItem
(
bstate
->
clients
,
&
sock
,
clientSocketCompare
);
if
(
!
elem
)
{
printf
(
"pubrec: couldn't find client for socket %d
\n
"
,
sock
);
rc
=
SOCKET_ERROR
;
goto
exit
;
}
client
=
(
Clients
*
)(
elem
->
content
);
//client = (Clients*)(ListFindItem(bstate->clients, &sock, clientSocketCompare)->content);
Log
(
LOG_PROTOCOL
,
19
,
NULL
,
sock
,
client
->
clientID
,
pubcomp
->
msgId
);
Log
(
LOG_PROTOCOL
,
19
,
NULL
,
sock
,
client
->
clientID
,
pubcomp
->
msgId
);
/* look for the message by message id in the records of outbound messages for this client */
/* look for the message by message id in the records of outbound messages for this client */
...
@@ -481,6 +511,7 @@ int MQTTProtocol_handlePubcomps(void* pack, int sock)
...
@@ -481,6 +511,7 @@ int MQTTProtocol_handlePubcomps(void* pack, int sock)
}
}
}
}
}
}
exit:
free
(
pack
);
free
(
pack
);
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
return
rc
;
return
rc
;
...
...
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