From MozillaWiki
Jump to: navigation, search

NNTP Implementation Notes

NNTP State Diagram

The included file is a simplified diagram of the state machine for NNTP (the true diagram is about twice as large with unneeded complexity). It was generated with a python script run on nsNNTPProtocol.cpp and then hand-edited to fix some edge cases and remove some complexity. It is not embedded in the page due to its large size.

Most nodes are labeled in the form "FunctionName (STATE_NAME)". These nodes are the core states, called by ProcessProtocolState during each iteration. If no state name is given, it is not a state function, but an important function interacting with the state functions that modify the next state. Double-octagon nodes are states which end processing; the single diamond node the initiation of the state machine. Red nodes are nodes which can call up an error dialog box under certain conditions.

The lines show the flow between different states. Regular black lines are standard transitions. Dotted black lines, on the other hand, indicate that more states or function calls happen before proceeding to the next state. For the most part, this elided state transition is a transition to NNTP_RESPONSE. Red lines indicate direct function calls.

A few states have been elided for various reasons. The two error states and three completion states have been removed to keep the number of crisscrossing lines down. An unneeded auxiliary function after SEND_FIRST_NNTP_COMMAND_RESPONSE has been removed also to keep lines down and the graph generation program sane. A long branch of states that are not compiled in most builds has been removed; similarly, other unused or unimplemented states have been removed.

The boxes surrounding some nodes are a means of collapsing the states into groups. It is an imperfect collapse primarily due to the sharing of states and state paths between article retrieval, article posting, and article canceling. At the top of most boxes is the URL needed to trigger that path of states. The two unlabelled boxes are the authentication states and the internal article selection states, which are not triggered by specific URLs.

Currently, a rewrite of this backend is underway. Many of the nonfunctional states not present in this picture will be removed in the process of this rewrite. The graphical choke point, SEND_FIRST_NNTP_COMMAND, will also be removed in this process. Other states will be renamed to be more descriptive and to hold a common naming scheme. Finally, thorough documentation of the interaction between various states will be added to nsNNTPProtocol.h.

(Description written by Joshua Cranmer)