chiark / gitweb /
prefork-interp: diagrams
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Aug 2022 14:26:12 +0000 (15:26 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Aug 2022 20:21:10 +0000 (21:21 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cprogs/prefork-interp.c

index f0bc785859743acd3a2d4267e4c777e995a0a3c5..105f21c5761edd66c5ea67c9dd7c9aab9d561d0d 100644 (file)
          |fork/exec                          
          |                                   
      CLIENT(C)                               
-      tidy up stale sockets etc.             
-      acquire lock                           
-      create listening socket                
          |                                   
-      fork/daemonise                         
+      attempt to connect, and read greeting
+         |failure?                \success?  
+         |                         \         
+      tidy up stale /run entries    continue from send_fds, below  
+      acquire lock                                                 
+         |                                                         
+      retry attempt to connect, and read greeting                  
+         |failure?                \success?                        
+         |                         \                               
+      create listening socket     release lock                     
+         |                           \                             
+      fork/daemonise                  continue from send_fds, below                    
          |    `------------------.           
          |                      WATCHER(C) &&
          |                                  
-       make "fake" initial call socketpair  
-         |                                  
-       fork/exec                            
-         |      `------.                    
-         |           SCRIPT (setup)         
-         |             |                    
-         |          script initialisation   
-         |             |                    
-         |          identify fds from envirnment
-         |          open syslog                 
-         |             |                           
-         |          dzemonize
-         |   ,...../   |                           
-      waitpid          |                           
-         |           fork for initial service            
-         |             |child        |parent                 
-         |             |             |                       
-         |             |         SCRIPT [server] &&
-         |             |             |                       
-         |             |         ** accept / event loop **   
-         |             |            /            \ \ \                   
-         |             |        accepted?         \ \ \idle timeout?     
-         |             |           |               \ \ \                 
-         |             |        fork child          \ \ \                
-         |             | _________/            watch | |watch stderr eof?
-         |             |/                      stderr| | |          
-         |        SCRIPT [monitor]                   | | |   
-         |             |                      log msg  | |   
-         |        send greeting                      | | |   
-      read greeting    |                             | | |   
-         |             |                             exit    
-      release lock     |                                     
-         |             |                                     
+       make "fake" initial call socketpair                       
+         |                                           C prefork-interp               
+       fork/exec  + + + + + + + + + + + + + + + + + + + + + + + + + + + +           
+         |      `------.                             Perl, application              
+         |      +    SCRIPT (setup)                                                 
+         |      +      |                                                            
+         |      +   script initialisation                                           
+         |      +      |                             Perl, application                     
+         |      + + + +| + + + + + + + + + + + + + + + + + + + + + + + +                   
+         |      +      |                             Perl, prefork-interp                      
+         |      +   identify fds from envirnment                        
+         |      +   open syslog                                         
+         |      +      |                                                
+         |      +   dzemonize                            
+         |   ,...../   |                                 
+      waitpid   +      |                                 
+         |      +    fork for initial service            
+         |      +      |child        |parent                 
+         |      +      |             |                       
+         |      +      |         SCRIPT [server] &&      
+         |      +      |             |                       
+         |      +      |         ** accept / event loop **   
+         |      +      |            /            \ \ \                   
+         |      +      |        accepted?         \ \ \idle timeout?     
+         |      +      |           |               \ \ \                 
+         |      +      |        fork child          \ \ \                
+         |      +      | _________/            watch | |watch stderr eof?
+         |      +      |/                      stderr| | |          
+         |      + SCRIPT [monitor]                   | | |   
+         |      +      |                      log msg  | |   
+         |      +   setpgrpt &                       | | |   
+         |      +      |                             | | |   
+         |      + send greeting                      | | |   
+      read greeting    |                             exit    
+         |      +      |                                     
+      release lock     |          from read greeting success, above 
+         |    ________ | ________/                       
+         |   /  +      |                                     
       send fds....     |                                     
-         |        receive fds                                
-         |             |                                     
-         |         fork for executor                         
-         |             |       \                             
-         |             |        \child
-         |             |         \                       
-         |             |        setpgrp &                
-         |             |        execute service          
-         |             |            |                    
-         |       wait for read      |    
-         |         (select)         |    
-         |           |   |          |          
-         |               |        exits  
-         |               |        kernel closes execterm
-         |               | ,......./|                   
-         |         execterm?        |    
-         |               |        zombie 
-         |               | ,....../      
-         |          waitpid              
-         |               |               
-         |          send exit status     
-      read exit status                   
-                                         
+         |      + receive fds                                
+         |      +         |                                  
+         |      +     fork for executor                      
+         |      +   p  |parent        \child         Perl, prefork-interp                                         
+         |      +      |        + + + + \+ + + + + + + + + + + + + + + +                            
+         |      +      |        +   execute service  Perl, application                                 
+         |      +      |        +       |                               
+         |      +wait for read  +       |                               
+         |      +  (select)     +       |                               
+         |      +    |   |      +       |                               
+         |      +        |      +     exits                             
+         |      +        |      +     kernel closes execterm            
+         |      +        | ,.........../|                               
+         |      +  execterm?    +       |                               
+         |      +        |      +     zombie                            
+         |      +        | ,........../             
+         |      +   waitpid     +
+         |      +        |      +                                         
+         |    ,..,..send status +
+    read status +               +                                         
+                +               +
                                          
   Or, if client is killed                
                                          
-         |             |            |          
-         |       wait for read      |    
-         |         (select)         |    
-         |           |   |          |          
-       exits         |              |    
-         |           |              |    
-     kernel closes   |              |    
-                \....|              |    
-                     call?          |    
-                     |              |    
-               kill whole pgrp...   |    
-                         |       killled
-                         |        zombie
-                         | ,....../
+         |             |                |      
+         |       wait for read          |    
+         |         (select)             |    
+         |           |   |              |      
+       exits         |                  |    
+         |           |                  |    
+     kernel closes   |                  |    
+                \....|                  |    
+                     call?              |    
+                     |                  |    
+               kill whole pgrp...       |    
+                         |           killled 
+                         |            zombie 
+                         | ,.....    ./      
                     waitpid
                          |  
                     send exit status