Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
icraggs committed Mar 28, 2022
2 parents 3b7ae63 + 29ed338 commit 515ddba
Show file tree
Hide file tree
Showing 65 changed files with 1,661 additions and 581 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Builds for Linux"
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install doxygen
- name: Build
run: |
rm -rf build.paho
mkdir build.paho
cd build.paho
echo "pwd $PWD"
cmake -DPAHO_BUILD_STATIC=FALSE -DPAHO_BUILD_SHARED=TRUE -DCMAKE_BUILD_TYPE=Debug -DPAHO_WITH_SSL=TRUE -DOPENSSL_ROOT_DIR= -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_HIGH_PERFORMANCE=TRUE ..
cmake --build .
- name: Start test broker
run: |
git clone https://github.com/eclipse/paho.mqtt.testing.git
cd paho.mqtt.testing/interoperability
python3 startbroker.py -c localhost_testing.conf &
- name: Start test proxy
run: |
python3 test/mqttsas.py &
- name: run tests
run: |
cd build.paho
ctest -VV --timeout 600
- name: clean up
run: |
killall python3 || true
sleep 3 # allow broker time to terminate and report
- name: package
run: |
cd build.paho
cpack --verbose
41 changes: 41 additions & 0 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Builds for MacOS"
on: [push, pull_request]

jobs:
build:
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Install dependencies
run: |
brew update
brew install doxygen
- name: Build
run: |
rm -rf build.paho
mkdir build.paho
cd build.paho
echo "pwd $PWD"
cmake -DPAHO_BUILD_STATIC=FALSE -DPAHO_BUILD_SHARED=TRUE -DCMAKE_BUILD_TYPE=Debug -DPAHO_WITH_SSL=TRUE -DOPENSSL_ROOT_DIR=/usr/local/opt/[email protected] -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_HIGH_PERFORMANCE=TRUE ..
cmake --build .
- name: Start test broker
run: |
git clone https://github.com/eclipse/paho.mqtt.testing.git
cd paho.mqtt.testing/interoperability
python3 startbroker.py -c localhost_testing.conf &
- name: Start test proxy
run: |
python3 test/mqttsas.py &
- name: run tests
run: |
cd build.paho
ctest -VV --timeout 600
- name: clean up
run: |
killall python3 || true
sleep 3 # allow broker time to terminate and report
- name: package
run: |
cd build.paho
cpack --verbose
1 change: 1 addition & 0 deletions .github/workflows/covsync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ jobs:
fetch-depth: 0
- run: |
git checkout -b coverity-develop origin/develop
git pull origin coverity-develop
git push origin coverity-develop
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
env: OPENSSL_ROOT_DIR= PAHO_BUILD_STATIC=TRUE PAHO_BUILD_SHARED=TRUE PAHO_HIGH_PERFORMANCE=TRUE
- os: osx
compiler: clang
env: OPENSSL_ROOT_DIR=/usr/local/opt/openssl PAHO_BUILD_STATIC=FALSE PAHO_BUILD_SHARED=TRUE PAHO_HIGH_PERFORMANC=FALSE
env: OPENSSL_ROOT_DIR=/usr/local/opt/openssl PAHO_BUILD_STATIC=FALSE PAHO_BUILD_SHARED=TRUE PAHO_HIGH_PERFORMANCE=FALSE
- os: linux
compiler: gcc
dist: trusty
Expand Down
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ INCLUDE(GNUInstallDirs)
STRING(TIMESTAMP BUILD_TIMESTAMP UTC)
MESSAGE(STATUS "Timestamp is ${BUILD_TIMESTAMP}")

IF (PAHO_HIGH_PERFORMANCE)
ADD_DEFINITIONS(-DHIGH_PERFORMANCE=1)
ENDIF()

IF(WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN -MD)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN)
ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
ADD_DEFINITIONS(-DOSX)
ENDIF()
Expand All @@ -55,6 +51,16 @@ SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs")
SET(PAHO_BUILD_DEB_PACKAGE FALSE CACHE BOOL "Build debian package")
SET(PAHO_ENABLE_TESTING TRUE CACHE BOOL "Build tests and run")
SET(PAHO_ENABLE_CPACK TRUE CACHE BOOL "Enable CPack")
SET(PAHO_HIGH_PERFORMANCE FALSE CACHE BOOL "Disable tracing and heap tracking")
SET(PAHO_USE_SELECT FALSE CACHE BOOL "Revert to select system call instead of poll")

IF (PAHO_HIGH_PERFORMANCE)
ADD_DEFINITIONS(-DHIGH_PERFORMANCE=1)
ENDIF()

IF (PAHO_USE_SELECT)
ADD_DEFINITIONS(-DUSE_SELECT=1)
ENDIF()

IF (NOT PAHO_BUILD_SHARED AND NOT PAHO_BUILD_STATIC)
MESSAGE(FATAL_ERROR "You must set either PAHO_BUILD_SHARED, PAHO_BUILD_STATIC, or both")
Expand Down
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#*******************************************************************************
# Copyright (c) 2009, 2020 IBM Corp.
# Copyright (c) 2009, 2021 IBM Corp.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
Expand All @@ -21,7 +21,7 @@
# Note: on OS X you should install XCode and the associated command-line tools

SHELL = /bin/sh
.PHONY: clean, mkdir, install, uninstall, html
.PHONY: clean mkdir install install-strip uninstall html strip-options

MAJOR_VERSION := $(shell cat version.major)
MINOR_VERSION := $(shell cat version.minor)
Expand Down Expand Up @@ -155,18 +155,18 @@ PAHO_CS_PUB_TARGET = ${blddir}/samples/${PAHO_CS_PUB_NAME}
PAHO_CS_SUB_TARGET = ${blddir}/samples/${PAHO_CS_SUB_NAME}

#CCFLAGS_SO = -g -fPIC $(CFLAGS) -Os -Wall -fvisibility=hidden -I$(blddir_work)
#FLAGS_EXE = $(LDFLAGS) -I ${srcdir} -lpthread -L ${blddir}
#FLAGS_EXES = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -lpthread -lssl -lcrypto ${END_GROUP} -L ${blddir}
#FLAGS_EXE = $(LDFLAGS) -I ${srcdir} -pthread -L ${blddir}
#FLAGS_EXES = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -pthread -lssl -lcrypto ${END_GROUP} -L ${blddir}

CCFLAGS_SO = -g -fPIC $(CFLAGS) -D_GNU_SOURCE -Os -Wall -fvisibility=hidden -I$(blddir_work) -DPAHO_MQTT_EXPORTS=1
FLAGS_EXE = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -lpthread ${GAI_LIB} ${END_GROUP} -L ${blddir}
FLAGS_EXES = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -lpthread ${GAI_LIB} -lssl -lcrypto ${END_GROUP} -L ${blddir}
FLAGS_EXE = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -pthread ${GAI_LIB} ${END_GROUP} -L ${blddir}
FLAGS_EXES = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -pthread ${GAI_LIB} -lssl -lcrypto ${END_GROUP} -L ${blddir}

LDCONFIG ?= /sbin/ldconfig
LDFLAGS_C = $(LDFLAGS) -shared -Wl,-init,$(MQTTCLIENT_INIT) $(START_GROUP) -lpthread $(GAI_LIB) $(END_GROUP)
LDFLAGS_CS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(GAI_LIB) $(EXTRA_LIB) -lssl -lcrypto $(END_GROUP) -Wl,-init,$(MQTTCLIENT_INIT)
LDFLAGS_A = $(LDFLAGS) -shared -Wl,-init,$(MQTTASYNC_INIT) $(START_GROUP) -lpthread $(GAI_LIB) $(END_GROUP)
LDFLAGS_AS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(GAI_LIB) $(EXTRA_LIB) -lssl -lcrypto $(END_GROUP) -Wl,-init,$(MQTTASYNC_INIT)
LDFLAGS_C = $(LDFLAGS) -shared -Wl,-init,$(MQTTCLIENT_INIT) $(START_GROUP) -pthread $(GAI_LIB) $(END_GROUP)
LDFLAGS_CS = $(LDFLAGS) -shared $(START_GROUP) -pthread $(GAI_LIB) $(EXTRA_LIB) -lssl -lcrypto $(END_GROUP) -Wl,-init,$(MQTTCLIENT_INIT)
LDFLAGS_A = $(LDFLAGS) -shared -Wl,-init,$(MQTTASYNC_INIT) $(START_GROUP) -pthread $(GAI_LIB) $(END_GROUP)
LDFLAGS_AS = $(LDFLAGS) -shared $(START_GROUP) -pthread $(GAI_LIB) $(EXTRA_LIB) -lssl -lcrypto $(END_GROUP) -Wl,-init,$(MQTTASYNC_INIT)

SED_COMMAND = sed \
-e "s/@CLIENT_VERSION@/${release.version}/g" \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ PAHO_WITH_SSL | FALSE | Flag that defines whether to build ssl-enabled binaries
OPENSSL_ROOT_DIR | "" (system default) | Directory containing your OpenSSL installation (i.e. `/usr/local` when headers are in `/usr/local/include` and libraries are in `/usr/local/lib`)
PAHO_BUILD_DOCUMENTATION | FALSE | Create and install the HTML based API documentation (requires Doxygen)
PAHO_BUILD_SAMPLES | FALSE | Build sample programs
PAHO_ENABLE_TESTING | TRUE | Build test and run
MQTT_TEST_BROKER | tcp://localhost:1883 | MQTT connection URL for a broker to use during test execution
MQTT_TEST_PROXY | tcp://localhost:1883 | Hostname of the test proxy to use
MQTT_SSL_HOSTNAME | localhost | Hostname of a test SSL MQTT broker to use
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ build_script:
nmake
ctest -T test -VV
ctest -T test -VV
cd ..
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ SET(common_src
Base64.c
SHA1.c
WebSocket.c
Proxy.c
)

IF (NOT PAHO_HIGH_PERFORMANCE)
Expand Down
4 changes: 2 additions & 2 deletions src/Clients.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp.
* Copyright (c) 2009, 2022 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
Expand Down Expand Up @@ -51,5 +51,5 @@ int clientSocketCompare(void* a, void* b)
{
Clients* client = (Clients*)a;
/*printf("comparing %d with %d\n", (char*)a, (char*)b); */
return client->net.socket == *(int*)b;
return client->net.socket == *(SOCKET*)b;
}
16 changes: 10 additions & 6 deletions src/Clients.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2021 IBM Corp. and Ian Craggs
* Copyright (c) 2009, 2022 IBM Corp. and Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
Expand All @@ -24,15 +24,16 @@

#include <stdint.h>
#include "MQTTTime.h"
#if defined(OPENSSL)
#if defined(_WIN32) || defined(_WIN64)
#include <winsock2.h>
#endif
#if defined(OPENSSL)
#include <openssl/ssl.h>
#endif
#include "MQTTClient.h"
#include "LinkedList.h"
#include "MQTTClientPersistence.h"
#include "Socket.h"

/**
* Stored publication data to minimize copying
Expand Down Expand Up @@ -77,7 +78,7 @@ typedef struct

typedef struct
{
int socket;
SOCKET socket;
START_TIME_TYPE lastSent;
START_TIME_TYPE lastReceived;
START_TIME_TYPE lastPing;
Expand Down Expand Up @@ -131,12 +132,15 @@ typedef struct
networkHandles net; /**< network info for this client */
int msgID; /**< the MQTT message id */
int keepAliveInterval; /**< the MQTT keep alive interval */
int retryInterval;
int retryInterval; /**< the MQTT retry interval for QoS > 0 */
int maxInflightMessages; /**< the max number of inflight outbound messages we allow */
willMessages* will; /**< the MQTT will message, if any */
List* inboundMsgs; /**< inbound in flight messages */
List* outboundMsgs; /**< outbound in flight messages */
int connect_count; /**< the number of outbound messages on reconnect - to ensure we send them all */
int connect_sent; /**< the current number of outbound messages on reconnect that we've sent */
List* messageQueue; /**< inbound complete but undelivered messages */
List* outboundQueue; /**< outbound queued messages */
unsigned int qentry_seqno;
void* phandle; /**< the persistence handle */
MQTTClient_persistence* persistence; /**< a persistence implementation */
Expand All @@ -147,8 +151,8 @@ typedef struct
void* context; /**< calling context - used when calling disconnect_internal */
int MQTTVersion; /**< the version of MQTT being used, 3, 4 or 5 */
int sessionExpiry; /**< MQTT 5 session expiry */
char* httpProxy; /**< HTTP proxy for websockets */
char* httpsProxy; /**< HTTPS proxy for websockets */
char* httpProxy; /**< HTTP proxy */
char* httpsProxy; /**< HTTPS proxy */
#if defined(OPENSSL)
MQTTClient_SSLOptions *sslopts; /**< the SSL/TLS connect options */
SSL_SESSION* session; /**< SSL session pointer for fast handhake */
Expand Down
22 changes: 22 additions & 0 deletions src/Keysight_ws_add
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#if WINVER <= _WIN32_WINNT_WIN8
#define HTON(x) hton((uint64_t) (x), sizeof(x))
uint64_t hton(uint64_t x, size_t n)
{
uint64_t y = 0;
size_t i = 0;

for (i=0; i < n; ++i)
{
y = (y << 8) | (x & 0xff);
x = (x >> 8);
}
return y;
}
#define htons(x) (uint16_t) HTON(x)
#define htonl(x) (uint32_t) HTON(x)
#define htonll(x) (uint64_t) HTON(x)

#define ntohs(x) htons(x)
#define ntohl(x) htonl(x)
#define ntohll(x) htonll(x)
#endif
6 changes: 3 additions & 3 deletions src/Log.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2020 IBM Corp.
* Copyright (c) 2009, 2022 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
Expand Down Expand Up @@ -86,7 +86,7 @@ typedef struct
#endif
int sametime_count;
int number;
int thread_id;
thread_id_type thread_id;
int depth;
char name[MAX_FUNCTION_NAME_LENGTH + 1];
int line;
Expand Down Expand Up @@ -453,7 +453,7 @@ void Log(enum LOG_LEVELS log_level, int msgno, const char *format, ...)
* @param aFormat the printf format string to be used if the message id does not exist
* @param ... the printf inserts
*/
void Log_stackTrace(enum LOG_LEVELS log_level, int msgno, int thread_id, int current_depth, const char* name, int line, int* rc)
void Log_stackTrace(enum LOG_LEVELS log_level, int msgno, thread_id_type thread_id, int current_depth, const char* name, int line, int* rc)
{
traceEntry *cur_entry = NULL;

Expand Down
12 changes: 10 additions & 2 deletions src/Log.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp.
* Copyright (c) 2009, 2022 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
Expand All @@ -18,6 +18,14 @@
#if !defined(LOG_H)
#define LOG_H

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#define thread_id_type DWORD
#else
#include <pthread.h>
#define thread_id_type pthread_t
#endif

/*BE
map LOG_LEVELS
{
Expand Down Expand Up @@ -76,7 +84,7 @@ int Log_initialize(Log_nameValue*);
void Log_terminate(void);

void Log(enum LOG_LEVELS, int, const char *, ...);
void Log_stackTrace(enum LOG_LEVELS, int, int, int, const char*, int, int*);
void Log_stackTrace(enum LOG_LEVELS, int, thread_id_type, int, const char*, int, int*);

typedef void Log_traceCallback(enum LOG_LEVELS level, const char *message);
void Log_setTraceCallback(Log_traceCallback* callback);
Expand Down
Loading

0 comments on commit 515ddba

Please sign in to comment.