You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to #2525 I encountered a situation where incorrectly an out-of-memory was reported: a client connected to the Mosquitto broker, published a message and disconnected without properly waiting for the puback. The broker would then log a message saying the client disconnected due to out-of-memory while the correct error is "broken pipe".
I can fix this with a patch like the following (against 2.0.15):
diff --git a/src/handle_publish.c b/src/handle_publish.c
index 111f0316..8736812d 100644
--- a/src/handle_publish.c+++ b/src/handle_publish.c@@ -332,9 +332,9 @@ int handle__publish(struct mosquitto *context)
rc2 = sub__messages_queue(context->id, stored->topic, stored->qos, stored->retain, &stored);
/* stored may now be free, so don't refer to it */
if(rc2 == MOSQ_ERR_SUCCESS || context->protocol != mosq_p_mqtt5){
- if(send__puback(context, mid, 0, NULL)) rc = 1;+ rc = send__puback(context, mid, 0, NULL);
}else if(rc2 == MOSQ_ERR_NO_SUBSCRIBERS){
- if(send__puback(context, mid, MQTT_RC_NO_MATCHING_SUBSCRIBERS, NULL)) rc = 1;+ rc = send__puback(context, mid, MQTT_RC_NO_MATCHING_SUBSCRIBERS, NULL);
}else{
rc = rc2;
}
While this seems to fix my particular scenario with minimal changes I think more improvements can be done: it looks to me like rc2 can be eliminated (in the above piece of code at least). And if I look further in this file I think there are other cases where rc = 1 is done instead of propagating the return value of a helper function.
Grepping the code for rc = 1; reveals some other places that seem to me to warrant further investigation.
The text was updated successfully, but these errors were encountered:
Similar to #2525 I encountered a situation where incorrectly an out-of-memory was reported: a client connected to the Mosquitto broker, published a message and disconnected without properly waiting for the puback. The broker would then log a message saying the client disconnected due to out-of-memory while the correct error is "broken pipe".
I can fix this with a patch like the following (against 2.0.15):
While this seems to fix my particular scenario with minimal changes I think more improvements can be done: it looks to me like
rc2
can be eliminated (in the above piece of code at least). And if I look further in this file I think there are other cases whererc = 1
is done instead of propagating the return value of a helper function.Grepping the code for
rc = 1;
reveals some other places that seem to me to warrant further investigation.The text was updated successfully, but these errors were encountered: