Skip to content

Commit 09c731c

Browse files
committed
Revert "Add lastError to preserve TLS error code"
This reverts commit cb0f8f8.
1 parent 3f37af5 commit 09c731c

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

src/mqtt_socket.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ static int MqttSocket_WriteDo(MqttClient *client, const byte* buf, int buf_len,
143143

144144
rc = wolfSSL_write(client->tls.ssl, (char*)buf, buf_len);
145145
if (rc < 0) {
146+
#if defined(WOLFMQTT_DEBUG_SOCKET) || defined(WOLFSSL_ASYNC_CRYPT)
146147
int error = wolfSSL_get_error(client->tls.ssl, 0);
147-
client->tls.lastError = error;
148+
#endif
148149
#ifdef WOLFMQTT_DEBUG_SOCKET
149150
if (error != WOLFSSL_ERROR_WANT_WRITE
150151
#ifdef WOLFSSL_ASYNC_CRYPT
@@ -247,7 +248,6 @@ static int MqttSocket_ReadDo(MqttClient *client, byte* buf, int buf_len,
247248
rc = wolfSSL_read(client->tls.ssl, (char*)buf, buf_len);
248249
if (rc < 0) {
249250
int error = wolfSSL_get_error(client->tls.ssl, 0);
250-
client->tls.lastError = error;
251251
#ifdef WOLFMQTT_DEBUG_SOCKET
252252
if (error != WOLFSSL_ERROR_WANT_READ
253253
#ifdef WOLFSSL_ASYNC_CRYPT
@@ -404,9 +404,6 @@ int MqttSocket_Connect(MqttClient *client, const char* host, word16 port,
404404
#if defined(ENABLE_MQTT_TLS) && !defined(ENABLE_MQTT_CURL) && \
405405
!defined(ENABLE_MQTT_WEBSOCKET)
406406
if (use_tls) {
407-
/* Clear any previous TLS error */
408-
client->tls.lastError = 0;
409-
410407
if (client->tls.ctx == NULL) {
411408
#ifdef DEBUG_WOLFSSL
412409
wolfSSL_Debugging_ON();
@@ -505,8 +502,6 @@ int MqttSocket_Connect(MqttClient *client, const char* host, word16 port,
505502
) {
506503
return MQTT_CODE_CONTINUE;
507504
}
508-
/* Preserve the error to be used later, e.g. in net callback */
509-
client->tls.lastError = errnum;
510505
#ifdef WOLFMQTT_DEBUG_SOCKET
511506
errstr = wolfSSL_ERR_reason_error_string(errnum);
512507
#endif

wolfmqtt/mqtt_socket.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ typedef struct _MqttTls {
7373
int sockRcWrite;
7474
int timeout_ms_read;
7575
int timeout_ms_write;
76-
int lastError;
7776
} MqttTls;
7877
#endif
7978

0 commit comments

Comments
 (0)