Skip to content
Snippets Groups Projects
Closed [NAT-PMP] simplify and improve reliability of readResponse function
  • View options
  • [NAT-PMP] simplify and improve reliability of readResponse function

  • View options
  • Closed Issue created by François-Simon Fauteux-Chapleau

    The NatPmp::readResponse function is responsible for calling libnatpmp's readnatpmpresponseorretry. According to the libnatpmp documentation (see here or here), readnatpmpresponseorretry should be called "as long as it returns NATPMP_TRYAGAIN." The maximum number of times this can happen is determined by the NATPMP_MAX_RETRIES macro (see natpmp.h), whose default value is 9 (but a different value could be chosen at compile-time). However, NatPmp::readResponse limits the number of calls to readnatpmpresponseorretry to MAX_READ_RETRIES, a DHTNet macro whose current value is 3.

    This means that it's in principle possible (albeit unlikely in practice) for NatPmp::readResponse to fail to call readnatpmpresponseorretry enough times, which could lead to the kind of bug described in issue #33 (closed). It would therefore probably be better to get rid of the redundant MAX_READ_RETRIES and simply rely on the NATPMP_MAX_RETRIES limit defined by libnatpmp. Similarly, we probably don't need to sleep for TIMEOUT_BEFORE_READ_RETRY milliseconds each time readnatpmpresponseorretry returns NATPMP_TRYAGAIN in addition to using the timeout values provided by libnatpmp's getnatpmprequesttimeout function; getting rid of this would simplify the code and reduce the amount of time spent waiting in case of error.

    Linked items 0

  • Link items together to show that they're related or that one is blocking others.

    Activity

    • All activity
    • Comments only
    • History only
    • Newest first
    • Oldest first
    Loading Loading Loading Loading Loading Loading Loading Loading Loading Loading