samples: net: google_iot_mqtt: Change read publish to blocking

Avoid endless loop in `case MQTT_EVT_PUBLISH`
Fail on any error for mqtt_read_publish_payload_blocking, inc. -EAGAIN.

Fixes zephyrproject-rtos#40965

Signed-off-by: Jeffrey Urban <jeffrey@jeffreyurban.com>
This commit is contained in:
Jeffrey Urban 2021-12-10 09:42:12 -05:00 committed by Carles Cufí
commit 34a958f545

View file

@ -165,10 +165,10 @@ void mqtt_evt_handler(struct mqtt_client *const client,
/* assuming the config message is textual */ /* assuming the config message is textual */
while (len) { while (len) {
bytes_read = mqtt_read_publish_payload( bytes_read = mqtt_read_publish_payload_blocking(
client, d, client, d,
len >= 32 ? 32 : len); len >= 32 ? 32 : len);
if (bytes_read < 0 && bytes_read != -EAGAIN) { if (bytes_read < 0) {
LOG_ERR("failure to read payload"); LOG_ERR("failure to read payload");
break; break;
} }