aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV.Krishn <vkrishn4@gmail.com>2020-03-09 00:59:35 +0530
committerV.Krishn <vkrishn4@gmail.com>2020-03-09 00:59:35 +0530
commitd8af0fb7658aff1c40f9d4b5721012e44e355123 (patch)
tree38bed445a793fd9a6ca077e7d22a0af77a932c38
parentbc08f8fc5d8867f300e5d2c358a595ceafec3ac4 (diff)
downloadmqtt-dirpub-d8af0fb7658aff1c40f9d4b5721012e44e355123.tar.bz2
update to mosquitto-v1.6.9
-rw-r--r--README.md4
-rw-r--r--client_shared.c27
-rw-r--r--client_shared.h3
-rw-r--r--sub_client.c6
-rw-r--r--sub_client_output.c2
5 files changed, 33 insertions, 9 deletions
diff --git a/README.md b/README.md
index b86aebe..1442859 100644
--- a/README.md
+++ b/README.md
@@ -18,9 +18,9 @@ allowed masks are:
`@[epoch|date|year|month|day|datetime|hour|min|sec|id|topic[1-9]]`
**eg.**
-`--fmask '/tmp/msgs/@year/@month@-@day/@topic/@id@-@hour@min'`
+`--fmask '/tmp/msgs/@year/@month@-@day/@topic/@hour@min'`
will create file:
-`/tmp/msgs/2010/10-29/topic/id-0540`
+`/tmp/msgs/2010/10-29/topic/0540`
Note: **topic**/s *having hierarchy structure gets further resolved to directory.*
diff --git a/client_shared.c b/client_shared.c
index 7c6b4e7..1547375 100644
--- a/client_shared.c
+++ b/client_shared.c
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2014-2019 Roger Light <roger@atchoo.org>
+Copyright (c) 2014-2020 Roger Light <roger@atchoo.org>
Copyright (c) 2015-2019 V.Krishn <vkrishn@insteps.net>
All rights reserved. This program and the accompanying materials
@@ -141,6 +141,7 @@ void init_config(struct mosq_config *cfg, int pub_or_sub)
}else{
cfg->protocol_version = MQTT_PROTOCOL_V311;
}
+ cfg->session_expiry_interval = -1; /* -1 means unset here, the user can't set it to -1. */
cfg->isfmask = false;
cfg->overwrite = false;
}
@@ -358,9 +359,27 @@ int client_config_load(struct mosq_config *cfg, int pub_or_sub, int argc, char *
}
#endif
- if(cfg->clean_session == false && (cfg->id_prefix || !cfg->id)){
- fprintf(stderr, "Error: You must provide a client id if you are using the -c option.\n");
- return 1;
+ if(cfg->protocol_version == 5){
+ if(cfg->clean_session == false && cfg->session_expiry_interval == -1){
+ /* User hasn't set session-expiry-interval, but has cleared clean
+ * session so default to persistent session. */
+ cfg->session_expiry_interval = UINT32_MAX;
+ }
+ if(cfg->session_expiry_interval > 0){
+ if(cfg->session_expiry_interval == UINT32_MAX && (cfg->id_prefix || !cfg->id)){
+ fprintf(stderr, "Error: You must provide a client id if you are using an infinite session expiry interval.\n");
+ return 1;
+ }
+ rc = mosquitto_property_add_int32(&cfg->connect_props, MQTT_PROP_SESSION_EXPIRY_INTERVAL, cfg->session_expiry_interval);
+ if(rc){
+ fprintf(stderr, "Error adding property session-expiry-interval\n");
+ }
+ }
+ }else{
+ if(cfg->clean_session == false && (cfg->id_prefix || !cfg->id)){
+ fprintf(stderr, "Error: You must provide a client id if you are using the -c option.\n");
+ return 1;
+ }
}
if(pub_or_sub == CLIENT_SUB){
diff --git a/client_shared.h b/client_shared.h
index a376980..4293082 100644
--- a/client_shared.h
+++ b/client_shared.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2014-2019 Roger Light <roger@atchoo.org>
+Copyright (c) 2014-2020 Roger Light <roger@atchoo.org>
Copyright (c) 2015-2019 V.Krishn <vkrishn@insteps.net>
All rights reserved. This program and the accompanying materials
@@ -104,6 +104,7 @@ struct mosq_config {
char *format; /* sub */
int timeout; /* sub */
int sub_opts; /* sub */
+ long session_expiry_interval;
#ifdef WITH_SOCKS
char *socks5_host;
int socks5_port;
diff --git a/sub_client.c b/sub_client.c
index 8707d0d..1dfb02f 100644
--- a/sub_client.c
+++ b/sub_client.c
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2009-2019 Roger Light <roger@atchoo.org>
+Copyright (c) 2009-2020 Roger Light <roger@atchoo.org>
Copyright (c) 2013-2019 V.Krishn <vkrishn@insteps.net>
All rights reserved. This program and the accompanying materials
@@ -99,6 +99,10 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit
}
}
+ if(cfg.remove_retained && message->retain){
+ mosquitto_publish(mosq, &last_mid, message->topic, 0, NULL, 1, true);
+ }
+
if(cfg.fmask){
print_message_file(&cfg, message);
}else{
diff --git a/sub_client_output.c b/sub_client_output.c
index 8d6034a..e8c105b 100644
--- a/sub_client_output.c
+++ b/sub_client_output.c
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2009-2019 Roger Light <roger@atchoo.org>
+Copyright (c) 2009-2020 Roger Light <roger@atchoo.org>
Copyright (c) 2015-2019 V.Krishn <vkrishn@insteps.net>
All rights reserved. This program and the accompanying materials