1=========================================================================
2 State machine transitions for the Crash Generation Server
3=========================================================================
4
5=========================================================================
6               |
7 STATE         | ACTIONS
8               |
9=========================================================================
10 ERROR         | Clean up resources used to serve clients.
11               | Always remain in ERROR state.
12-------------------------------------------------------------------------
13 INITIAL       | Connect to the pipe asynchronously.
14               | If connection is successfully queued up asynchronously,
15               | go into CONNECTING state.
16               | If connection is done synchronously, go into CONNECTED
17               | state.
18               | For any unexpected problems, go into ERROR state.
19-------------------------------------------------------------------------
20 CONNECTING    | Get the result of async connection request.
21               | If I/O is still incomplete, remain in the CONNECTING
22               | state.
23               | If connection is complete, go into CONNECTED state.
24               | For any unexpected problems, go into DISCONNECTING state.
25-------------------------------------------------------------------------
26 CONNECTED     | Read from the pipe asynchronously.
27               | If read request is successfully queued up asynchronously,
28               | go into READING state.
29               | For any unexpected problems, go into DISCONNECTING state.
30-------------------------------------------------------------------------
31 READING       | Get the result of async read request.
32               | If read is done, go into READ_DONE state.
33               | For any unexpected problems, go into DISCONNECTING state.
34-------------------------------------------------------------------------
35 READ_DONE     | Register the client, prepare the reply and write the
36               | reply to the pipe asynchronously.
37               | If write request is successfully queued up asynchronously,
38               | go into WRITING state.
39               | For any unexpected problems, go into DISCONNECTING state.
40-------------------------------------------------------------------------
41 WRITING       | Get the result of the async write request.
42               | If write is done, go into WRITE_DONE state.
43               | For any unexpected problems, go into DISCONNECTING state.
44-------------------------------------------------------------------------
45 WRITE_DONE    | Read from the pipe asynchronously (for an ACK).
46               | If read request is successfully queued up asynchonously,
47               | go into READING_ACK state.
48               | For any unexpected problems, go into DISCONNECTING state.
49-------------------------------------------------------------------------
50 READING_ACK   | Get the result of the async read request.
51               | If read is done, perform action for successful client
52               | connection.
53               | Go into DISCONNECTING state.
54-------------------------------------------------------------------------
55 DISCONNECTING | Disconnect from the pipe, reset the event and go into
56               | INITIAL state and signal the event again. If anything
57               | fails, go into ERROR state.
58=========================================================================
59