Help: time(0) crash/freeze

DannyBackx
Posts: 33
Joined: Wed Sep 19, 2018 7:17 pm

Help: time(0) crash/freeze

Postby DannyBackx » Sat Dec 22, 2018 12:42 pm

Hi,

I'm still trying to determine why my code freezes at times.
A log of this morning's crash shows :
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
The last two lines are from this piece of code. I've indicated the line numbers mentioned in the log.

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__);
This appears to indicate that the time(0) call freezes.

Help, anyone ?

Thanks,

Danny

Who is online

Users browsing this forum: Baidu [Spider], iParcelBox and 136 guests