!==
!== Architecture.txt for IServerd snapshot 04 Nov 2000
!==
Contributor:	Dmitry A. Panov <redfox@mail.khstu.ru>
Date:		04 November 2000
Updated:	14 May 2001 by Regressor <AVShutko@mail.khstu.ru>

Subject:	IServerd architecture 
============================================================================


  <<                          
  V                                                                     
                           
 MS >   SP ==> PP1 +===>    + EP                 DB 
     poll()                               
          daemon                          Online 
   US >      ==> PP2 +===> <>      
                                     Users  
                                                              
    < wwp,info...          ... <>  Msgs   
                                                               
                                             
 <<  BP  <====== =====> PPn +===> Timer         
                               


 MS  --  Main socket		 (UDP socket for clients)
 US  --  Webpager socket	 (unix domain socket for wwp messages)
 SP  --  Socket Processor	 (control socket, manage childs)
 PP  --  Packet Processors (n)   (process messages)
 EP  --  Event Processor         (confirm and timeout actions processing)
 BP  --  Busy processor		 (live-time limited kamikaze-process)
 
 ==> --  IPC pipe		 (IPC pipe based on unix domain sockets )
 > --  database connection	 (connection to main database)
 
   Socket processor listen sockets and put all data in interprocess pipe. 
Also it  manage childrens - if any child exits  SP fork new  one to keep 
mininum number of childs correct. 

   Packets  processors read  from interprocess  unnamed pipe and process 
packets (they work with database  server directly). They (PP's) send ask 
packets  directly to  socket and  reply packets  to second pipe (pipe to 
event-processor). Read and write to pipe are coordinated by semaphores. 

   Event processor keep list of unconfirmed packets and resend them after 
timeout, also it keep online users cache-list and track their keep-alive 
timeout. If packet-processor receive ask message it send SYSV IPC message 
to event-processor, which delete confirmed packet from list.

   If socket  processor  detect server overloading (number of packets in 
first pipe exeeds limit) it fork special children with  limited livetime 
this children read packets from pipe and send "busy" reply. This special 
children called "Busy processor" - it doesn't use any blocking call  and 
can help if server are flooded.

