lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #61837] DNS Table State Deadlock On NTP Retry


From: HB
Subject: [lwip-devel] [bug #61837] DNS Table State Deadlock On NTP Retry
Date: Sun, 13 Feb 2022 18:24:24 -0500 (EST)

Follow-up Comment #1, bug #61837 (project lwip):

Forgot to allocate a PCB when an enqueued request is found, resulting in the
dns send to fail. Updated as such:



static void
dns_check_entry(u8_t i)
{

    ...

    case DNS_STATE_ASKING:
      if (--entry->tmr == 0) {
        if (++entry->retries == DNS_MAX_RETRIES) {
          if (dns_backupserver_available(entry)
#if LWIP_DNS_SUPPORT_MDNS_QUERIES
              && !entry->is_mdns
#endif /* LWIP_DNS_SUPPORT_MDNS_QUERIES */
             ) {
            /* change of server */
            entry->server_idx++;
            entry->tmr = 1;
            entry->retries = 0;
          } else {
            LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": timeout\n",
entry->name));
            /* call specified callback function if provided */
            dns_call_found(i, NULL);

            /* Check to see if new DNS request was enqueued by resulting call
back
            * if so, we don't want to change the state to unused, doing so
would brick the DNS
            * entry as the state would be set as unused, but a request would
exist. As the request
            * exists, we cannot enqueue a new request, forcing the block to
stay unused.
            */

            u8_t enqueued_request = dns_check_for_request(i);

            /* Flush or reset based on enqueued response */
            if (enqueued_request) {
                entry->state = DNS_STATE_NEW;
                entry->pcb_idx = dns_alloc_pcb();
            } else {
                entry->state = DNS_STATE_UNUSED;
            }

          }
        }

    ...

}





/**
 * dns_check_entries() - Checks if there is a DNS request enqueued for
dns_table
 * @param i - dns_table index
 * @return 1 for request found, 0 for no request found.
 */
static u8_t
dns_check_for_request(u8_t i)
{
  u8_t callback_enqueued_request = 0;
  for (u8_t idx = 0; idx < DNS_MAX_REQUESTS; idx++) {
    if (dns_requests[idx].found != NULL && dns_requests[idx].dns_table_idx ==
i) {
      return 1;
    }
  }

  return 0;
}




    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?61837>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]