aboutsummaryrefslogtreecommitdiffstats
path: root/camel/README.mt
blob: aeece1b0bb839fc5672aeba79a4934ccaa8304a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

This version of camel is working towards being multi-thread safe
(MT-SAFE).  At least, for the important api's.

This code has now been merged into the main head, but this file
will remain here as a log of how it was done, incase any issues
arise.  The ChangeLog of course has a much more detailed list
of changes.

Intended method
===============

I intend working on it in several stages:

1. Making the api multi-threadable.  Basically removing some const-returns,
and copying some data where it wasn't before.  The api should
still continue to work if not being used in a multithreaded
application.  There is not a significant amount of work here since
this was more or less the intention all along.

Some functions where references to objects are returned may have to be
changed slightly, so that refcounts are incremented before return.
This doesn't affect much though.

camel_folder::get_message_info              done
camel_folder_summary::uid               done
camel_folder_summary::index             done
camel_folder::get_summary
    Needs to ref each summary item it points to.    done
camel_folder::free_summary
    Needs to unref each summary item it points to.  done
camel_folder_get_message_tag
    needs to copy the tag return
camel_maildir_summary filename string
    should not be able to modify the string
    array contents after it has been added to
    the summary.
camel_folder                        done
    Make every camel-folder use a camel-folder-summary.
    This just reduces some of the code duplication,
    since everything but vee-folder does this already.

2. Adding high level locks for proof of concept.  The locks will
be stored in private or global data, so the api should remain the same for
non-threaded applications.

A per-folder lock which governs access to the folder
    summary, the folder file or
    communications socket, etc.         done
Locking for exceptions.                 done
Per store locks for internal stuff.         done
Per-service locks for various internal lists and
    caches                      done

3. Further fine-grained locking where it can be done/is worthwhile.

A per-index lock for libibex                done
Locking for the search object               half done
Internal lock for the folder_summary itself
    So that searching can be detatched from other
    folder operations, etc.             done
Possibly a lock for access to parts of a mime-part
    or message

4. A method to cancel operations.

Individual outstanding operations must be cancellable, and not just
'all current operations'.  This will probably not use pthread_cancel
type of cancelling.

This will however, probably use a method for starting a new thread,
through camel, that can then be cancelled, and/or some method of
registering that a thread can be cancelled.  Blocking states within
camel, within that thread, will then act as checkpoints for if the
operation, and if it is cancelled, the operation will abort
(i.e. fail, with an appropriate exception code).

Operation cancelling should also function when the application is not
multi-threaded.  Not sure of the api for this yet, probably a callback
system.  Hopefully the api for both scenarios can be made the same.

Other thoughts
==============

Basically much of the code in camel that does the actual work does NOT
need to be thread safe to make it safely usable in an mt context.

camel-folder, camel-summary, camel-imap-search, and the camel-service
classes (at least) are the important ones to be made multithreaded.

For other things, they are either resources that are created
one-off (for example, camel-mime-message, and its associated
parts, like camel-internet-address), or multithreadedness
doesn't make a lot of sense - e.g. camel-stream, or camel-mime-parser.

So basically the approach is a low-risk one.  Adding the minimum
number of locks to start with, and providing further fine-grained
locks as required.  The locks should not need to be particularly
fine-grained in order to get reasonable results.

Log of changes
==============

Changed CamelFolder:get_message_info() to return a ref'd copy, requiring
all get_message_info()'s to have a matching free_message_info().

Moved the CamelFolder frozen changelog data to a private structure.

Added a mutex for CamelFolder frozen changelog stuff (it was just easy
to do, although it isn't needed yet).

Added a single mutex around all other CamelFolder functions that need
it, this is just the first cut at mt'edness.

Fixed all camel-folder implementations that call any other
camel-folder functions to call via virtual methods, to bypass the locks.

Added camel-store private data.

Added a single mutex lock for camel-store's folder functions.

Added camel-service private data.

Added a single mutex lock for camel-service's connect stuff.

Added a mutex for remote-store stream io stuff.

Added a mutex for imap, so it can bracket a compound command
exclusively.  Pop doesn't need this since you can only have a single
folder per store, and the folder interface is already forced
single-threaded.

Added mutex for camel-session, most operations.

Running the tests finds at least 1 deadlock so far.  Need to
work on that.

Fixed get_summary to ref/unref its items.

Removed the global folder lock from the toplevel
camel_folder_search(), each implementation must now handle locking.

Fixed the local-folder implementation of searching.  imap-folder
searching should already be mt-safe through the command lock.

Fixed imap summary to ref/unref too.

Built some test cases, and expanded the test framework library to
handle multiple threads.  It works!

Next, added a recursive mutex class, so that locking inside imap had
any chance of working.  Got imap working.

Moved the camel folder summary into the base folder class, and fixed
everything to use it that way.

Made the vfolder use a real camel-folder-summary rather than a
hashtable + array that it was using, and probably fixed some problems
which caused evolution-mail not to always catch flag updates.  Oh, and
made it sync/expunge all its subfolders when sync/expungeing.

Made the camel-folder summary completely mt-safe.

Removed all of the locks on the folder functions dealing directly with
the summary, so now for example all summary lookups will not be
interupted by long operations.

Made the nntp newsrc thing mt-safe, because of some unfortunate
sideeffect of it being called from the summary interaction code in
nntp-folder.

'insertions'>+2 * Eliminate USE_GNOME=pkgconfigbapt2013-09-021-4/+2 * Update to Wine 1.7.1. This includes the following changes:gerald2013-08-313-3/+15 * Add an explicit dependency on pkgconfbapt2013-08-311-6/+2 * - Remove bogus conditional IGNORE for PACKAGE_BUILDING; these shouldbdrewery2013-08-291-2/+2 * Make sure the build respect CC, and while here enforce gcc as a compiler as c...bapt2013-08-281-3/+3 * Remove expired ports:rene2013-08-289-204/+0 * - Install an icon and use it in a desktop fileamdmi32013-08-271-3/+4 * emulators/spim: fix packagewg2013-08-231-0/+1 * - Update to 1.6.0 - announce message is here:nox2013-08-2133-23333/+8 * Replace USE_GCC=4.6+ and USE_GCC=4.4+ by USE_GCC=yes.gerald2013-08-185-5/+5 * - Remove MAKE_JOBS_SAFE variableak2013-08-1522-22/+0 * Add back i386-wine/Makefile (wouldn't commit otherwise).dbn2013-08-121-0/+16 * Add emulators/i386-wine.dbn2013-08-1210-0/+2466 * Fix emulators/i386-wine-devel when installing on -current.dbn2013-08-123-7/+8 * Backport changes from emulators/wine-devel and add CONFLICTS_INSTALL.dbn2013-08-122-9/+19 * Update emulators/i386-wine-devel options with GECKO and MONO.dbn2013-08-112-3/+17 * Enable packaging of emulators/i386-wine-devel on amd64 (part 2/2).dbn2013-08-101-86/+12 * Enable packaging of emulators/i386-wine-devel on amd64 (part 1/2).dbn2013-08-106-0/+2321 * - update libdg to 2.1.0dinoex2013-08-091-0/+1 * Update to Wine 1.7.0, the new development branch of Wine after thegerald2013-08-053-4/+10 * - Convert to new perl frameworkmat2013-08-031-1/+1 * - Convert to new perl frameworkaz2013-08-032-4/+2 * - Fix build with PYTHON_DEFAULT_VERSION of 3+. [1]nox2013-08-032-2/+4 * - Unbreak the build, augment port description textdanfe2013-08-022-31/+34 * - Unbreak the build, convert USE_GMAKE, add missing OPTIONS_DEFINEdanfe2013-08-022-16/+10 * Fix build with clang by forcing gnu89 standardbapt2013-07-311-0/+2 * - Add PROFILING_DESC (should be part of r323888)danfe2013-07-303-3/+54 * - Expand creator's name in the Makefile headerdanfe2013-07-296-54/+757 * - Remove no-op MAKE_JOBS_SAFErene2013-07-291-2/+1 * Remove MAKE_JOBS_SAFE from all my ports.dbn2013-07-291-1/+0 * Update to 1.5.2 - announce message is here:nox2013-07-282-4/+3 * - Fix CONFLICTS.hrs2013-07-272-9/+8 * Deprecate and set expiration date for ports broken for more than 6 monthbapt2013-07-271-0/+3 * Simplify path for extra-patches.nox2013-07-276-19/+19 * Move allegro-devel to allegro; 4.4 is hardly a devel version any more.crees2013-07-273-3/+3 * - Add missing USES=pkgconfig.nox2013-07-192-13/+13 * - Unbreak build with clangmiwi2013-07-155-11/+98 * - Update to 1.7.0miwi2013-07-153-12/+18 * Fix bogus backquote that was giving portsmon fits.linimon2013-07-141-1/+1 * Mark as broken, dos not build:bapt2013-07-131-0/+2 * Update to Wine 1.6 RC5. More bug fixes and translation work.gerald2013-07-132-3/+3 * - Bump PORTREVISION for ftp/curl shlib changesunpoet2013-07-121-1/+1 * - Update to 7.31.0sunpoet2013-07-124-3/+5 * - Update emulators/mame to version 0.149miwi2013-07-1117-46/+420 * - Fix querying total and available RAM on i386decke2013-07-112-2/+3 * uCON64 is the video game backup tool and emulator Swiss Army knife program.skreuzer2013-07-1012-0/+147 * Mark jobs unsafe and convert to USES=gmakebapt2013-07-101-1/+2 * Convert from USE_MOTIF to USES=motifbapt2013-07-102-6/+5 * - Add OPTIONS to enable internal debuggerlippe2013-07-091-0/+11 * Remove WITH_KDE3 knob which provided support for the expired KDE3.rene2013-07-081-4/+0 * - Update to 4.2.16decke2013-07-076-12/+11 * - Update to 1.5.1, announce message is here:nox2013-07-0710-615/+2625 * Remove support for the expired QT3 port.novel2013-07-061-11/+0 * Convert to USES=gmakerene2013-07-051-2/+1 * Add -Wno-unused-parameter to silence excessive clang warnings.tijl2013-07-051-2/+3 * - Changing RAM for a VM was broken in the GUI because there was nodecke2013-07-033-0/+95 * Remove expired ports:rene2013-07-015-180/+0 * Tilem:antoine2013-06-301-1/+3 * Update to Wine 1.6 RC4. This includes some further bug fixes.gerald2013-06-292-3/+3 * New USES imake to handle the dependency on imake.bapt2013-06-282-10/+4 * Bump portrevision - the binary has now changed.adrian2013-06-281-0/+1 * Enable LBA in GXEMUL.adrian2013-06-281-0/+32 * Building gxemul conflicts with svgalib, so mark it as a conflict.adrian2013-06-281-0/+4 * Actually fix build with gcc46 when bsd.gcc.mk passes LDFLAGS with -Wl,...nox2013-06-282-6/+12 * - Switch to new header style. [1]nox2013-06-264-279/+22 * Update multimedia/ffmpeg1 to 1.2.1mm2013-06-251-0/+1 * - Update to 4.2.14decke2013-06-2412-21/+109 * Update to Wine 1.6 RC3. This includes some further bug fixes.gerald2013-06-232-3/+3 * Remove expired port:rene2013-06-225-43/+0 * Update to Wine 1.6 RC2. This includes a number of bug fixes.gerald2013-06-173-3/+5 * Really fix dynamic pkg-plist for emulators/i386-wine-devel.dbn2013-06-171-3/+3 * Fix plist and directory creation for emulators/i386-wine-devel.dbn2013-06-152-3/+3 * Update to Wine 1.6 RC1. This includes the following relevant changes:gerald2013-06-153-3/+10 * Update to 3.08.rakuco2013-06-156-81/+67 * - Fix buildmiwi2013-06-141-0/+2 * Fix spelling LICENCE -> LICENSE.bsam2013-06-131-1/+1 * . remove shlib ABI version from LIB_DEPENDS;bsam2013-06-131-8/+6 * - Fix i18n manpagesmiwi2013-06-111-0/+2 * - Update to r250249.kuriyama2013-06-115-17/+28 * Turn this 30-year old code to use GCC.joerg2013-06-101-4/+3 * * Major update to FLAC 1.3.0, including shared library bumps.naddy2013-06-102-0/+2 * Improve 3D acceleration for emulators/i386-wine-devel.dbn2013-06-104-43/+74 * Replace OPTIONS_OVERRIDE with OPTIONS_SLAVE in all ports. It is not meanttijl2013-06-0910-10/+10 * Add second part to handle libwine.so; the joy of upstream using .so.1.0.gerald2013-06-091-0/+1 * Update to Wine 1.5.31. This includes the following relevant changes:gerald2013-06-083-6/+8 * Update to the new upstream version 2.21.gerald2013-06-082-3/+3 * Removed due to dependency on expired linux-js.bapt2013-06-056-80/+0 * Unhook emulators/linux-xjoypad from emulators/Makefile, as it depends oncperciva2013-06-051-1/+0 * Cleanup:eadler2013-06-052-14/+7 * 2013-03-05 devel/linux-js: Broken for more than 6 monthbapt2013-06-054-57/+0 * Update pkg-message a bit for the old qemu version too.nox2013-06-051-6/+5 * - Fix build with clangmiwi2013-06-042-9/+27 * Drop maintainership.rene2013-06-041-1/+1 * Update libspectrum, fuse, and fuse-utils to 1.1.1rene2013-06-03