Skip to content

Commit

Permalink
Further improve WOLFMQTT_TEST_NONBLOCK.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Nov 22, 2023
1 parent 1ea152e commit 86c424f
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/mqtt_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ int MqttSocket_TlsSocketReceive(WOLFSSL* ssl, char *buf, int sz,
MqttClient *client = (MqttClient*)ptr;
(void)ssl; /* Not used */

#if defined(WOLFMQTT_NONBLOCK) && defined(WOLFMQTT_TEST_NONBLOCK)
static int testSmallerTlsRead = 0;
if (!testSmallerTlsRead) {
if (sz > 2)
sz /= 2;
testSmallerTlsRead = 1;
}
else {
testSmallerTlsRead = 0;
}
#endif

rc = client->net->read(client->net->context, (byte*)buf, sz,
client->tls.timeout_ms);

Expand All @@ -87,6 +99,18 @@ int MqttSocket_TlsSocketSend(WOLFSSL* ssl, char *buf, int sz,
MqttClient *client = (MqttClient*)ptr;
(void)ssl; /* Not used */

#if defined(WOLFMQTT_NONBLOCK) && defined(WOLFMQTT_TEST_NONBLOCK)
static int testSmallerTlsWrite = 0;
if (!testSmallerTlsWrite) {
if (sz > 2)
sz /= 2;
testSmallerTlsWrite = 1;
}
else {
testSmallerTlsWrite = 0;
}
#endif

rc = client->net->write(client->net->context, (byte*)buf, sz,
client->tls.timeout_ms);

Expand Down Expand Up @@ -173,7 +197,7 @@ static int MqttSocket_WriteDo(MqttClient *client, const byte* buf, int buf_len,
#if defined(WOLFMQTT_NONBLOCK) && defined(WOLFMQTT_TEST_NONBLOCK)
static int testSmallerWrite = 0;
if (!testSmallerWrite) {
if (buf_len > 1)
if (buf_len > 2)
buf_len /= 2;
testSmallerWrite = 1;
}
Expand Down Expand Up @@ -299,7 +323,7 @@ static int MqttSocket_ReadDo(MqttClient *client, byte* buf, int buf_len,
#if defined(WOLFMQTT_NONBLOCK) && defined(WOLFMQTT_TEST_NONBLOCK)
static int testSmallerRead = 0;
if (!testSmallerRead) {
if (buf_len > 1)
if (buf_len > 2)
buf_len /= 2;
testSmallerRead = 1;
}
Expand Down

0 comments on commit 86c424f

Please sign in to comment.