The SessionInitialiser class performs the database queries needed to initialise or update Session objects.
When it's created, it tries to see whether the database work can be skipped. If not, it does all the necessary database queries and updates, and finally informs the Session objects of new and modified Message objects.
Constructs an SessionInitialiser for mailbox. If t is non-null, then thr initialiser will use a subtransaction of t for its work.
Adds uid with modseq ms to each session to be announced as changed or new.
Persuades each Session to emit its responses.
Issues a query to find new and changed messages in the mailbox, and one to find newly expunged messages.
Fetches the "\recent" data from the database and sends an update to the database if we have to change it. Note that this doesn't release our lock.
Finds all sessions that may be updated by this initialiser. Doesn't lock anything.
It may be that Mailbox::uidnext() is a little behind the times. If we retrieve the values from the database anyway, this function updates the Mailbox.
Constructs a big complex query to find out what a view's contents should be like, which writeViewChanges() can use to update the view_messages table and the Sessions. Takes care to make the query as simple as possible, so it only looks at modseq if necessary.
The generated query is big, complex and invariant. Perhaps we should try to make a PreparedStatement. Not sure how. There's nowhere natural to put it.
Grabs enough locks on the database that we can update what we need to update: Only one session must get the "\recent" flag, and if we change view contents, noone else must do so at the same time.
Finds any expunges stored in the db, but new to us, and records those in all the sessions.
Parses the results of the Query generated by findMailboxChanges() and updates each Session.
Commits the transaction, releasing the locks we've held, and updates the state. After this we're done.
This private helper submits q via our Transaction if we're using one, directly if not.
Processes the query results from the Query generated by findViewChanges(), adds to and/or removes from the view_messages table and the in-RAM Session object as a result, and updates the view so the next SessionInitialiser will not have to consider the same messages.
This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.