I'm still trying to determine why my code freezes at times.
A log of this morning's crash shows :
The last two lines are from this piece of code. I've indicated the line numbers mentioned in the log.I (66541022) Peers: ImageFromPeerBinaryAsync 192.168.0.199 23457
I (66567102) Peers: ImageFromPeerBinaryAsync 192.168.0.199 23457
E (66569572) MQTT_CLIENT: Read error or end of stream
E (66569572) Keypad: STA_DISCONNECTED
I (66569572) Peers: Network disconnected
I (66569572) Peers: RestStop()
I (66569582) Peers: MulticastStop()
I (66569582) Peers: ImageServerStopTask()
I (66569582) Peers: ImageServerStopTask end
I (66569592) Peers: RestLoop: socket < 0
I (66574572) Peers: MQTT Client Stop : 0 ok
I (66574572) Peers: Network disconnected --> end of function
I (66574572) Keypad: Network disconnected
I (66576212) event: sta ip: 192.168.0.156, mask: 255.255.255.0, gw: 192.168.0.1
I (66576212) Keypad: Network connected
I (66576212) Peers: Network Connected, ip 192.168.0.156
I (66576212) Peers: RestSetup()
I (66576222) Peers: MulticastSetup()
I (66576222) Peers: NetworkConnected 114
I (66576232) Peers: ImageServerStartTask
I (66576232) Peers: NetworkConnected 116
I (66576242) Peers: QueryPeers 961
I (66576242) Peers: QueryPeers 973
Code: Select all
void Peers::QueryPeers() {
ESP_LOGI(peer_tag, "%s %d", __FUNCTION__, __LINE__); // <-- this is line 961
// Protect against nearly infinite loops
if (lastqp == 0) {
// We'll fall through, so launch an initial query
lastqp = time(0);
if (lastqp == 0) { // Complexity because time(0) initially returns time since boot
// Make sure to do this initial query just once
lastqp = 1;
}
ESP_LOGI(peer_tag, "%s %d, lastqp = %ld, do query", __FUNCTION__, __LINE__, lastqp);
} else {
ESP_LOGI(peer_tag, "%s %d", __FUNCTION__, __LINE__); // <-- this is line 973
time_t now = time(0); // Crash ??
ESP_LOGI(peer_tag, "%s %d", __FUNCTION__, __LINE__);
if (lastqp == 1) {
ESP_LOGI(peer_tag, "QueryPeers lastqp == 1 -> return");
return;
}
ESP_LOGI(peer_tag, "%s %d", __FUNCTION__, __LINE__);
Help, anyone ?
Thanks,
Danny