diff --git a/Makefile b/Makefile index b4668ff4..e89a04f3 100755 --- a/Makefile +++ b/Makefile @@ -164,11 +164,12 @@ END_GROUP = EXTRA_LIB = -ldl -CCFLAGS_SO += -Wno-deprecated-declarations -DUSE_NAMED_SEMAPHORES +CCFLAGS_SO += -Wno-deprecated-declarations -DOSX LDFLAGS_C += -Wl,-install_name,lib$(MQTTLIB_C).so.${MAJOR_VERSION} LDFLAGS_CS += -Wl,-install_name,lib$(MQTTLIB_CS).so.${MAJOR_VERSION} LDFLAGS_A += -Wl,-install_name,lib${MQTTLIB_A}.so.${MAJOR_VERSION} LDFLAGS_AS += -Wl,-install_name,lib${MQTTLIB_AS}.so.${MAJOR_VERSION} +FLAGS_EXE += -DOSX endif diff --git a/src/Thread.c b/src/Thread.c index c93ced70..4d96d89e 100644 --- a/src/Thread.c +++ b/src/Thread.c @@ -196,7 +196,7 @@ sem_type Thread_create_sem(void) NULL // object name ); #elif defined(OSX) - sem = dispatch_semaphore_create(0L); + sem = dispatch_semaphore_create(0L); rc = (sem == NULL) ? -1 : 0; #else sem = malloc(sizeof(sem_t)); @@ -234,7 +234,7 @@ int Thread_wait_sem(sem_type sem, int timeout) #if defined(WIN32) || defined(WIN64) rc = WaitForSingleObject(sem, timeout); #elif defined(OSX) - rc = (int)dispatch_semaphore_wait(sem, dispatch_time(DISPATCH_TIME_NOW, timeout*1000)); + rc = (int)dispatch_semaphore_wait(sem, dispatch_time(DISPATCH_TIME_NOW, (int64_t)timeout*1000000L)); #elif defined(USE_TRYWAIT) while (++i < count && (rc = sem_trywait(sem)) != 0) { @@ -291,7 +291,7 @@ int Thread_post_sem(sem_type sem) if (SetEvent(sem) == 0) rc = GetLastError(); #elif defined(OSX) - rc = (int)dispatch_semaphore_signal(sem); + rc = (int)dispatch_semaphore_signal(sem); #else if (sem_post(sem) == -1) rc = errno; diff --git a/test/mqttsas2.py b/test/mqttsas2.py index b1c7c9f5..2de83d04 100755 --- a/test/mqttsas2.py +++ b/test/mqttsas2.py @@ -1,16 +1,16 @@ """ ******************************************************************* - Copyright (c) 2013, 2016 IBM Corp. - + Copyright (c) 2013, 2017 IBM Corp. + All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 - and Eclipse Distribution License v1.0 which accompany this distribution. - - The Eclipse Public License is available at + and Eclipse Distribution License v1.0 which accompany this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - and the Eclipse Distribution License is available at + and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. - + Contributors: Ian Craggs - initial implementation and/or documentation ******************************************************************* @@ -45,7 +45,8 @@ class MyHandler(socketserver.StreamRequestHandler): clients = self.request brokers = socket.socket(socket.AF_INET, socket.SOCK_STREAM) brokers.connect((brokerhost, brokerport)) - while inbuf != None: + terminated = False + while inbuf != None and not terminated: (i, o, e) = select.select([clients, brokers], [], []) for s in i: if s == clients: @@ -60,6 +61,7 @@ class MyHandler(socketserver.StreamRequestHandler): print("Terminating client", self.ids[id(clients)]) brokers.close() clients.close() + terminated = True break elif packet.fh.MessageType == MQTTV3.CONNECT: self.ids[id(clients)] = packet.ClientIdentifier diff --git a/test/test1.c b/test/test1.c index bc173857..a8ecb624 100644 --- a/test/test1.c +++ b/test/test1.c @@ -955,7 +955,7 @@ int test6(struct Options options) opts.keepAliveInterval = 2; opts.cleansession = 1; - opts.MQTTVersion = options.MQTTVersion; + opts.MQTTVersion = MQTTVERSION_3_1_1; opts.will = &wopts; opts.will->message = test6_will_message; opts.will->qos = 1;