chiark / gitweb /
New state diagrams for new startup/drop arrangements
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Tue, 20 Apr 2010 20:55:40 +0000 (21:55 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Tue, 20 Apr 2010 20:55:40 +0000 (21:55 +0100)
backends/innduct.c

index 9fcd2ff04ab0a3309bf4813a5102f65c6e59926a..85a27995b0b7ae641134c222717fabb1c43e9618 100644 (file)
 
                                                                START
                                                                   |
 
                                                                START
                                                                   |
-                                                             check D, F
-                                                                  |
-                          <--------------------------------------'|
-        Nothing                            F, D both ENOENT       |
-         F: ENOENT                                                       |
-         D: ENOENT                                                       |
-         duct: not not reading anything                           |
-           |                                                     |
-           |`---------------------.                               |
-           |                      | duct times out waiting for F  |
-           V  innd creates F      | duct exits                    |
-           |                      V                               |
-        Noduct                    GO TO Dropped                   |
-         F: innd writing                                         |
-         D: ENOENT                                               |
-         duct: not running or not reading anything                |
-           |                                                     |
-           |                                                     |
-     ,-->--+                   <---------------------------------'|
-     |     |  duct opens F                         F exists       |
-     |     |                                              D ENOENT       |
+     ,-->--.                                                 check F, D
+     |     |                                                      |
+     |     |                                                      |
+     |     |  <----------------<---------------------------------'|
+     |     |                                       F exists       |
+     |     |                                       D ENOENT       |
+     |     |  duct opens F                                        |
      |     V                                                     |
      |  Normal                                                    |
      |   F: innd writing, duct reading                            |
      |     V                                                     |
      |  Normal                                                    |
      |   F: innd writing, duct reading                            |
      |   F == D: innd writing, duct reading         both exist    |
      ^     |                                                      |
      |     |  duct unlinks F                                             |
      |   F == D: innd writing, duct reading         both exist    |
      ^     |                                                      |
      |     |  duct unlinks F                                             |
-     |     V                                                     |
-     |  Moved                               <----+------------<--'|
-     |   F: ENOENT                               |  F ENOENT      |
-     |   D: innd writing, duct reading           |  D exists      |
-     |     |                                     |               |
-     |     |  duct requests flush of feed        |               |
-     |     |   (others can too, harmlessly)      |               |
-     |     V                                    |                |
-     |  Flushing                                |                |
-     |   F: ENOENT                              |                |
-     |   D: innd flushing, duct reading                 |                |
-     |     |                                            |                |
-     |     |   inndcomm flush fails                     |                |
-     |     |`-------------------------->---------'               |
-     |     |                                                             |
+     |     |                        <-----------<-------------<--'|
+     |     |                           open D         F ENOENT    |
+     |     |                           if exists                  |
+     |     |                                                      |
+     |     V                        <---------------------.       |
+     |  Moved                                             |       |
+     |   F: ENOENT                                        |       |
+     |   D: innd writing, duct reading; or ENOENT         |       |
+     |     |                                              |      |
+     |     |  duct requests flush of feed                 |      |
+     |     |   (others can too, harmlessly)               |      |
+     |     V                                             |       |
+     |  Flushing                                         |       |
+     |   F: ENOENT                                               |       |
+     |   D: innd flushing, duct; or ENOENT               |       |
+     |     |                                                     |       |
+     |     |   inndcomm flush fails                              |       |
+     |     |`-------------------------->------------------'      |
+     |     |                                                             |
      |     |   inndcomm reports no such site                             |
      |     |`---------------------------------------------------- | -.
      |     |   inndcomm reports no such site                             |
      |     |`---------------------------------------------------- | -.
-     |     |                                                     |  |
+     |     |                                                     |  |
      |     |  innd finishes writing D, creates F                 |  |
      |     |  inndcomm reports flush successful                          |  |
      |     |                                                             |  |
      |     V                                                     |  |
      |  Separated                                <----------------'  |
      |   F: innd writing                            F!=D             /
      |     |  innd finishes writing D, creates F                 |  |
      |     |  inndcomm reports flush successful                          |  |
      |     |                                                             |  |
      |     V                                                     |  |
      |  Separated                                <----------------'  |
      |   F: innd writing                            F!=D             /
-     |   D: duct reading                             both exist     /
+     |   D: duct reading; or ENOENT                  both exist     /
      |     |                                                       /
      |     |  duct gets to the end of D                           /
      |     |  duct opens F too                                          /
      |     |                                                       /
      |     |  duct gets to the end of D                           /
      |     |  duct opens F too                                          /
@@ -1420,78 +1410,83 @@ static void inputfile_tailing_stop(InputFile *ipf) {
 /* See official state diagram at top of file.  We implement
  * this as follows:
 
 /* See official state diagram at top of file.  We implement
  * this as follows:
 
-          ================
-           WAITING
-          [Nothing/Noduct]
-           poll for F
-          ================
-               |
-               |     TIMEOUT and no defer, no backlog
-               |`--------------------------.
-               |                           |
-                | OPEN F SUCCEEDS           | exit
-     ,--------->|                           V
-     |          V                         =========
-     |     ========                        (ESRCH)
-     |      NORMAL                        [Dropped]
-     |     [Normal]                       =========
-     |      main F tail
-     |     ========
-     |          |
-     |          | F IS SO BIG WE SHOULD FLUSH
-     ^          | hardlink F to D
-     |     [Hardlinked]
-     |          | unlink F
-     |          | our handle onto F is now onto D
-     |     [Moved]
-     |          |
-     |          |<---------------------------------------------------.
+           .=======.
+           ||START||               
+            `======='
+                |                   
+                | open F            
+                |                   
+                |    F ENOENT                                        
+                |`---------------------------------------------------.
+      F OPEN OK |                                                    |
+                |`---------------- - - -                             |
+       D ENOENT |       D EXISTS   see OVERALL STATES diagram        |
+                |                  for full startup logic            |
+     ,--------->|                                                    |
+     |          V                                                    |
+     |     ============                                       try to |
+     |      NORMAL                                            open D |
+     |     [Normal]                                                  |
+     |      main F tail                                              |
+     |     ============                                                     V
+     |          |                                                           |
+     |          | F IS SO BIG WE SHOULD FLUSH, OR TIMEOUT           |
+     ^          | hardlink F to D                                   |
+     |     [Hardlinked]                                                     |
+     |          | unlink F                                          |
+     |          | our handle onto F is now onto D                   |
+     |     [Moved]                                                          |
+     |          |                                                           |
+     |          |<-------------------<---------------------<---------+
      |          |                                                    |
      |          | spawn inndcomm flush                               |
      |          V                                                    |
      |          |                                                    |
      |          | spawn inndcomm flush                               |
      |          V                                                    |
-     |     ==========                                                |
+     |     ================                                          |
      |      FLUSHING                                                 |
      |     [Flushing]                                                |
      |      FLUSHING                                                 |
      |     [Flushing]                                                |
-     |      main D tail                                              |
-     |     ==========                                                |
+     |     main D tail/none                                          |
+     |     ================                                          |
      |          |                                                    |
      |          |   INNDCOMM FLUSH FAILS                             ^
      |          |`----------------------->----------.                |
      |          |                                   |                |
      |          |   NO SUCH SITE                    V                |
      |          |                                                    |
      |          |   INNDCOMM FLUSH FAILS                             ^
      |          |`----------------------->----------.                |
      |          |                                   |                |
      |          |   NO SUCH SITE                    V                |
-     ^          |`--------------->----.          ===========         |
-     |          |                      \         FLUSHFAIL           |
-     |          |                       \        [Moved]             |
-     |          |                        \       main D tail         |
-     |          |                         \      ===========         |
+     ^          |`--------------->----.          ================    |
+     |          |                      \          FLUSHFAIL          |
+     |          |                       \         [Moved]            |
+     |          | FLUSH OK               \       main D tail/none    |
+     |          | open F                  \      ================    |
      |          |                          \        |                |
      |          |                           \       | TIME TO RETRY  |
      |          |                          \        |                |
      |          |                           \       | TIME TO RETRY  |
-     |          |                            \      `----------------'
-     |          | FLUSH OK                    \
-     |          | open F                       \
-     |          V                               V
-     |     =============                     ============
-     |      SEPARATED/                        DROPPING/
-     |      flsh->fd>=0                       flsh->fd>=0
-     |     [Separated]                       [Dropping]
-     |      main F idle                       main none
-     |      old  D tail                       old  D tail
-     |     =============                     ============
-     |          |                                 |
-     ^          | EOF ON D                        | EOF ON D
-     |          V                                 V
-     |     ===============                   ===============
-     |      SEPARATED/                        DROPPING/
-     |      flsh->fd==-1                      flsh->fd==-1
-     |     [Finishing]                       [Dropping]
-     |      main F tail                              main none
-     |      old  D closed                     old  D closed
-     |     ===============                          ===============
-     |          |                               |
-     |          | ALL D PROCESSED                | ALL D PROCESSED
-     |          V install defer as backlog       V install defer as backlog
-     ^          | close D                        | close D
-     |          | unlink D                       | unlink D
+     |<--------'|                   ,---<---'\      `----------------'
+     |  D NONE  |                   | D NONE  \                                     
+     |          |                   |          \                            
+     |          |                   |           |                                   
+     |          |                   V           |                    
+     |          V                   |           V                                   
+     |     =============            |        ============                    
+     |      SEPARATED/              |         DROPPING/                             
+     |      flsh->fd>=0             |         flsh->fd>=0                    
+     |     [Separated]              |        [Dropping]                             
+     |      main F idle             |         main none                             
+     |      old D tail              |         old D tail                      
+     |     =============            |        ============                    
+     |          |                   |          |                             
+     ^          | EOF ON D          |          | EOF ON D              
+     |          V                   |          V                                  
+     |     ===============          |        ===============  
+     |      SEPARATED/              |         DROPPING/              
+     |      flsh->fd==-1            V         flsh->fd==-1    
+     |     [Finishing]              |        [Dropping]              
+     |      main F tail                    `.        main none       
+     |      old D closed              `.      old D closed    
+     |     ===============                     `.   ===============  
+     |          |                        `.     |            
+     |          | ALL D PROCESSED           `.   | ALL D PROCESSED
+     |          V install defer as backlog    `. V install defer as backlog
+     ^          | close D                       \| close D    
+     |          | unlink D                       | unlink D   
+     |          |                                | unlink lock
      |          |                                | exit
      `----------'                                V
                                              ==========
      |          |                                | exit
      `----------'                                V
                                              ==========
@@ -1994,7 +1989,7 @@ EVERY(filepoll, {5,0}, {
   if (main_input_file && main_input_file->readable_callback)
     filemon_callback(main_input_file);
 });
   if (main_input_file && main_input_file->readable_callback)
     filemon_callback(main_input_file);
 });
+
 #define DEBUGF_IPF(wh) " " #wh "=%p/%s:ip=%ld,off=%ld,fd=%d%s" \
 #define DEBUG_IPF(sh)                                          \
   wh##_input_file, debug_ipf_path(wh##_input_file),            \
 #define DEBUGF_IPF(wh) " " #wh "=%p/%s:ip=%ld,off=%ld,fd=%d%s" \
 #define DEBUG_IPF(sh)                                          \
   wh##_input_file, debug_ipf_path(wh##_input_file),            \