Event/Threading Model

From reSIProcate
Jump to: navigation, search

The threading model in the stack requires the application to build an FdSet and call process on the stack. The select call needs a timeout value which the stack can also determine. The application may need to add its own file descriptors and timers as well.

buildFdSet[edit]

  • anything in the stack or the application that uses a file descriptor needs to add itself to the FdSet
  • this should start with an empty FdSet
  • next call SipStack::buildFdSet and this will add the file descriptors for all of the transports, connections and the dns provider
  • next add any application file descriptors

getTimeTillNextProcess[edit]

  • determines the minimum time till any timer in the application or stack will fire
  • if anything in the stack needs to process immediately, short circuit and return 0. (Currently, the dns provider short circuits with a value of 50ms?)

select[edit]

  • call select either in the Application or in a StackThread and pass in the two things constructed above

process[edit]

  • after select returns, pass the now marked up FdSet to SipStack::process
  • process delegates to anything in the SipStack that needs cycles periodically
    • ask the StatisticsManager to generate its stats
    • ask the Transports to send/receive and accept new connections
    • give the dns provider / cache cycles
    • process App and Transaction Timers
    • handle all outstanding events affecting TransactionState
    • handle TU shutdown related events


WARNING!!! Under windows the default FD_SETSIZE is 64 so using TCP/TLS transports is limited