Merge branch 'fixes'

pull/211/merge v1.4.6
Roger A. Light 10 years ago
commit 156442c694

@ -11,7 +11,7 @@ project(mosquitto)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
# Only for version 3 and up. cmake_policy(SET CMP0042 NEW) # Only for version 3 and up. cmake_policy(SET CMP0042 NEW)
set (VERSION 1.4.5) set (VERSION 1.4.6)
if (WIN32) if (WIN32)
execute_process(COMMAND cmd /c echo %DATE% %TIME% OUTPUT_VARIABLE TIMESTAMP execute_process(COMMAND cmd /c echo %DATE% %TIME% OUTPUT_VARIABLE TIMESTAMP

@ -1,3 +1,18 @@
1.4.6 - 20151220
================
Broker:
- Add support for libwebsockets 1.6.
Client library:
- Fix _mosquitto_socketpair() on Windows, reducing the chance of delays when
publishing. Closes #483979.
Clients:
- Fix "mosquitto_pub -l" stripping the final character on a line. Closes
#483981.
1.4.5 - 20151108 1.4.5 - 20151108
================ ================

@ -392,7 +392,7 @@ int main(int argc, char *argv[])
buf_len_actual = strlen(buf); buf_len_actual = strlen(buf);
if(buf[buf_len_actual-1] == '\n'){ if(buf[buf_len_actual-1] == '\n'){
buf[buf_len_actual-1] = '\0'; buf[buf_len_actual-1] = '\0';
rc2 = mosquitto_publish(mosq, &mid_sent, topic, buf_len_actual, buf, qos, retain); rc2 = mosquitto_publish(mosq, &mid_sent, topic, buf_len_actual-1, buf, qos, retain);
if(rc2){ if(rc2){
if(!quiet) fprintf(stderr, "Error: Publish returned %d, disconnecting.\n", rc2); if(!quiet) fprintf(stderr, "Error: Publish returned %d, disconnecting.\n", rc2);
mosquitto_disconnect(mosq); mosquitto_disconnect(mosq);

@ -83,7 +83,7 @@ WITH_SOCKS:=yes
# Also bump lib/mosquitto.h, CMakeLists.txt, # Also bump lib/mosquitto.h, CMakeLists.txt,
# installer/mosquitto.nsi, installer/mosquitto-cygwin.nsi # installer/mosquitto.nsi, installer/mosquitto-cygwin.nsi
VERSION=1.4.5 VERSION=1.4.6
TIMESTAMP:=$(shell date "+%F %T%z") TIMESTAMP:=$(shell date "+%F %T%z")
# Client library SO version. Bump if incompatible API/ABI changes are made. # Client library SO version. Bump if incompatible API/ABI changes are made.

@ -7,7 +7,7 @@
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
Name "mosquitto" Name "mosquitto"
!define VERSION 1.4.5 !define VERSION 1.4.6
OutFile "mosquitto-${VERSION}-install-cygwin.exe" OutFile "mosquitto-${VERSION}-install-cygwin.exe"
InstallDir "$PROGRAMFILES\mosquitto" InstallDir "$PROGRAMFILES\mosquitto"

@ -9,7 +9,7 @@
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
Name "mosquitto" Name "mosquitto"
!define VERSION 1.4.5 !define VERSION 1.4.6
OutFile "mosquitto-${VERSION}-install-win32.exe" OutFile "mosquitto-${VERSION}-install-win32.exe"
InstallDir "$PROGRAMFILES\mosquitto" InstallDir "$PROGRAMFILES\mosquitto"

@ -45,7 +45,7 @@ extern "C" {
#define LIBMOSQUITTO_MAJOR 1 #define LIBMOSQUITTO_MAJOR 1
#define LIBMOSQUITTO_MINOR 4 #define LIBMOSQUITTO_MINOR 4
#define LIBMOSQUITTO_REVISION 5 #define LIBMOSQUITTO_REVISION 6
/* LIBMOSQUITTO_VERSION_NUMBER looks like 1002001 for e.g. version 1.2.1. */ /* LIBMOSQUITTO_VERSION_NUMBER looks like 1002001 for e.g. version 1.2.1. */
#define LIBMOSQUITTO_VERSION_NUMBER (LIBMOSQUITTO_MAJOR*1000000+LIBMOSQUITTO_MINOR*1000+LIBMOSQUITTO_REVISION) #define LIBMOSQUITTO_VERSION_NUMBER (LIBMOSQUITTO_MAJOR*1000000+LIBMOSQUITTO_MINOR*1000+LIBMOSQUITTO_REVISION)
@ -576,6 +576,7 @@ libmosq_EXPORT int mosquitto_disconnect(struct mosquitto *mosq);
* Note that although the MQTT protocol doesn't use message ids * Note that although the MQTT protocol doesn't use message ids
* for messages with QoS=0, libmosquitto assigns them message ids * for messages with QoS=0, libmosquitto assigns them message ids
* so they can be tracked with this parameter. * so they can be tracked with this parameter.
* topic - null terminated string of the topic to publish to.
* payloadlen - the size of the payload (bytes). Valid values are between 0 and * payloadlen - the size of the payload (bytes). Valid values are between 0 and
* 268,435,455. * 268,435,455.
* payload - pointer to the data to send. If payloadlen > 0 this must be a * payload - pointer to the data to send. If payloadlen > 0 this must be a

@ -207,8 +207,12 @@ struct mosquitto {
int sub_count; int sub_count;
int pollfd_index; int pollfd_index;
# ifdef WITH_WEBSOCKETS # ifdef WITH_WEBSOCKETS
# if defined(LWS_LIBRARY_VERSION_NUMBER)
struct lws *wsi;
# else
struct libwebsocket_context *ws_context; struct libwebsocket_context *ws_context;
struct libwebsocket *wsi; struct libwebsocket *wsi;
# endif
# endif # endif
#else #else
# ifdef WITH_SOCKS # ifdef WITH_SOCKS

@ -68,6 +68,7 @@ Contributors:
extern unsigned long g_pub_msgs_sent; extern unsigned long g_pub_msgs_sent;
# endif # endif
# ifdef WITH_WEBSOCKETS # ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h> # include <libwebsockets.h>
# endif # endif
#else #else
@ -1125,10 +1126,6 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
continue; continue;
} }
if(_mosquitto_socket_nonblock(listensock)){
continue;
}
if(family[i] == AF_INET){ if(family[i] == AF_INET){
sa->sin_family = family[i]; sa->sin_family = family[i];
sa->sin_addr.s_addr = htonl(INADDR_LOOPBACK); sa->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
@ -1145,6 +1142,7 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
continue; continue;
} }
if(_mosquitto_socket_nonblock(spR)){ if(_mosquitto_socket_nonblock(spR)){
COMPAT_CLOSE(spR);
COMPAT_CLOSE(listensock); COMPAT_CLOSE(listensock);
continue; continue;
} }
@ -1172,6 +1170,7 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
if(_mosquitto_socket_nonblock(spW)){ if(_mosquitto_socket_nonblock(spW)){
COMPAT_CLOSE(spR); COMPAT_CLOSE(spR);
COMPAT_CLOSE(spW);
COMPAT_CLOSE(listensock); COMPAT_CLOSE(listensock);
continue; continue;
} }

@ -444,8 +444,8 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
while(!mosquitto_loop(mosq, -1, 1)){ mosquitto_loop_forever(mosq, -1, 1);
}
mosquitto_destroy(mosq); mosquitto_destroy(mosq);
mosquitto_lib_cleanup(); mosquitto_lib_cleanup();
return 0; return 0;

@ -37,6 +37,7 @@ Contributors:
#include <time.h> #include <time.h>
#ifdef WITH_WEBSOCKETS #ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h> # include <libwebsockets.h>
#endif #endif

@ -43,6 +43,7 @@ Contributors:
#include <tcpd.h> #include <tcpd.h>
#endif #endif
#ifdef WITH_WEBSOCKETS #ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h> # include <libwebsockets.h>
#endif #endif

@ -20,6 +20,26 @@ Contributors:
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h>
# if defined(LWS_LIBRARY_VERSION_NUMBER)
# define libwebsocket_callback_on_writable(A, B) lws_callback_on_writable((B))
# define libwebsocket_service(A, B) lws_service((A), (B))
# define libwebsocket_create_context(A) lws_create_context((A))
# define libwebsocket_context_destroy(A) lws_context_destroy((A))
# define libwebsocket_write(A, B, C, D) lws_write((A), (B), (C), (D))
# define libwebsocket_get_socket_fd(A) lws_get_socket_fd((A))
# define libwebsockets_return_http_status(A, B, C, D) lws_return_http_status((B), (C), (D))
# define libwebsocket_context lws_context
# define libwebsocket_protocols lws_protocols
# define libwebsocket_callback_reasons lws_callback_reasons
# define libwebsocket lws
# endif
#endif
#include <mosquitto_internal.h> #include <mosquitto_internal.h>
#include <mosquitto_plugin.h> #include <mosquitto_plugin.h>
#include <mosquitto.h> #include <mosquitto.h>
@ -482,7 +502,11 @@ void service_run(void);
* Websockets related functions * Websockets related functions
* ============================================================ */ * ============================================================ */
#ifdef WITH_WEBSOCKETS #ifdef WITH_WEBSOCKETS
# if defined(LWS_LIBRARY_VERSION_NUMBER)
struct lws_context *mosq_websockets_init(struct _mqtt3_listener *listener, int log_level);
# else
struct libwebsocket_context *mosq_websockets_init(struct _mqtt3_listener *listener, int log_level); struct libwebsocket_context *mosq_websockets_init(struct _mqtt3_listener *listener, int log_level);
# endif
#endif #endif
void do_disconnect(struct mosquitto_db *db, struct mosquitto *context); void do_disconnect(struct mosquitto_db *db, struct mosquitto *context);

@ -32,7 +32,8 @@ Contributors:
#endif #endif
#ifdef WITH_WEBSOCKETS #ifdef WITH_WEBSOCKETS
#include <libwebsockets.h> # include <lws_config.h>
# include <libwebsockets.h>
#endif #endif
#ifdef WITH_SYS_TREE #ifdef WITH_SYS_TREE

@ -29,6 +29,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef WITH_WEBSOCKETS #ifdef WITH_WEBSOCKETS
#include <lws_config.h>
#include <libwebsockets.h> #include <libwebsockets.h>
#include "mosquitto_internal.h" #include "mosquitto_internal.h"
#include "mosquitto_broker.h" #include "mosquitto_broker.h"
@ -49,13 +50,22 @@ extern unsigned long g_pub_msgs_sent;
#endif #endif
extern struct mosquitto_db int_db; extern struct mosquitto_db int_db;
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_mqtt(
#else
static int callback_mqtt(struct libwebsocket_context *context, static int callback_mqtt(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi, struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, enum libwebsocket_callback_reasons reason,
void *user, void *user,
void *in, void *in,
size_t len); size_t len);
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_http(
#else
static int callback_http(struct libwebsocket_context *context, static int callback_http(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi, struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, enum libwebsocket_callback_reasons reason,
void *user, void *user,
@ -95,7 +105,9 @@ static struct libwebsocket_protocols protocols[] = {
0, 0,
#endif #endif
NULL, NULL,
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
0 0
#endif
}, },
{ {
"mqtt", "mqtt",
@ -106,7 +118,9 @@ static struct libwebsocket_protocols protocols[] = {
1, 1,
#endif #endif
NULL, NULL,
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
0 0
#endif
}, },
{ {
"mqttv3.1", "mqttv3.1",
@ -117,10 +131,16 @@ static struct libwebsocket_protocols protocols[] = {
1, 1,
#endif #endif
NULL, NULL,
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
0 0
#endif
}, },
#ifdef LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD #ifdef LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
# if defined(LWS_LIBRARY_VERSION_NUMBER)
{ NULL, NULL, 0, 0, 0, NULL}
# else
{ NULL, NULL, 0, 0, 0, NULL, 0} { NULL, NULL, 0, 0, 0, NULL, 0}
# endif
#else #else
{ NULL, NULL, 0, 0, NULL, 0} { NULL, NULL, 0, 0, NULL, 0}
#endif #endif
@ -135,7 +155,11 @@ static void easy_address(int sock, struct mosquitto *mosq)
} }
} }
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_mqtt(
#else
static int callback_mqtt(struct libwebsocket_context *context, static int callback_mqtt(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi, struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, enum libwebsocket_callback_reasons reason,
void *user, void *user,
@ -158,7 +182,9 @@ static int callback_mqtt(struct libwebsocket_context *context,
case LWS_CALLBACK_ESTABLISHED: case LWS_CALLBACK_ESTABLISHED:
mosq = mqtt3_context_init(db, WEBSOCKET_CLIENT); mosq = mqtt3_context_init(db, WEBSOCKET_CLIENT);
if(mosq){ if(mosq){
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
mosq->ws_context = context; mosq->ws_context = context;
#endif
mosq->wsi = wsi; mosq->wsi = wsi;
u->mosq = mosq; u->mosq = mosq;
}else{ }else{
@ -342,7 +368,11 @@ static int callback_mqtt(struct libwebsocket_context *context,
} }
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_http(
#else
static int callback_http(struct libwebsocket_context *context, static int callback_http(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi, struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, enum libwebsocket_callback_reasons reason,
void *user, void *user,
@ -368,7 +398,11 @@ static int callback_http(struct libwebsocket_context *context,
return -1; return -1;
} }
#if defined(LWS_LIBRARY_VERSION_NUMBER)
hack = (struct libws_mqtt_hack *)lws_context_user(lws_get_context(wsi));
#else
hack = (struct libws_mqtt_hack *)libwebsocket_context_user(context); hack = (struct libws_mqtt_hack *)libwebsocket_context_user(context);
#endif
if(!hack){ if(!hack){
return -1; return -1;
} }

Loading…
Cancel
Save