Closed Bug 204111 Opened 21 years ago Closed 14 years ago

nsCharsetAlias should be threadsafe

Categories

(Core :: Internationalization, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sfraser_bugs, Assigned: smontagu)

Details

Attachments

(2 files)

An embedder calls nsICharsetAlias from different threads. We need to make it
threadsafe.
who is calling the charset alias code from a non ui thread?
an embedder who uses them to do charset stuff with mail headers on a thread that
isn't the UI thread.
Comment on attachment 122231 [details] [diff] [review]
Make it threadsafe

> nsCharsetAlias2::nsCharsetAlias2()
>+: mDelegate(nsnull)
> {
>   NS_INIT_ISUPPORTS();
>-  mDelegate = nsnull; // delay the load of mDelegate untill we need it.
>+  mDelegateLock = PR_NewLock();
> }

technically this is wrong, you should use an Init method and modify the
nsmodule macro to be _CONSTRUCTOR(..., Init)

that said, i really want this change or something even more dangerous (my
version just marks the code as threadsafe - xpinstall uses it).
Attachment #122231 - Flags: review?(smontagu)
that's funny, i already reviewed a similar patch in bug 229032 comment 56
Just for comparison, this is what I wrote in last March after getting some
comments from timeless, alecf, bz, jst, dbaron. (Then, I completely forgot
about it.) However, apparently I didn't address timeless' comment about 'Init'.
No timeless, this is not wrong. you only use _CONSTRUCTOR(...,Init) when you
need to bubble an error up to the creator of the object. 

constructors are good when stuff isn't going to fail.

In the above case, I suppose creating the lock could fail.. but mDelegate should
still be initialized to nsnull in the constructor.

QA Contact: amyy → i18n
Attachment #122231 - Flags: review?(smontagu)
I suggest putting the alias data into the data segment of the object code and make it the operating system's problem to page it in.
The fix for bug 563536 fixed this one, too.
http://hg.mozilla.org/mozilla-central/rev/8d6db7f8fe09
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: