Commit c44cbcb0 authored by Michael Ott's avatar Michael Ott
Browse files

Bump mosquitto to version 1.5.5, add patch to replace select() call by poll()...

Bump mosquitto to version 1.5.5, add patch to replace select() call by poll() to solve issues with sockets > 1024
parent 01ec918c
......@@ -3,7 +3,7 @@ MAKEFILENAME := $(lastword $(MAKEFILE_LIST))
SUB_DIRS = lib CollectAgent tools scripts
CASSANDRA_VERSION = 2.2.10
MOSQUITTO_VERSION = 1.4.14
MOSQUITTO_VERSION = 1.5.5
BOOST_VERSION = 1.58.0
OPENSSL_VERSION = 1.0.2l
CPPDRV_VERSION = 2.10.0
......@@ -20,7 +20,7 @@ DISTFILES = apache-cassandra-$(CASSANDRA_VERSION).tar.gz;http://archive.apache.o
cpp-driver-$(CPPDRV_VERSION).tar.gz;https://github.com/datastax/cpp-driver/archive/$(CPPDRV_VERSION).tar.gz \
cpp-netlib-$(CPPNET_VERSION).tar.gz;http://downloads.cpp-netlib.org/0.12.0/cpp-netlib-$(CPPNET_VERSION).tar.gz
DISTFILES_HASHES = apache-cassandra-2.2.10.tar.gz|4c58cb7c6753ce26f7c4d650502feece;mosquitto-1.4.14.tar.gz|6b0966e93f118bc71ad7b61600a6c2d3;boost_1_58_0.tar.gz|5a5d5614d9a07672e1ab2a250b5defc5;openssl-1.0.2l.tar.gz|f85123cd390e864dfbe517e7616e6566;cpp-driver-2.10.0.tar.gz|6d15dd2cccd2efd1fdc86089d26971d0;libuv-v1.24.0.tar.gz|90320330757253b07404d2a97f59c66b;cpp-netlib-0.12.0-final.tar.gz|29b87c0e8c1a9e7fbdea5afcec947d53
DISTFILES_HASHES = apache-cassandra-2.2.10.tar.gz|4c58cb7c6753ce26f7c4d650502feece;mosquitto-1.5.5.tar.gz|a17dffc6f63b2a4ab2eb5c51139e60e9;boost_1_58_0.tar.gz|5a5d5614d9a07672e1ab2a250b5defc5;openssl-1.0.2l.tar.gz|f85123cd390e864dfbe517e7616e6566;cpp-driver-2.10.0.tar.gz|6d15dd2cccd2efd1fdc86089d26971d0;libuv-v1.24.0.tar.gz|90320330757253b07404d2a97f59c66b;cpp-netlib-0.12.0-final.tar.gz|29b87c0e8c1a9e7fbdea5afcec947d53
include common.mk
......@@ -83,7 +83,7 @@ clean:
cleanall: clean
@$(foreach f,$(DISTFILESPATHS),echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f) && echo;)
@$(foreach f,mosquitto cpp-netlib,echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f)_build && echo;)
@$(foreach f,cpp-netlib,echo "Cleaning $(f)..." && rm -rf $(DCDBDEPSPATH)/$(f)_build && echo;)
distclean: clean
@echo "Wiping dependencies..."
......@@ -129,14 +129,13 @@ $(DCDBDEPSPATH)/openssl-$(OPENSSL_VERSION)/.installed: $(DCDBDEPSPATH)/openssl-$
$(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.built: $(DCDBDEPSPATH)/mosquitto-$(MOSQUITTO_VERSION)/.patched
@echo "Building Mosquitto library...";
mkdir -p $(DCDBDEPSPATH)/mosquitto_build;
cd $(DCDBDEPSPATH)/mosquitto_build && \
mkdir -p $(@D)/build;
cd $(@D)/build && \
CC=$(FULL_CC) CXX=$(FULL_CXX) cmake $(CMAKE_CROSS_FLAGS) \
-DOPENSSL_ROOT_DIR=$(DCDBDEPLOYPATH)/ \
-DWITH_SRV=no \
-DWITH_TLS=yes \
-DWITH_TLS_PSK=yes \
-DCMAKE_INSTALL_PREFIX:PATH=$(DCDBDEPLOYPATH)/ \
-DCMAKE_INSTALL_PREFIX=$(DCDBDEPLOYPATH)/ \
$(@D) && \
make -j $(MAKETHREADS) && \
touch $(@)
......
--- mosquitto-1.4.14/config.h 2014-10-28 18:38:17.000000000 +0100
+++ mosquitto-1.4.14/config.h 2014-10-28 18:38:27.000000000 +0100
@@ -4,7 +4,7 @@
*
* Compile time options have moved to config.mk.
*/
-
+#include <time.h>
/* ============================================================
* Compatibility defines
diff --git a/lib/loop.c b/lib/loop.c
index e4a985e..7c8982b 100644
--- a/lib/loop.c
+++ b/lib/loop.c
@@ -18,7 +18,7 @@ Contributors:
#include <errno.h>
#ifndef WIN32
-#include <sys/select.h>
+#include <poll.h>
#include <time.h>
#endif
@@ -36,45 +36,33 @@ Contributors:
int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
{
-#ifdef HAVE_PSELECT
- struct timespec local_timeout;
-#else
- struct timeval local_timeout;
-#endif
- fd_set readfds, writefds;
+ struct pollfd fds[2];
+ nfds_t nfds = 1;
int fdcount;
int rc;
char pairbuf;
- int maxfd = 0;
time_t now;
if(!mosq || max_packets < 1) return MOSQ_ERR_INVAL;
-#ifndef WIN32
- if(mosq->sock >= FD_SETSIZE || mosq->sockpairR >= FD_SETSIZE){
- return MOSQ_ERR_INVAL;
- }
-#endif
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
if(mosq->sock != INVALID_SOCKET){
- maxfd = mosq->sock;
- FD_SET(mosq->sock, &readfds);
+ fds[0].fd = mosq->sock;
+ fds[0].events = POLLIN;
pthread_mutex_lock(&mosq->current_out_packet_mutex);
pthread_mutex_lock(&mosq->out_packet_mutex);
if(mosq->out_packet || mosq->current_out_packet){
- FD_SET(mosq->sock, &writefds);
+ fds[0].events|= POLLOUT;
}
#ifdef WITH_TLS
if(mosq->ssl){
if(mosq->want_write){
- FD_SET(mosq->sock, &writefds);
+ fds[0].events|= POLLOUT;
}else if(mosq->want_connect){
- /* Remove possible FD_SET from above, we don't want to check
+ /* Remove possible POLLOUT from above, we don't want to check
* for writing if we are still connecting, unless want_write is
* definitely set. The presence of outgoing packets does not
* matter yet. */
- FD_CLR(mosq->sock, &writefds);
+ fds[0].events&= ~POLLOUT;
}
}
#endif
@@ -82,6 +70,7 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
pthread_mutex_unlock(&mosq->current_out_packet_mutex);
}else{
#ifdef WITH_SRV
+ //TODO
if(mosq->achan){
pthread_mutex_lock(&mosq->state_mutex);
if(mosq->state == mosq_cs_connect_srv){
@@ -102,10 +91,9 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
if(mosq->sockpairR != INVALID_SOCKET){
/* sockpairR is used to break out of select() before the timeout, on a
* call to publish() etc. */
- FD_SET(mosq->sockpairR, &readfds);
- if(mosq->sockpairR > maxfd){
- maxfd = mosq->sockpairR;
- }
+ nfds++;
+ fds[nfds-1].fd = mosq->sockpairR;
+ fds[nfds-1].fd|= POLLIN;
}
if(timeout < 0){
@@ -123,18 +111,7 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
timeout = 0;
}
- local_timeout.tv_sec = timeout/1000;
-#ifdef HAVE_PSELECT
- local_timeout.tv_nsec = (timeout-local_timeout.tv_sec*1000)*1e6;
-#else
- local_timeout.tv_usec = (timeout-local_timeout.tv_sec*1000)*1000;
-#endif
-
-#ifdef HAVE_PSELECT
- fdcount = pselect(maxfd+1, &readfds, &writefds, NULL, &local_timeout, NULL);
-#else
- fdcount = select(maxfd+1, &readfds, &writefds, NULL, &local_timeout);
-#endif
+ fdcount = poll(fds, nfds, timeout);
if(fdcount == -1){
#ifdef WIN32
errno = WSAGetLastError();
@@ -146,13 +123,13 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
}
}else{
if(mosq->sock != INVALID_SOCKET){
- if(FD_ISSET(mosq->sock, &readfds)){
+ if((fds[0].revents & POLLIN) == POLLIN){
rc = mosquitto_loop_read(mosq, max_packets);
if(rc || mosq->sock == INVALID_SOCKET){
return rc;
}
}
- if(mosq->sockpairR != INVALID_SOCKET && FD_ISSET(mosq->sockpairR, &readfds)){
+ if(mosq->sockpairR != INVALID_SOCKET && (fds[nfds-1].revents & POLLIN) == POLLIN){
#ifndef WIN32
if(read(mosq->sockpairR, &pairbuf, 1) == 0){
}
@@ -163,9 +140,9 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
* we didn't ask for it, because at that point the publish or
* other command wasn't present. */
if(mosq->sock != INVALID_SOCKET)
- FD_SET(mosq->sock, &writefds);
+ fds[0].revents|= POLLOUT;
}
- if(mosq->sock != INVALID_SOCKET && FD_ISSET(mosq->sock, &writefds)){
+ if(mosq->sock != INVALID_SOCKET && (fds[0].revents & POLLOUT) == POLLOUT){
#ifdef WITH_TLS
if(mosq->want_connect){
rc = net__socket_connect_tls(mosq);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment