Skip to content

Commit bd5e4db

Browse files
authored
Merge pull request #2551 from cesanta/mqttpayload
Avoid calling mg_send on no actual payload
2 parents 744df7b + 2427c40 commit bd5e4db

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mongoose.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3990,7 +3990,7 @@ void mg_mqtt_pub(struct mg_connection *c, const struct mg_mqtt_opts *opts) {
39903990

39913991
if (c->is_mqtt5) mg_send_mqtt_properties(c, opts->props, opts->num_props);
39923992

3993-
mg_send(c, opts->message.ptr, opts->message.len);
3993+
if (opts->message.len > 0) mg_send(c, opts->message.ptr, opts->message.len);
39943994
}
39953995

39963996
void mg_mqtt_sub(struct mg_connection *c, const struct mg_mqtt_opts *opts) {

src/mqtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ void mg_mqtt_pub(struct mg_connection *c, const struct mg_mqtt_opts *opts) {
338338

339339
if (c->is_mqtt5) mg_send_mqtt_properties(c, opts->props, opts->num_props);
340340

341-
mg_send(c, opts->message.ptr, opts->message.len);
341+
if (opts->message.len > 0) mg_send(c, opts->message.ptr, opts->message.len);
342342
}
343343

344344
void mg_mqtt_sub(struct mg_connection *c, const struct mg_mqtt_opts *opts) {

0 commit comments

Comments
 (0)