Skip to content

Event Threading Model

Scott Godin edited this page Jan 29, 2021 · 2 revisions

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.

Table of Contents

buildFdSet

  • 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

  • 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

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

process

  • 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 Transaction State
    • handle TU shutdown related events
 WARNING!!! Under windows the default FD_SETSIZE is 64 so using TCP/TLS transports is limited
Clone this wiki locally