diff --git a/CMakeLists.txt b/CMakeLists.txt index 782185c9..30d6f598 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,8 @@ else (${WITH_TLS} STREQUAL ON) set (OPENSSL_INCLUDE_DIR "") endif (${WITH_TLS} STREQUAL ON) +option(WITH_SRV "Include SRV lookup support?" ON) + # ======================================== # Include projects # ======================================== diff --git a/ChangeLog.txt b/ChangeLog.txt index bd8a25da..9efcef5c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -23,6 +23,13 @@ Broker: Client library: - Fix topic matching edge case. +- Fix callback deadlocks after calling mosquitto_disconnect(), when using the + threaded interfaces. Closes bug #1313725. +- Fix SRV support when building with CMake. + +General: +- Use $(STRIP) for stripping binaries when installing, to allow easier cross + compilation. 1.3.1 - 20140324 ================ diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 14abcbec..97e5dae4 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -4,6 +4,10 @@ link_directories(${mosquitto_BINARY_DIR}/lib) set(shared_src client_shared.c client_shared.h) +if (${WITH_SRV} STREQUAL ON) + add_definitions("-DWITH_SRV") +endif (${WITH_SRV} STREQUAL ON) + add_executable(mosquitto_pub pub_client.c ${shared_src}) add_executable(mosquitto_sub sub_client.c ${shared_src}) diff --git a/client/client_shared.c b/client/client_shared.c index 974761aa..85192683 100644 --- a/client/client_shared.c +++ b/client/client_shared.c @@ -406,8 +406,10 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c }else{ cfg->pub_mode = MSGMODE_STDIN_FILE; } +#ifdef WITH_SRV }else if(!strcmp(argv[i], "-S")){ cfg->use_srv = true; +#endif }else if(!strcmp(argv[i], "-t") || !strcmp(argv[i], "--topic")){ if(i==argc-1){ fprintf(stderr, "Error: -t argument given but no topic specified.\n\n"); diff --git a/client/pub_client.c b/client/pub_client.c index 3a0c8972..60842e9f 100644 --- a/client/pub_client.c +++ b/client/pub_client.c @@ -201,7 +201,11 @@ void print_usage(void) printf("mosquitto_pub is a simple mqtt client that will publish a message on a single topic and exit.\n"); printf("mosquitto_pub version %s running on libmosquitto %d.%d.%d.\n\n", VERSION, major, minor, revision); printf("Usage: mosquitto_pub [-h host] [-p port] [-q qos] [-r] {-f file | -l | -n | -m message} -t topic\n"); +#ifdef WITH_SRV printf(" [-A bind_address] [-S]\n"); +#else + printf(" [-A bind_address]\n"); +#endif printf(" [-i id] [-I id_prefix]\n"); printf(" [-d] [--quiet]\n"); printf(" [-M max_inflight]\n"); @@ -231,7 +235,9 @@ void print_usage(void) printf(" -q : quality of service level to use for all messages. Defaults to 0.\n"); printf(" -r : message should be retained.\n"); printf(" -s : read message from stdin, sending the entire input as a message.\n"); +#ifdef WITH_SRV printf(" -S : use SRV lookups to determine which host to connect to.\n"); +#endif printf(" -t : mqtt topic to publish to.\n"); printf(" -u : provide a username (requires MQTT 3.1 broker)\n"); printf(" -P : provide a password (requires MQTT 3.1 broker)\n"); diff --git a/client/sub_client.c b/client/sub_client.c index 58855eb9..dab5cc92 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -127,7 +127,11 @@ void print_usage(void) printf("mosquitto_sub version %s running on libmosquitto %d.%d.%d.\n\n", VERSION, major, minor, revision); printf("Usage: mosquitto_sub [-c] [-h host] [-k keepalive] [-p port] [-q qos] [-R] -t topic ...\n"); printf(" [-1] [-T filter_out]\n"); +#ifdef WITH_SRV printf(" [-A bind_address] [-S]\n"); +#else + printf(" [-A bind_address]\n"); +#endif printf(" [-i id] [-I id_prefix]\n"); printf(" [-d] [-N] [--quiet] [-v]\n"); printf(" [-u username [-P password]]\n"); @@ -154,7 +158,9 @@ void print_usage(void) printf(" -p : network port to connect to. Defaults to 1883.\n"); printf(" -q : quality of service level to use for the subscription. Defaults to 0.\n"); printf(" -R : do not print stale messages (those with retain set).\n"); +#ifdef WITH_SRV printf(" -S : use SRV lookups to determine which host to connect to.\n"); +#endif printf(" -t : mqtt topic to subscribe to. May be repeated multiple times.\n"); printf(" -u : provide a username (requires MQTT 3.1 broker)\n"); printf(" -v : print published messages verbosely.\n"); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2ae6f6a6..b7c37290 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -50,8 +50,8 @@ if (WIN32) set (LIBRARIES ${LIBRARIES} ws2_32) endif (WIN32) -option(WITH_SRV "Include SRV lookup support?" ON) if (${WITH_SRV} STREQUAL ON) + add_definitions("-DWITH_SRV") set (LIBRARIES ${LIBRARIES} cares) endif (${WITH_SRV} STREQUAL ON) diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 42ea4ce9..a3977e25 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -776,6 +776,7 @@ int _mosquitto_packet_write(struct mosquitto *mosq) mosq->on_disconnect(mosq, mosq->userdata, 0); mosq->in_callback = false; } + pthread_mutex_unlock(&mosq->callback_mutex); pthread_mutex_unlock(&mosq->current_out_packet_mutex); return MOSQ_ERR_SUCCESS; } diff --git a/lib/srv_mosq.c b/lib/srv_mosq.c index 276080d6..b6f2e46d 100644 --- a/lib/srv_mosq.c +++ b/lib/srv_mosq.c @@ -40,7 +40,14 @@ static void srv_callback(void *arg, int status, int timeouts, unsigned char *abu } }else{ _mosquitto_log_printf(mosq, MOSQ_LOG_ERR, "Error: SRV lookup failed (%d).", status); - exit(1); + /* FIXME - calling on_disconnect here isn't correct. */ + pthread_mutex_lock(&mosq->callback_mutex); + if(mosq->on_disconnect){ + mosq->in_callback = true; + mosq->on_disconnect(mosq, mosq->userdata, 2); + mosq->in_callback = false; + } + pthread_mutex_unlock(&mosq->callback_mutex); } } #endif diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 03ca0805..27f88a3d 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -902,6 +902,22 @@ to 60 seconds. + + password + + Configure the password to be used when connecting + this bridge to the local broker. This may be important + when authentication and ACLs are being used. + + + + username + + Configure the username to be used when connecting + this bridge to the local broker. This may be important + when authentication and ACLs are being used. + + [ true | false ] diff --git a/src/Makefile b/src/Makefile index c3f06cce..45675caf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -100,10 +100,10 @@ mosquitto_passwd.o : mosquitto_passwd.c install : all $(INSTALL) -d ${DESTDIR}$(prefix)/sbin - $(INSTALL) -s mosquitto ${DESTDIR}${prefix}/sbin/mosquitto + $(INSTALL) -s --strip-program=$(STRIP) mosquitto ${DESTDIR}${prefix}/sbin/mosquitto $(INSTALL) mosquitto_plugin.h ${DESTDIR}${prefix}/include/mosquitto_plugin.h ifeq ($(WITH_TLS),yes) - $(INSTALL) -s mosquitto_passwd ${DESTDIR}${prefix}/bin/mosquitto_passwd + $(INSTALL) -s --strip-program=$(STRIP) mosquitto_passwd ${DESTDIR}${prefix}/bin/mosquitto_passwd endif uninstall :