Ticket #1130 (closed defect: fixed)

Opened 7 years ago

Last modified 7 years ago

Incoming TCP connection on iPhone iOS4 BG mode would fail over and over with EAGAIN error (thanks Bogdan Krakowski for the report)

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-1.8.5
Component: pjsip Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description (last modified by ming) (diff)

From accept() manual: There may not always be a connection waiting after a SIGIO is delivered or select(2) or poll(2) return a readability event because the connection might have been removed by an asynchronous network error or another thread before accept() is called.

In iOS4, the problem is reproducible by putting the app to BG and locking the device, hence causing iOS4 to close all connections. When application is brought back to the FG, select() always returns a readability event while accept() always fails with EAGAIN error.

There was a report that the problem happened in Sun Solaris OS as well.

Change History

comment:1 Changed 7 years ago by ming

  • Description modified (diff)

comment:2 Changed 7 years ago by ming

  • Status changed from new to closed
  • Resolution set to fixed

(In [3316]) Fixed #1130 Since the problem may not be iOS4 specific, a general approach is adopted to fix the problem.

comment:3 Changed 7 years ago by ming

  • Description modified (diff)

comment:4 Changed 7 years ago by ming

To fix this, we create a counter and record the last error that we encountered from the accept() operation. If we get the same error, we increase the counter, otherwise the counter will be reset to zero. Once the counter reaches PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR, no further accept() operations will be called.

Note: See TracTickets for help on using tickets.