Commit 89f227ce authored by Ian Craggs's avatar Ian Craggs

Fix for issue #453

parent 6f929f58
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2014 IBM Corp. * Copyright (c) 2009, 2018 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs, Allan Stockdill-Mander - SSL updates * Ian Craggs, Allan Stockdill-Mander - SSL updates
* Ian Craggs - MQTT 3.1.1 support * Ian Craggs - MQTT 3.1.1 support
* Ian Craggs - fix for issue 453
*******************************************************************************/ *******************************************************************************/
/** /**
...@@ -179,27 +180,32 @@ int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buf ...@@ -179,27 +180,32 @@ int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buf
int rc; int rc;
size_t buf0len; size_t buf0len;
char *buf; char *buf;
int count = 0;
FUNC_ENTRY; FUNC_ENTRY;
buf = malloc(10); buf = malloc(10);
buf[0] = header.byte; buf[0] = header.byte;
buf0len = 1 + MQTTPacket_encode(&buf[1], buflen); buf0len = 1 + MQTTPacket_encode(&buf[1], buflen);
if (buffer != NULL)
count = 1;
#if !defined(NO_PERSISTENCE) #if !defined(NO_PERSISTENCE)
if (header.bits.type == PUBREL) if (header.bits.type == PUBREL)
{ {
char* ptraux = buffer; char* ptraux = buffer;
int msgId = readInt(&ptraux); int msgId = readInt(&ptraux);
rc = MQTTPersistence_put(net->socket, buf, buf0len, 1, &buffer, &buflen, rc = MQTTPersistence_put(net->socket, buf, buf0len, count, &buffer, &buflen,
header.bits.type, msgId, 0); header.bits.type, msgId, 0);
} }
#endif #endif
#if defined(OPENSSL) #if defined(OPENSSL)
if (net->ssl) if (net->ssl)
rc = SSLSocket_putdatas(net->ssl, net->socket, buf, buf0len, 1, &buffer, &buflen, &freeData); rc = SSLSocket_putdatas(net->ssl, net->socket, buf, buf0len, count, &buffer, &buflen, &freeData);
else else
#endif #endif
rc = Socket_putdatas(net->socket, buf, buf0len, 1, &buffer, &buflen, &freeData); rc = Socket_putdatas(net->socket, buf, buf0len, count, &buffer, &buflen, &freeData);
if (rc == TCPSOCKET_COMPLETE) if (rc == TCPSOCKET_COMPLETE)
time(&(net->lastSent)); time(&(net->lastSent));
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2017 IBM Corp. * Copyright (c) 2009, 2018 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -142,12 +142,11 @@ int MQTTPacket_send_pingreq(networkHandles* net, const char* clientID) ...@@ -142,12 +142,11 @@ int MQTTPacket_send_pingreq(networkHandles* net, const char* clientID)
{ {
Header header; Header header;
int rc = 0; int rc = 0;
size_t buflen = 0;
FUNC_ENTRY; FUNC_ENTRY;
header.byte = 0; header.byte = 0;
header.bits.type = PINGREQ; header.bits.type = PINGREQ;
rc = MQTTPacket_send(net, header, NULL, buflen,0); rc = MQTTPacket_send(net, header, NULL, 0, 0);
Log(LOG_PROTOCOL, 20, NULL, net->socket, clientID, rc); Log(LOG_PROTOCOL, 20, NULL, net->socket, clientID, rc);
FUNC_EXIT_RC(rc); FUNC_EXIT_RC(rc);
return rc; return rc;
......
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