iDon't treat an unexpected PUBREL as fatal.
Issue #1629. Thanks to radcrabs.
This commit is contained in:
parent
346f695937
commit
a16d7e0661
@ -1,3 +1,6 @@
|
||||
Client library:
|
||||
- Don't treat an unexpected PUBREL as a fatal error. Issue #1629.
|
||||
|
||||
Build:
|
||||
- Various fixes for building with <C99 support. Closes #1622.
|
||||
- Fix use of sed on BSD. Closes #1614.
|
||||
|
@ -101,9 +101,7 @@ int handle__pubrel(struct mosquitto_db *db, struct mosquitto *mosq)
|
||||
}
|
||||
|
||||
rc = message__remove(mosq, mid, mosq_md_in, &message, 2);
|
||||
if(rc){
|
||||
return rc;
|
||||
}else{
|
||||
if(rc == MOSQ_ERR_SUCCESS){
|
||||
/* Only pass the message on if we have removed it from the queue - this
|
||||
* prevents multiple callbacks for the same message. */
|
||||
pthread_mutex_lock(&mosq->callback_mutex);
|
||||
@ -120,6 +118,10 @@ int handle__pubrel(struct mosquitto_db *db, struct mosquitto *mosq)
|
||||
pthread_mutex_unlock(&mosq->callback_mutex);
|
||||
mosquitto_property_free_all(&properties);
|
||||
message__cleanup(&message);
|
||||
}else if(rc == MOSQ_ERR_NOT_FOUND){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -41,6 +41,7 @@ c : test-compile
|
||||
./03-publish-b2c-qos1.py $@/03-publish-b2c-qos1.test
|
||||
./03-publish-b2c-qos2-len.py $@/03-publish-b2c-qos2-len.test
|
||||
./03-publish-b2c-qos2.py $@/03-publish-b2c-qos2.test
|
||||
./03-publish-b2c-qos2-unexpected-pubrel.py $@/03-publish-b2c-qos2-unexpected-pubrel.test
|
||||
./03-publish-c2b-qos1-disconnect.py $@/03-publish-c2b-qos1-disconnect.test
|
||||
./03-publish-c2b-qos1-len.py $@/03-publish-c2b-qos1-len.test
|
||||
./03-publish-c2b-qos1-receive-maximum.py $@/03-publish-c2b-qos1-receive-maximum.test
|
||||
|
72
test/lib/c/03-publish-b2c-qos2-unexpected-pubrel.c
Normal file
72
test/lib/c/03-publish-b2c-qos2-unexpected-pubrel.c
Normal file
@ -0,0 +1,72 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
|
||||
static int run = -1;
|
||||
|
||||
void on_connect(struct mosquitto *mosq, void *obj, int rc)
|
||||
{
|
||||
if(rc){
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_message *msg)
|
||||
{
|
||||
if(msg->mid != 13423){
|
||||
printf("Invalid mid (%d)\n", msg->mid);
|
||||
exit(1);
|
||||
}
|
||||
if(msg->qos != 2){
|
||||
printf("Invalid qos (%d)\n", msg->qos);
|
||||
exit(1);
|
||||
}
|
||||
if(strcmp(msg->topic, "pub/qos2/receive")){
|
||||
printf("Invalid topic (%s)\n", msg->topic);
|
||||
exit(1);
|
||||
}
|
||||
if(strcmp(msg->payload, "message")){
|
||||
printf("Invalid payload (%s)\n", (char *)msg->payload);
|
||||
exit(1);
|
||||
}
|
||||
if(msg->payloadlen != 7){
|
||||
printf("Invalid payloadlen (%d)\n", msg->payloadlen);
|
||||
exit(1);
|
||||
}
|
||||
if(msg->retain != false){
|
||||
printf("Invalid retain (%d)\n", msg->retain);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
run = 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc;
|
||||
struct mosquitto *mosq;
|
||||
|
||||
int port = atoi(argv[1]);
|
||||
|
||||
mosquitto_lib_init();
|
||||
|
||||
mosq = mosquitto_new("publish-qos2-test", true, &run);
|
||||
mosquitto_connect_callback_set(mosq, on_connect);
|
||||
mosquitto_message_callback_set(mosq, on_message);
|
||||
mosquitto_message_retry_set(mosq, 5);
|
||||
|
||||
rc = mosquitto_connect(mosq, "localhost", port, 60);
|
||||
|
||||
while(run == -1){
|
||||
rc = mosquitto_loop(mosq, 300, 1);
|
||||
if(rc){
|
||||
printf("%d:%s\n", rc, mosquitto_strerror(rc));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
mosquitto_lib_cleanup();
|
||||
return run;
|
||||
}
|
@ -27,6 +27,7 @@ SRC = \
|
||||
03-publish-c2b-qos2-disconnect.c \
|
||||
03-publish-c2b-qos2-len.c \
|
||||
03-publish-b2c-qos2-len.c \
|
||||
03-publish-b2c-qos2-unexpected-pubrel.c \
|
||||
03-publish-c2b-qos1-receive-maximum.c \
|
||||
03-publish-c2b-qos2-receive-maximum-1.c \
|
||||
03-publish-c2b-qos2-receive-maximum-2.c \
|
||||
|
@ -23,6 +23,7 @@ tests = [
|
||||
|
||||
(1, ['./03-publish-b2c-qos1.py', 'c/03-publish-b2c-qos1.test']),
|
||||
(1, ['./03-publish-b2c-qos2-len.py', 'c/03-publish-b2c-qos2-len.test']),
|
||||
(1, ['./03-publish-b2c-qos2-unexpected-pubrel.py', 'c/03-publish-b2c-qos2-unexpected-pubrel.test']),
|
||||
(1, ['./03-publish-b2c-qos2.py', 'c/03-publish-b2c-qos2.test']),
|
||||
(1, ['./03-publish-c2b-qos1-disconnect.py', 'c/03-publish-c2b-qos1-disconnect.test']),
|
||||
(1, ['./03-publish-c2b-qos1-len.py', 'c/03-publish-c2b-qos1-len.test']),
|
||||
|
Loading…
Reference in New Issue
Block a user