Commit da3f6341 authored by Ian Craggs's avatar Ian Craggs

Fix for bug #415042

parent e5882541
......@@ -15,6 +15,7 @@
* Ian Craggs, Allan Stockdill-Mander - SSL support
* Ian Craggs - multiple server connection support
* Ian Craggs - fix for bug 413429 - connectionLost not called
* Ian Craggs - fix for bug# 415042 - using already freed structure
*******************************************************************************/
/**
......@@ -2618,7 +2619,7 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
while (ListNextElement(m->responses, &current))
{
MQTTAsync_queuedCommand* command = (MQTTAsync_queuedCommand*)(current->content);
if (command->command.token == ((Puback*)pack)->msgId)
if (command->command.token == msgid)
{
if (!ListDetach(m->responses, command)) /* then remove the response from the list */
Log(LOG_ERROR, -1, "Publish command not removed from command list");
......
......@@ -13,6 +13,7 @@
* Contributors:
* Ian Craggs - initial implementation
* Ian Craggs, Allan Stockdill-Mander - async client updates
* Ian Craggs - bug #415042 - start Linux thread as disconnected
*******************************************************************************/
/**
......@@ -53,18 +54,22 @@
*/
thread_type Thread_start(thread_fn fn, void* parameter)
{
#if defined(WIN32)
#if defined(WIN32)
thread_type thread = NULL;
#else
thread_type thread = 0;
pthread_attr_t attr;
#endif
FUNC_ENTRY;
#if defined(WIN32)
thread = CreateThread(NULL, 0, fn, parameter, 0, NULL);
#else
if (pthread_create(&thread, NULL, fn, parameter) != 0)
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (pthread_create(&thread, &attr, fn, parameter) != 0)
thread = 0;
pthread_attr_destroy(&attr);
#endif
FUNC_EXIT;
return thread;
......
......@@ -19,7 +19,7 @@
#include "string.h"
#include "MQTTAsync.h"
#define ADDRESS "tcp://swtest.hursley.ibm.com:1883"
#define ADDRESS "tcp://m2m.eclipse.org:1883"
#define CLIENTID "ExampleClientPub"
#define TOPIC "MQTT Examples"
#define PAYLOAD "Hello World!"
......
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