Try something for linux stuck test

This commit is contained in:
Johannes Schriewer 2018-08-06 02:17:39 +02:00
parent e260a906f8
commit 636840641e
3 changed files with 9 additions and 4 deletions

View file

@ -256,7 +256,7 @@ PlatformStatusCode platform_create_timer(MQTTHandle *handle, int interval, int *
uint8_t free_timer = 0;
for (free_timer = 0; free_timer < MAX_TIMERS; free_timer++) {
DEBUG_LOG("Timer %d: %s", free_timer, p->timers[free_timer].callback ? "Occupied" : "Free");
// DEBUG_LOG("Timer %d: %s", free_timer, p->timers[free_timer].callback ? "Occupied" : "Free");
if (p->timers[free_timer].callback == NULL) {
break;
}

View file

@ -211,6 +211,8 @@ static void _mqtt_connect(MQTTHandle *handle, MQTTEventHandler callback, void *c
return;
}
expect_packet(handle, PacketTypeConnAck, 0, callback, context);
if (!handle->reader_alive) {
if (handle->read_task_handle >= 0) {
platform_cleanup_task(handle, handle->read_task_handle);
@ -223,8 +225,6 @@ static void _mqtt_connect(MQTTHandle *handle, MQTTEventHandler callback, void *c
}
}
expect_packet(handle, PacketTypeConnAck, 0, callback, context);
bool result = send_connect_packet(handle);
if (result == false) {
DEBUG_LOG("Sending connect packet failed, running error handler");
@ -262,6 +262,8 @@ MQTTHandle *mqtt_connect(MQTTConfig *config, MQTTEventHandler callback, void *co
handle->config = config;
handle->error_handler = error_callback;
handle->read_task_handle = -1;
handle->keepalive_timer = -1;
_mqtt_connect(handle, callback, context);

View file

@ -21,6 +21,10 @@ void mqtt_reconnected(MQTTHandle *handle, void *context) {
void callback(MQTTHandle *handle, char *topic, char *payload) {
LOG("Received publish: %s -> %s", topic, payload);
if (leave == 0) {
mqtt_reconnect(handle, mqtt_reconnected, NULL);
}
leave++;
}
@ -54,7 +58,6 @@ int main(int argc, char **argv) {
LOG("Waiting for first publish...");
platform_sleep(1000);
}
mqtt_reconnect(mqtt, mqtt_reconnected, NULL);
while (leave < 2) {
LOG("Waiting for second publish...");