Commit 3bdd5b5d authored by Juergen Kosel's avatar Juergen Kosel

Merge branch 'develop' into 373

* develop:
  Remove reference to internal Heap functions for now
  Some cleanup of testing code
  Add call to AppVeyor env setup
  Do we need spaces?
  Try again...
  Change vcvars syntax
  Check visual studio env var
  Correct vcvarsall location
  Add Visual Studio 2013 build as well as 2015
  Reinstate .travis.yml
  Update cd command
  Use HTTPS git checkout instead of SSH
  Another Python3 try
  Update Python3 version
  Try AppVeyor build with local broker
  修改了restoreCommand时:(1)topics指针未申请内存的问题;(2)unsub误写为sub的问题。
  fix issue that MQTTClient_connect hangs on network outage, for windows

# Conflicts:
#	src/Socket.c
#	test/test6.c
Signed-off-by: 's avatarJuergen Kosel <juergen.kosel@softing.com>
parents 5edc4db3 abecbdc8
version: 1.2.{build}
image: Visual Studio 2015
image:
- Visual Studio 2013
- Visual Studio 2015
configuration: Debug
install:
- cmd: openssl version
......@@ -12,7 +14,17 @@ install:
- cmd: netsh advfirewall set allprofiles state off
- ps: Start-Process python -ArgumentList 'test\mqttsas2.py', 'mqtt.iotree.co.uk'
- ps: Start-Process python -ArgumentList 'test\mqttsas2.py'
- cmd: C:\Python36\python --version
- cmd: git clone https://github.com/eclipse/paho.mqtt.testing.git
- cmd: cd paho.mqtt.testing\interoperability
- ps: Start-Process C:\Python36\python -ArgumentList 'startbroker.py'
- cmd: cd ..\..
build_script:
- cmd: >-
......@@ -20,7 +32,11 @@ build_script:
cd build.paho
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
echo %APPVEYOR_BUILD_WORKER_IMAGE%
if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2013" call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
cmake -G "NMake Makefiles" -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=TRUE ..
......
......@@ -718,6 +718,12 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle
case SUBSCRIBE:
command->details.sub.count = *(int*)ptr;
ptr += sizeof(int);
if (command->details.sub.count > 0)
{
command->details.sub.topics = (char **)malloc(sizeof(char *) * command->details.sub.count);
command->details.sub.qoss = (int *)malloc(sizeof(int) * command->details.sub.count);
}
for (i = 0; i < command->details.sub.count; ++i)
{
......@@ -733,8 +739,13 @@ static MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int bufle
break;
case UNSUBSCRIBE:
command->details.sub.count = *(int*)ptr;
command->details.unsub.count = *(int*)ptr;
ptr += sizeof(int);
if (command->details.unsub.count > 0)
{
command->details.unsub.topics = (char **)malloc(sizeof(char *) * command->details.unsub.count);
}
for (i = 0; i < command->details.unsub.count; ++i)
{
......
......@@ -429,8 +429,11 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
rc = TCPSOCKET_INTERRUPTED;
}
#else
//#define TESTING
#if defined(TESTING)
/*#define TCPSOCKET_INTERRUPTED_TESTING
This section forces the occasional return of TCPSOCKET_INTERRUPTED,
for testing purposes only!
*/
#if defined(TCPSOCKET_INTERRUPTED_TESTING)
static int i = 0;
if (++i >= 10 && i < 21)
{
......@@ -463,7 +466,7 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
}
else
*bytes = rc;
#if defined(TESTING)
#if defined(TCPSOCKET_INTERRUPTED_TESTING)
}
#endif
#endif
......@@ -525,7 +528,6 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
#if defined(OPENSSL)
SocketBuffer_pendingWrite(socket, NULL, count+1, iovecs, frees1, total, bytes);
#else
//printf("Partial write for socket %d pending write created\n", socket);
StackTrace_printStack(stdout);
SocketBuffer_pendingWrite(socket, count+1, iovecs, frees1, total, bytes);
#endif
......@@ -606,7 +608,6 @@ int Socket_close_only(int socket)
void Socket_close(int socket)
{
FUNC_ENTRY;
//printf("Closing socket %d\n", socket);
Socket_close_only(socket);
FD_CLR(socket, &(s.rset_saved));
if (FD_ISSET(socket, &(s.pending_wset)))
......@@ -719,9 +720,12 @@ int Socket_new(char* addr, int port, int* sock)
if (setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0)
Log(LOG_ERROR, -1, "Could not set SO_NOSIGPIPE for socket %d", *sock);
#endif
//#define TESTING1
#if defined(TESTING1)
if (1)
/*#define SMALL_TCP_BUFFER_TESTING
This section sets the TCP send buffer to a small amount to provoke TCPSOCKET_INTERRUPTED
return codes from send, for testing only!
*/
#if defined(SMALL_TCP_BUFFER_TESTING)
if (1)
{
int optsend = 100; //2 * 1440;
printf("Setting optsend to %d\n", optsend);
......@@ -834,7 +838,6 @@ int Socket_continueWrite(int socket)
}
}
rc = 1; /* signal complete */
//printf("Partial write complete for socket %d\n", socket);
Log(TRACE_MIN, -1, "ContinueWrite: partial write now complete for socket %d", socket);
}
else
......@@ -853,7 +856,6 @@ int Socket_continueWrite(int socket)
pw->iovecs[i].iov_base = NULL;
}
}
//printf("Partial write aborted for socket %d\n", socket);
}
#if defined(OPENSSL)
exit:
......@@ -875,16 +877,12 @@ int Socket_abortWrite(int socket)
pending_writes* pw;
FUNC_ENTRY;
//printf("In abortWrite for socket %d\n", socket);
if ((pw = SocketBuffer_getWrite(socket)) == NULL)
goto exit;
#if defined(OPENSSL)
if (pw->ssl)
{
//rc = SSLSocket_continueWrite(pw);
goto exit;
}
#endif
for (i = 0; i < pw->count; i++)
......@@ -896,7 +894,6 @@ int Socket_abortWrite(int socket)
}
}
exit:
//printf("Exit abortWrite for socket %d\n", socket);
FUNC_EXIT_RC(rc);
return rc;
}
......
......@@ -319,6 +319,7 @@ void SocketBuffer_queueChar(int socket, char c)
* @param socket the socket for which the write was interrupted
* @param count the number of iovec buffers
* @param iovecs buffer array
* @param frees a set of flags indicating which of the iovecs array should be freed
* @param total total data length to be written
* @param bytes actual data length that was written
*/
......
......@@ -233,7 +233,7 @@ int Thread_wait_sem(sem_type sem, int timeout)
FUNC_ENTRY;
#if defined(WIN32) || defined(WIN64)
rc = WaitForSingleObject(sem, timeout);
rc = WaitForSingleObject(sem, timeout < 0 ? 0 : timeout);
#elif defined(OSX)
rc = (int)dispatch_semaphore_wait(sem, dispatch_time(DISPATCH_TIME_NOW, (int64_t)timeout*1000000L));
#elif defined(USE_TRYWAIT)
......
PROJECT(mqtt-tests C)
SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQTT broker to use")
SET(MQTT_TEST_PROXY "tcp://localhost:1884" CACHE STRING "Hostname of the test proxy to use")
SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use")
IF (WIN32)
SET(MQTT_TEST_BROKER "tcp://mqtt.iotree.co.uk:1883" CACHE STRING "Hostname of a test MQTT broker to use")
SET(MQTT_TEST_PROXY "tcp://localhost:1883" CACHE STRING "Hostname of the test proxy to use")
SET(MQTT_SSL_HOSTNAME "mqtt.iotree.co.uk" CACHE STRING "Hostname of a test SSL MQTT broker to use")
SET(CERTDIR $ENV{APPVEYOR_BUILD_FOLDER}/test/ssl)
ELSE ()
SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQTT broker to use")
SET(MQTT_TEST_PROXY "tcp://localhost:1884" CACHE STRING "Hostname of the test proxy to use")
SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use")
SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl)
ENDIF ()
......
......@@ -512,12 +512,11 @@ int recreateReconnect(void)
MQTTAsync_destroy(&client); /* destroy the client object so that we force persistence to be read on recreate */
#if !defined(_WINDOWS)
heap_info* mqtt_mem = 0;
mqtt_mem = Heap_get_info();
/*mqtt_mem = Heap_get_info();
MyLog(LOGA_INFO, "MQTT mem current %ld, max %ld",mqtt_mem->current_size,mqtt_mem->max_size);
if (mqtt_mem->current_size > 20)
HeapScan(5); */
#endif
//if (mqtt_mem->current_size > 20)
// HeapScan(5);
rc = MQTTAsync_create(&client, opts.connection, opts.clientid, MQTTCLIENT_PERSISTENCE_DEFAULT, NULL);
if (rc != MQTTASYNC_SUCCESS)
{
......
Markdown is supported
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