samples: net: mqtt_publisher: handle EAGAIN from mqtt_live()

Now that mqtt_live() can send an EAGAIN message meaning: no ping
was generated, let's handle that in process_mqtt_and_sleep() by
skipping the call to mqtt_input() since no data will be expected.

Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
Michael Scott 2020-01-27 12:44:50 -08:00 committed by Anas Nashif
commit 3e24eb8af1

View file

@ -382,15 +382,15 @@ static int process_mqtt_and_sleep(struct mqtt_client *client, int timeout)
wait(remaining);
rc = mqtt_live(client);
if (rc != 0) {
if (rc != 0 && rc != -EAGAIN) {
PRINT_RESULT("mqtt_live", rc);
return rc;
}
rc = mqtt_input(client);
if (rc != 0) {
PRINT_RESULT("mqtt_input", rc);
return rc;
} else if (rc == 0) {
rc = mqtt_input(client);
if (rc != 0) {
PRINT_RESULT("mqtt_input", rc);
return rc;
}
}
remaining = timeout + start_time - k_uptime_get();