Merge fixes into develop.

pull/139/head
Roger A. Light 10 years ago
commit fca9ac84f7

@ -47,6 +47,10 @@ There are further details at
- <https://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions> - <https://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions>
If your contribution is a fix for a bug, please use the 'fixes' branch as the
base for your work. If you are proposing new behaviour/features please use the
'develop' branch.
Once the patch is pushed back to Gerrit, the project committers will be Once the patch is pushed back to Gerrit, the project committers will be
informed and they will undertake a review of the code. The patch may need informed and they will undertake a review of the code. The patch may need
modifying for some reason. In order to make amending commits more modifying for some reason. In order to make amending commits more

@ -36,6 +36,41 @@ Client:
- Add -U to mosquitto_sub for unsubscribing from topics. - Add -U to mosquitto_sub for unsubscribing from topics.
1.4.7 - 20151221
================
Broker:
- Fix support for libwebsockets 1.22.
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
================
Broker:
- Fix possible memory leak if bridge using SSL attempts to connect to a
host that is not up.
- Free unused topic tree elements (fix in 1.4.3 was incomplete). Closes
#468987.
Clients:
- "mosquitto_pub -l" now no longer limited to 1024 byte lines. Closes #478917.
1.4.4 - 20150916 1.4.4 - 20150916
================ ================

@ -290,10 +290,20 @@ void print_usage(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct mosq_config cfg; struct mosq_config cfg;
char buf[1024];
struct mosquitto *mosq = NULL; struct mosquitto *mosq = NULL;
int rc; int rc;
int rc2; int rc2;
char *buf;
int buf_len = 1024;
int buf_len_actual;
int read_len;
int pos;
buf = malloc(buf_len);
if(!buf){
fprintf(stderr, "Error: Out of memory.\n");
return 1;
}
memset(&cfg, 0, sizeof(struct mosq_config)); memset(&cfg, 0, sizeof(struct mosq_config));
rc = client_config_load(&cfg, CLIENT_PUB, argc, argv); rc = client_config_load(&cfg, CLIENT_PUB, argc, argv);
@ -376,14 +386,30 @@ int main(int argc, char *argv[])
do{ do{
if(mode == MSGMODE_STDIN_LINE){ if(mode == MSGMODE_STDIN_LINE){
if(status == STATUS_CONNACK_RECVD){ if(status == STATUS_CONNACK_RECVD){
if(fgets(buf, 1024, stdin)){ pos = 0;
buf[strlen(buf)-1] = '\0'; read_len = buf_len;
rc2 = mosquitto_publish(mosq, &mid_sent, topic, strlen(buf), buf, qos, retain); while(fgets(&buf[pos], read_len, stdin)){
if(rc2){ buf_len_actual = strlen(buf);
if(!quiet) fprintf(stderr, "Error: Publish returned %d, disconnecting.\n", rc2); if(buf[buf_len_actual-1] == '\n'){
mosquitto_disconnect(mosq); buf[buf_len_actual-1] = '\0';
rc2 = mosquitto_publish(mosq, &mid_sent, topic, buf_len_actual-1, buf, qos, retain);
if(rc2){
if(!quiet) fprintf(stderr, "Error: Publish returned %d, disconnecting.\n", rc2);
mosquitto_disconnect(mosq);
}
break;
}else{
buf_len += 1024;
pos += 1023;
read_len = 1024;
buf = realloc(buf, buf_len);
if(!buf){
fprintf(stderr, "Error: Out of memory.\n");
return 1;
}
} }
}else if(feof(stdin)){ }
if(feof(stdin)){
last_mid = mid_sent; last_mid = mid_sent;
status = STATUS_WAITING; status = STATUS_WAITING;
} }

@ -394,6 +394,15 @@ static int mosquitto__connect_init(struct mosquitto *mosq, const char *host, int
mosq->keepalive = keepalive; mosq->keepalive = keepalive;
if(mosq->sockpairR != INVALID_SOCKET){
COMPAT_CLOSE(mosq->sockpairR);
mosq->sockpairR = INVALID_SOCKET;
}
if(mosq->sockpairW != INVALID_SOCKET){
COMPAT_CLOSE(mosq->sockpairW);
mosq->sockpairW = INVALID_SOCKET;
}
if(net__socketpair(&mosq->sockpairR, &mosq->sockpairW)){ if(net__socketpair(&mosq->sockpairR, &mosq->sockpairW)){
log__printf(mosq, MOSQ_LOG_WARNING, log__printf(mosq, MOSQ_LOG_WARNING,
"Warning: Unable to open socket pair, outgoing publish commands may be delayed."); "Warning: Unable to open socket pair, outgoing publish commands may be delayed.");

@ -577,6 +577,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

@ -669,10 +669,6 @@ int net__socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
continue; continue;
} }
if(net__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);
@ -689,6 +685,7 @@ int net__socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
continue; continue;
} }
if(net__socket_nonblock(spR)){ if(net__socket_nonblock(spR)){
COMPAT_CLOSE(spR);
COMPAT_CLOSE(listensock); COMPAT_CLOSE(listensock);
continue; continue;
} }
@ -716,6 +713,7 @@ int net__socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
if(net__socket_nonblock(spW)){ if(net__socket_nonblock(spW)){
COMPAT_CLOSE(spR); COMPAT_CLOSE(spR);
COMPAT_CLOSE(spW);
COMPAT_CLOSE(listensock); COMPAT_CLOSE(listensock);
continue; continue;
} }

@ -64,7 +64,7 @@ html : *.xml
set -e; for m in *.xml; \ set -e; for m in *.xml; \
do \ do \
hfile=$$(echo $${m} | sed -e 's#\(.*\)\.xml#\1#' | sed -e 's/\./-/g'); \ hfile=$$(echo $${m} | sed -e 's#\(.*\)\.xml#\1#' | sed -e 's/\./-/g'); \
$(XSLTPROC) html.xsl $${m} > $${hfile}.php; \ $(XSLTPROC) html.xsl $${m} > $${hfile}.html; \
done done
potgen : potgen :

@ -9,26 +9,4 @@
<xsl:param name="make.valid.html" select="1"></xsl:param> <xsl:param name="make.valid.html" select="1"></xsl:param>
<xsl:param name="html.cleanup" select="1"></xsl:param> <xsl:param name="html.cleanup" select="1"></xsl:param>
<xsl:param name="docbook.css.source"></xsl:param> <xsl:param name="docbook.css.source"></xsl:param>
<xsl:template match="*" mode="process.root">
<xsl:variable name="doc" select="self::*"/>
<xsl:call-template name="user.preroot"/>
<xsl:call-template name="root.messages"/>
<xsl:text disable-output-escaping="yes"><![CDATA[<?php include '../_includes/header.php' ?>]]></xsl:text>
<xsl:call-template name="body.attributes"/>
<xsl:call-template name="user.header.content">
<xsl:with-param name="node" select="$doc"/>
</xsl:call-template>
<xsl:apply-templates select="."/>
<xsl:call-template name="user.footer.content">
<xsl:with-param name="node" select="$doc"/>
</xsl:call-template>
<xsl:text disable-output-escaping="yes"><![CDATA[<?php include '../_includes/footer.php' ?>]]></xsl:text>
<!-- Generate any css files only once, not once per chunk -->
<xsl:call-template name="generate.css.files"/>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

@ -439,8 +439,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;
@ -452,11 +452,11 @@ int main(int argc, char *argv[])
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-8.php">mosquitto</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-8.html">mosquitto</link></refentrytitle>
<manvolnum>8</manvolnum> <manvolnum>8</manvolnum>
</citerefentry> </citerefentry>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mqtt-7.php">mqtt</link></refentrytitle> <refentrytitle><link xlink:href="mqtt-7.html">mqtt</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -80,13 +80,13 @@
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-8.php">mosquitto</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-8.html">mosquitto</link></refentrytitle>
<manvolnum>8</manvolnum> <manvolnum>8</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-conf-5.php">mosquitto-conf</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-conf-5.html">mosquitto-conf</link></refentrytitle>
<manvolnum>5</manvolnum> <manvolnum>5</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -481,49 +481,49 @@
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mqtt-7.php">mqtt</link></refentrytitle> <refentrytitle><link xlink:href="mqtt-7.html">mqtt</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-tls-7.php">mosquitto-tls</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-tls-7.html">mosquitto-tls</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-conf-5.php">mosquitto.conf</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-conf-5.html">mosquitto.conf</link></refentrytitle>
<manvolnum>5</manvolnum> <manvolnum>5</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="http://www.linuxmanpages.com/man5/hosts_access.5.php">hosts_access</link></refentrytitle> <refentrytitle><link xlink:href="http://www.linuxmanpages.com/man5/hosts_access.5.html">hosts_access</link></refentrytitle>
<manvolnum>5</manvolnum> <manvolnum>5</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_passwd-1.php">mosquitto_passwd</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_passwd-1.html">mosquitto_passwd</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_pub-1.php">mosquitto_pub</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_pub-1.html">mosquitto_pub</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_sub-1.php">mosquitto_sub</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_sub-1.html">mosquitto_sub</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="libmosquitto-3.php">libmosquitto</link></refentrytitle> <refentrytitle><link xlink:href="libmosquitto-3.html">libmosquitto</link></refentrytitle>
<manvolnum>3</manvolnum> <manvolnum>3</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -1421,25 +1421,25 @@ topic clients/total in 0 test/mosquitto/org $SYS/broker/
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-8.php">mosquitto</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-8.html">mosquitto</link></refentrytitle>
<manvolnum>8</manvolnum> <manvolnum>8</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_passwd-1.php">mosquitto_passwd</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_passwd-1.html">mosquitto_passwd</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-tls-7.php">mosquitto-tls</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-tls-7.html">mosquitto-tls</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mqtt-7.php">mqtt</link></refentrytitle> <refentrytitle><link xlink:href="mqtt-7.html">mqtt</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -132,19 +132,19 @@
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-8.php">mosquitto</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-8.html">mosquitto</link></refentrytitle>
<manvolnum>8</manvolnum> <manvolnum>8</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-conf-5.php">mosquitto.conf</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-conf-5.html">mosquitto.conf</link></refentrytitle>
<manvolnum>5</manvolnum> <manvolnum>5</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mqtt-7.php">mqtt</link></refentrytitle> <refentrytitle><link xlink:href="mqtt-7.html">mqtt</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -485,31 +485,31 @@
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mqtt-7.php">mqtt</link></refentrytitle> <refentrytitle><link xlink:href="mqtt-7.html">mqtt</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_sub-1.php">mosquitto_sub</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_sub-1.html">mosquitto_sub</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-8.php">mosquitto</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-8.html">mosquitto</link></refentrytitle>
<manvolnum>8</manvolnum> <manvolnum>8</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="libmosquitto-3.php">libmosquitto</link></refentrytitle> <refentrytitle><link xlink:href="libmosquitto-3.html">libmosquitto</link></refentrytitle>
<manvolnum>3</manvolnum> <manvolnum>3</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-tls-7.php">mosquitto-tls</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-tls-7.html">mosquitto-tls</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -568,31 +568,31 @@
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mqtt-7.php">mqtt</link></refentrytitle> <refentrytitle><link xlink:href="mqtt-7.html">mqtt</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_pub-1.php">mosquitto_pub</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_pub-1.html">mosquitto_pub</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-8.php">mosquitto</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-8.html">mosquitto</link></refentrytitle>
<manvolnum>8</manvolnum> <manvolnum>8</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="libmosquitto-3.php">libmosquitto</link></refentrytitle> <refentrytitle><link xlink:href="libmosquitto-3.html">libmosquitto</link></refentrytitle>
<manvolnum>3</manvolnum> <manvolnum>3</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-tls-7.php">mosquitto-tls</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-tls-7.html">mosquitto-tls</link></refentrytitle>
<manvolnum>7</manvolnum> <manvolnum>7</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -161,19 +161,19 @@
<simplelist type="inline"> <simplelist type="inline">
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto-8.php">mosquitto</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto-8.html">mosquitto</link></refentrytitle>
<manvolnum>8</manvolnum> <manvolnum>8</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_pub-1.php">mosquitto_pub</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_pub-1.html">mosquitto_pub</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>
<member> <member>
<citerefentry> <citerefentry>
<refentrytitle><link xlink:href="mosquitto_sub-1.php">mosquitto_sub</link></refentrytitle> <refentrytitle><link xlink:href="mosquitto_sub-1.html">mosquitto_sub</link></refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
</citerefentry> </citerefentry>
</member> </member>

@ -180,6 +180,7 @@ int bridge__connect(struct mosquitto_db *db, struct mosquitto *context)
rc = net__socket_connect(context, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port, NULL, false); rc = net__socket_connect(context, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port, NULL, false);
if(rc > 0 ){ if(rc > 0 ){
if(rc == MOSQ_ERR_TLS){ if(rc == MOSQ_ERR_TLS){
_mosquitto_socket_close(db, context);
return rc; /* Error already printed */ return rc; /* Error already printed */
}else if(rc == MOSQ_ERR_ERRNO){ }else if(rc == MOSQ_ERR_ERRNO){
log__printf(NULL, MOSQ_LOG_ERR, "Error creating bridge: %s.", strerror(errno)); log__printf(NULL, MOSQ_LOG_ERR, "Error creating bridge: %s.", strerror(errno));

@ -20,6 +20,25 @@ Contributors:
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#ifdef WITH_WEBSOCKETS
# 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"
@ -560,7 +579,11 @@ void service_run(void);
* Websockets related functions * Websockets related functions
* ============================================================ */ * ============================================================ */
#ifdef WITH_WEBSOCKETS #ifdef WITH_WEBSOCKETS
struct libwebsocket_context *mosq_websockets_init(struct mosquitto__listener *listener, int log_level); # 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);
# endif
#endif #endif
void do_disconnect(struct mosquitto_db *db, struct mosquitto *context); void do_disconnect(struct mosquitto_db *db, struct mosquitto *context);

@ -34,7 +34,7 @@ Contributors:
#endif #endif
#ifdef WITH_WEBSOCKETS #ifdef WITH_WEBSOCKETS
#include <libwebsockets.h> # include <libwebsockets.h>
#endif #endif
static char *client_id_gen(struct mosquitto_db *db) static char *client_id_gen(struct mosquitto_db *db)

@ -559,18 +559,20 @@ static struct mosquitto__subhier *tmp_remove_subs(struct mosquitto__subhier *sub
if(!sub || !sub->parent){ if(!sub || !sub->parent){
return NULL; return NULL;
} }
if(sub->children || sub->subs || sub->next){
if(sub->children || sub->subs){
return NULL; return NULL;
} }
parent = sub->parent; parent = sub->parent;
hier = sub->parent->children; hier = sub->parent->children;
while(hier){ while(hier){
if(hier == sub){ if(hier == sub){
if(last){ if(last){
last->next = sub->next; last->next = hier->next;
}else{ }else{
parent->children = NULL; parent->children = hier->next;
} }
UHPA_FREE_TOPIC(sub); UHPA_FREE_TOPIC(sub);
mosquitto__free(sub); mosquitto__free(sub);

@ -43,13 +43,22 @@ POSSIBILITY OF SUCH DAMAGE.
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,
@ -77,7 +86,9 @@ static struct libwebsocket_protocols protocols[] = {
0, 0,
#endif #endif
NULL, NULL,
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
0 0
#endif
}, },
{ {
"mqtt", "mqtt",
@ -88,7 +99,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",
@ -99,10 +112,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
@ -117,7 +136,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,
@ -140,7 +163,9 @@ static int callback_mqtt(struct libwebsocket_context *context,
case LWS_CALLBACK_ESTABLISHED: case LWS_CALLBACK_ESTABLISHED:
mosq = context__init(db, WEBSOCKET_CLIENT); mosq = 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{
@ -319,7 +344,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,
@ -343,7 +372,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