tweaked old docs
authorArt Cancro <ajc@citadel.org>
Tue, 24 Jul 2018 20:12:17 +0000 (16:12 -0400)
committerArt Cancro <ajc@citadel.org>
Tue, 24 Jul 2018 20:12:17 +0000 (16:12 -0400)
citadel/docs/build.txt
citadel/docs/citadel_thread_io.txt [deleted file]
citadel/docs/logging.txt [deleted file]
citadel/docs/smtpclient.txt

index 56c74d0449cb93faa01c6cba10f61c6aa07613aa..b50f8f3c414cbc669958ef3a8d513cc5a81e0882 100644 (file)
@@ -1,6 +1,6 @@
 Some notes on the build process...
   
 Some notes on the build process...
   
- Oct 28 01:57 1998 from LoanShark @uncnsrd 
+ Oct 28 01:57 1998 from LoanShark
 
   autodependency generation is implemented by generating a bunch of .d  
 files (with another suffix rule) using $(CC) - M and "-include"-ing them 
 
   autodependency generation is implemented by generating a bunch of .d  
 files (with another suffix rule) using $(CC) - M and "-include"-ing them 
@@ -11,7 +11,7 @@ GNU make, but the Makefile should still work on other versions of Unix
 make, just without the autodependency stuff. 
 
 
 make, just without the autodependency stuff. 
 
 
- Oct 28 20:49 1998 from LoanShark @uncnsrd 
+ Oct 28 20:49 1998 from LoanShark
 one thing I forgot to mention about the autodependency generation: for a 
 file to be included in the autodepend process, it must be listed in the 
 SOURCES macro near the top of Makefile.in. 
 one thing I forgot to mention about the autodependency generation: for a 
 file to be included in the autodepend process, it must be listed in the 
 SOURCES macro near the top of Makefile.in. 
diff --git a/citadel/docs/citadel_thread_io.txt b/citadel/docs/citadel_thread_io.txt
deleted file mode 100644 (file)
index bdcae91..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-====== How Threads & IO for clients work ======
-Citserver is a multi thread process. It has four types of threads: 
-  - Workers - these are anonymous threads which can do any of the server related functions like Imapserver; smtpserver; citadel protocol and so on.
-  - Housekeeping - once per minute one Worker becomes the Housekeeping thread which does recurrent jobs like database maintenance and so on.
-  - IO - one thread is spawned to become the IO-Thread at startup. Inside it lives the event-queue which is implemented by libev.
-  - DB-IO - one thread is spawned to become the database IO thread. Inside it lives another event-queue, which is also implemented by libev.
-
-
-===== Worker Threads =====
-The workers live blocking on selects to server sockets. Once IO on a server socket becomes available, one thread awakes, and takes the task.
-It is then assigned a CitContext structure on a Thread global var (accessible via the CC macro), which then becomes his personality and controls what the thread is going to do with the IO,
-and which server code (Imap/SMTP/Citadel/...) is going to evaluate the IO and reply to it.
-
-===== Housekeeping Thread =====
-Once every minute one Worker becomes something special: the Housekeeping Thread. Only one Houskekeeper can exist at once. As long as one Housekeeper is running no other is started.
-Jobs done by the Housekeeper are registered via the <>-API. The current list:
-
-  - DB maintenance; flush redo logs etc.
-  - fulltext index (this one is a little problematic here, since it may be long running and block other housekeeping tasks for a while)
-  - Networking-Queue
-  - Citadel Networking Queue aggregator (Blocks NTT)
-  - Citadel Inbound Queue operator (Blocks NTT)
-  - Citadel Networking Queue
-  - SMTP-Client-Queue
-  - RSS-Aggregator scheduling
-  - HTTP-Message Notification Queue (Extnotify)
-  - POP3Client Queue
-
-The queues operate over their respective queue; which may be implemented with a private room (smtp-Queue, Extnotify Client), per room configs (RSS-Client; POP3Client), or an aggregate of Rooms/Queue/Roomconfigs (Citadel Networker).
-
-
-==== Networking Queue ====
-The networking queue opperats over an aggregate of per room network configs and messages in rooms that are newer than a remembered whatermark (netconfigs.txt#lastsent). 
-All messages Newer than the watermark are then processed: 
-  - for all mailinglist recipients an entry is added to the mailqueue
-  - for all mailinglist digest recipients a digest file is written, or once per day scheduled to 
-  - for all Citadel networking nodes a spool file is written for later evaluation.
-
-==== Citadel Networking Queue aggregator ====
-The aggregator iterates over the spool directory, and combines all per message spool files to one big file which is to be sent by the Citadel Networking Queue later.
-It blocks the NTT-List for the remote party while doing so; if the NTT-List is blocked the file is skipped for next operation. Once all files are successfully processed, all files not associated with a networking config are flushed.
-
-==== Citadel Inbound Queue operator ====
-The inbound queue operator scans for new inbound spool files, processes them, splits them into messages which are then posted into their respective rooms.
-
-
-==== other Queues ====
-Once these Queue-operators have identified a job to be performed like 
-  - talking to another Citadel Node to transfer spool files back and forth
-  - sending mails via SMTP
-  - polling remote POP3-Servers for new mails
-  - fetching RSS-Feeds via HTTP
-  - Notifying external facilities for new messages in inboxes via HTTP
-
-They create a Context for that Job (AsyncIO struct) plus their own Private data, plus a CitContext which is run under the privileges of a SYS_* user.
-HTTP Jobs just schedule the HTTP-Job, and are then called back on their previously registered hook once the HTTP-Request is done.
-
-All other have to implement their own IO controled business logic.
-
-
-===== IO-Thread =====
-The IO-Event-queue lives in this thread. Code running in this thread has to obey several rules.
-  - it mustn't do blocking operations (like disk IO or nameserver lookups other than the c-ares facilities) 
-  - it mustn't use blocking Sockets
-  - other threads mustn't access memory belonging to an IO job
-  - New IO contexts have to be registered via QueueEventContext() from other threads; Its callback are then called from whithin the event queue to start its logic.
-  - New HTTP-IO contexts have to be registered via QueueCurlContext() 
-  - once you've registered a context, you must not access its memory anymore to avoid race conditions.
-
-==== Logic in event_client ====
-InitIOStruct() which prepares an AsyncIO struct for later use before using QueueEventContext() to activate it.
-Here we offer the basics for I/O; Hostname lookus, connecting remote parties, basic read and write operation control flows.
-This logic communicates with the next layer via callback hooks. Before running hooks or logging CC is set from AsyncIO->CitContext
-Most clients are stacked that way: 
-
-<event base> --- <IO grammer logic> -- <state machine dispatcher> -- <state hooks>
-
-=== event base ===
-While the event base is responsible for reading and writing, it just does so without the understanding of the protocol it speaks. It at most knows about chunksises to send/read, or when a line is sent / received.
-=== IO grammer logic ===
-The IO grammer logic is implemented for each client. It understands the grammer of the protocol spoken; i.e. the SMTP implementation knows that it has to read status lines as long as there are 3 digits followed by a dash (i.e. in the ehlo reply). Once the grammer logic has decided a communication state is completed, it calls the next layer.
-
-=== state machine dispatcher ===
-The state machine dispatcher knows which part of the application logic is currently operated. Once its called, it dispatches to the right read/write hook. Read/write hooks may in term call the dispatcher again, if they want to divert to another part of the logic.
-
-=== state hooks ===
-The state hooks or handlers actualy PARSE the IO-Buffer and evaluate what next action should be taken; 
-There could be an error from the remote side so the action has to be aborted, or usually simply the next state can be reached.
-
-
-=== surrounding businesslogic ===
-Depending on the protocol there has to be surrounding business logic, which handles i.e. nameserver lookups, which ips to connect, what to do on a connection timeout, or doing local database IO.
-
-===== DB-IO-Thread =====
-Since lookups / writes to the database may take time, this mustn't be done inside of the IO-Eventloop. Therefore this other thread & event queue is around. 
-Usually a context should respect that there may be others around also wanting to do DB IO, so it shouldn't do endless numbers of requests.
-While its ok to do _some_ requests in a row (like deleting some messages, updating messages, etc.),
-loops over unknown numbers of queries should be unrolled and be done one query at a time (i.e. looking up messages in the 'already known table')
-
-=== Transitioning back & forth ===
-If the application logic has found that a transition is to be made from the event IO to the DB IO thread. Do so by calling DBQueueEventContext() (DB -> IO) EventQueueDBOperation() (IO->DB) and pass its return value up the row to enable the controll logic to do the actual transition for you. 
diff --git a/citadel/docs/logging.txt b/citadel/docs/logging.txt
deleted file mode 100644 (file)
index 425683d..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-=====Logging =====
-Note: the logging scheme is not yet persistant all over the citserver. 
-
-citadel server has several components that emmit different log strings. Its designed so you can filter for specific sessions. 
-
-Since there are several sources for numbering schemes, several numbers need to be employed to make one job / session completely traceable.
-The syntax is in general like CC[%d] 
-
-
-=== CC - Citadel Context ===
-All contexts that are visible to the RWHO command have a citadel context.  The ID of such a context is generated from a source that can grow and shrink again. Thus CC may not be uniq to one session.
-
-Citadel may have several kind of sessions: 
-  - sessions generated by external connections; they have a CC.
-  - sessions spawned by repetive tasks; they at first may have their own id-range, then later on an IO (AsyncIO) and CC (Citadel Context)
-
-=== Identifieing running sessions ===
-The RWHO command will list you the currently active CCs:
-
-# sendcommand RWHO
-sendcommand: started (pid=14528) connecting to Citadel server at /var/run/citadel/citadel-admin.socket
-200 potzblitz Citadel server ADMIN CONNECTION ready.
-RWHO
-100  
-576|SYS_rssclient||http://xkcd.org/rss.xml||0||.||||0
-1965|willi|Mail|PotzBlitz|IMAP session|1346695500|    |.||||1
-sendcommand: processing ended.
-
-576 is the CC connected to this client. with 
-
-grep 'CC\[576\]' /var/log/syslog 
-
-will show you the loglines from all contexts that had the ID 576; the one named above is an RSS aggregator:
-
-Jul  3 09:07:01 PotzBlitz citserver[1435]: EVCURL:IO[576]CC[576] error description: The requested URL returned error: 404
-Jul  3 09:07:01 PotzBlitz citserver[1435]: EVCURL:IO[576]CC[576] error performing request: HTTP response code said error
-Jul  3 09:07:01 PotzBlitz citserver[1435]: IO[576]CC[576][29]RSSPneed a 200, got a 404 !
-
-
-grep 'CC\[1965\]' /var/log/syslog 
-will show you the loglines from all contexts that had the ID 1965; the one named above is an inbound IMAP Connection:
-
-Jul  3 09:05:01 PotzBlitz citserver[12826]: IMAPCC[1965] <plain_auth>
-Jul  3 09:05:01 PotzBlitz citserver[12826]: CC[1965]<Lobby> 144 new of 144 total messages
-Jul  3 09:05:02 PotzBlitz citserver[12826]: CC[1965]<0000000010.Mail> 1 new of 17 total messages
-
-=== Numbering and prefixes ===
-
-While external sessions will constantly show the same CC (or maybe add their own name space as above with IMAPCC) Its important to understand that not all numbers are available in all situations with sessions from repetive tasks; thus you may need several filters to gather all logmessages belonging to one job.
-
-Generaly once per minute one worker becomes an housekeeping thread; This housekeeper scans the whole system for jobs to start.
-Once a job is identified, its detection is logged; neither a CC nor IO are already assigned to this job yet;
-but it already has its uniq number assigned to it which is specific to the type of task. 
-After the preanalysis of this job is done, it may become an AsyncIO job with a Citadel Context. The job now lives in one of the eventqueues, waiting for external file IO or Database IO or performing some calculation of a new state.    
-Some basic IO debug logging may not facilitate the CC or the Job-ID; especialy during HTTP or DNS requests.
-
-=== Debug logging ===
-By default citserver will only log information about errors or traffic analysis related errors. If you want to track all a job does, you can enable more logging:
-
-sendcommand LOGP (LOG Print; show status of logs; the following list may increase over time) : 
-
-sendcommand: started (pid=19897) connecting to Citadel server at /var/run/citadel/citadel-admin.socket
-200 potzblitz Citadel server ADMIN CONNECTION ready.
-LOGP
-100 Log modules enabled:
-modules|0 <- module loading; unloading etc.
-
-rssclient|0  <- RSS aggregator client debugging; on message level
-RSSAtomParser|0 <- debugging the parsing of ATOM / RSS feeds; once a message is isolated, the above logging comes into place again.
-curl|0 <- HTTP request logging; i.e. querieing the external RSS resources by http is logged with this.
-  
-networkqueue|0 <- working through rooms, finding jobs to schedule; reading network spool files, writing them; etc.
-networktalkingto|0 <- locked list of network interconnections to circumvent race conditions by simultaneous spooling / sending / receiving
-networkclient|0 <- outbound networking connections; this has an IO context.
-
-cares|0 <- asynchroneous nameserver lookup
-eventloop|0 <- adding jobs; connecting; timeouts; etc.
-eventloopbacktrace|0 <- add stacktraces in certain places; very noisy.
-
-sieve|0 <- sieve filtering of mailboxes
-messages|0 <- message processing; loading / printing / saving
-
-imapsrv|0 <- Imap connections
-serv_xmpp|0 <- XMPP connections
-pop3client|0 <- pop3 aggregators
-
-smtpeventclient|0 <- outbound SMTP connections
-
-sendcommand: processing ended.
-
-If the second column is 1, that debug log is enabled.
-
-You can enable the logging by 3 ways: 
- - sendcommand 'LOGS cares|1' (live)
- - via webcit->aide->Enable/Disable logging of the server components; in an interactive manner
- - via environment variable 'CITADEL_LOGDEBUG' as a coma separated list of facilities to enable; before starting citserver
- - via commandline parameter '-x' as a coma separated list of facilities to enable; please note that this switch used to set the loglevel previously.
-
-
-
-eventloop,eventloopbacktrace,cares
-  - IO the AsyncIO ID
-  - IOQ (Queueing of events into eventqueues)
-
-modules: 
-  - modules - module init / registering specific stuff
-
-smtpeventclient
-  - S[QueueID][N] where the Queue-ID is the number of the Message to be sent, and N the SMTP-job-ID
-  - SMTPCQ infrastructure logging when the housekeeper is checking for SMTP-Delivery jobs to spawn
-
-imapsrv
-  - IMAPCC: imap client contexts; commands sent to us from Imap-Clients
-
-
-networkqueue
-  - CC - 
-
-networkclient
-  - CC, IO - the context
-  - NW[nodename][networkerid] the name of the node we're trying to talk to; the networker connection counter uniq per attempt
-
-curl
-  - CURL - logging where we don't have a context
-  - CC, IO - the context
-
-RSSClient
-  - IO, CC, N, 'RSS'; IO & CC not always available.
-  - 'RSSP' - the rss and atom parser
-
-
-pop3client
-  - POP3 IO, CC, N - N the number of that connection
-
-sieve
-  - sieve doesn't have CC or IOs, its just ran one at a time serverwide.
-
-
-xmpp
-  - XMPP - whether CC could & should be logged has to be researched and added.
-
-Context
-  - 'Context:' context related logging - server infrastructure, cleanup of contexts etc.
-
-messages
-  - MSG - CC - the context that is manipulating this message.
-
-
-
index 6c48df93480c406192e5f8bddaa0715514a552ea..01fad9282b607b5db8561d6db7528cb7be29982d 100644 (file)
@@ -1,15 +1,13 @@
 ====== SMTP Client ======
 ===== source files involved: =====
 
 ====== SMTP Client ======
 ===== source files involved: =====
 
-event_client.h - AsyncIO structure, interfaces to event Queue
-
 
 modules/smtp/smtp_clienthandlers.h - SMTP-Client Context struct & functions.
 modules/smtp/smtpqueue.h - parsing of Queue mails & respective structures
 
 modules/smtp/serv_smtpqueue.c - queue handling executed by housekeeping thread; de/serialization of Queue-control-messages
 modules/smtp/serv_smtpeventclient.c - business logic 
 
 modules/smtp/smtp_clienthandlers.h - SMTP-Client Context struct & functions.
 modules/smtp/smtpqueue.h - parsing of Queue mails & respective structures
 
 modules/smtp/serv_smtpqueue.c - queue handling executed by housekeeping thread; de/serialization of Queue-control-messages
 modules/smtp/serv_smtpeventclient.c - business logic 
-modules/smtp/smtp_clienthandlers.c - Protocoll logic
+modules/smtp/smtp_clienthandlers.c - Protocol logic
 
 msgbase.c - writes spool messages + spoolcontrol files
 
 
 msgbase.c - writes spool messages + spoolcontrol files
 
@@ -18,7 +16,7 @@ event_client.c - base event functions
 modules/eventclient/serv_eventclient.c - the event queue
 modules/c-ares-dns/serv_c-ares-dns.c - nameserver lookup
 
 modules/eventclient/serv_eventclient.c - the event queue
 modules/c-ares-dns/serv_c-ares-dns.c - nameserver lookup
 
-===== Spool Controll =====
+===== Spool Control =====
 Citadel stores two messages for mail deliveries; the spool control message format is described in delivery-list.txt; its generated in msgbase.c, and de/serialized in serv_smtpqueue.c.
 The for Spool-control structures are kept in memory as OneQueItem per Spool-Control-File, and MailQEntry per Recipient of the message.
 For each MailQEntry which is still to be delivered, one SmtpOutMsg (containing the AsyncIO context) is spawned. The Jobs are processed in paralell, each job finished triggers an update of the spool control message, so we don't accidently deliver a message twice to one recipient. If the last recipient has succeeded, or permanently failed, the spool-file and the mail-file are removed from the spool room.
 Citadel stores two messages for mail deliveries; the spool control message format is described in delivery-list.txt; its generated in msgbase.c, and de/serialized in serv_smtpqueue.c.
 The for Spool-control structures are kept in memory as OneQueItem per Spool-Control-File, and MailQEntry per Recipient of the message.
 For each MailQEntry which is still to be delivered, one SmtpOutMsg (containing the AsyncIO context) is spawned. The Jobs are processed in paralell, each job finished triggers an update of the spool control message, so we don't accidently deliver a message twice to one recipient. If the last recipient has succeeded, or permanently failed, the spool-file and the mail-file are removed from the spool room.