@@ -119,7 +119,11 @@ static int wolfmqtt_net_read(void *context, byte *buf, int buf_len,
119119 }
120120
121121 ret = wolfIP_sock_recv (desc -> stack , desc -> fd , buf , buf_len , 0 );
122- if (ret == - WOLFIP_EAGAIN || ret == -1 ) {
122+ /* Only EAGAIN (TX/RX buffer transient) is retryable. A bare -1 from
123+ * wolfIP means the socket is no longer ESTABLISHED/CLOSE_WAIT (e.g. a
124+ * peer RST closed it); treat it as fatal so wolfMQTT does not busy-spin
125+ * on MQTT_CODE_CONTINUE forever. */
126+ if (ret == - WOLFIP_EAGAIN ) {
123127 return MQTT_CODE_CONTINUE ;
124128 }
125129 if (ret == 0 ) {
@@ -144,7 +148,12 @@ static int wolfmqtt_net_write(void *context, const byte *buf, int buf_len,
144148 }
145149
146150 ret = wolfIP_sock_send (desc -> stack , desc -> fd , buf , buf_len , 0 );
147- if (ret == - WOLFIP_EAGAIN || ret == -1 ) {
151+ /* Only EAGAIN (TX buffer full) is retryable. A bare -1 from wolfIP means
152+ * the socket is no longer ESTABLISHED/CLOSE_WAIT (e.g. a peer RST closed
153+ * it); treat it as fatal so wolfMQTT's publish retry loop does not
154+ * busy-spin on MQTT_CODE_CONTINUE forever (which on a single-threaded
155+ * target would stall wolfIP_poll and deny all network service). */
156+ if (ret == - WOLFIP_EAGAIN ) {
148157 return MQTT_CODE_CONTINUE ;
149158 }
150159 if (ret == 0 ) {
0 commit comments