owlib client persistence

Algorithm for OWLIB connections to another owlib-based program

  • Example owfs to owlib, owhttpd to owlib, ...
  • Goal: efficient communication: persistent connections if possible.
  • Server may not allowpersistent connection, either too old, or to busy.
  • Persistent connection may have timed out.

STEP 1: Attempt a connection with a message

  • Message is read, write, dir, ...

STEP 1A: Existing persistent free

  • Use a free persistent connection if available (from prior connection)
    • in->fd > -1
  • May have timed out (connection will fail)
    • flag persistent as free (in->fd = -1)
    • Retry new connection if timed out (STEP 1B)
  • Flag persistent connection as in use (in->fd = -2) until response done

STEP 1B: No existing persistent connection

  • Ask for persistent connection if appropriate
    • look at response to see oif persistence was granted
  • Flag persistent as in use (in->fd = -2) until response complete

STEP 1C: Non-persistent connection

  • Server too busy
  • Server doesn't support persistence
  • Persistent connection in use by another thread
  • Flag persistent connection as none (in->fd = -1)
  • No special handling of end of transaction

STEP 2: Transaction complete

  • Response complete
  • Error response
  • Time out with no "keep-alive"

STEP 2A: Persistent transaction complete

  • Flag persistent connection as available (in->fd==-2 becomes in->fd=fd)

STEP 2B: Non-persistent transaction complete

  • No special handling


  • Initial setup: persistent == non-persistent
  • Successful reuse: persistent << non-persistent
  • Unsuccessful reuse persistent = non-persistent + 1
  • Persistent in use by another thread: same as non-persistent


Previous page: Persistent connections
Next page: Directory Messages