Threading problem in TIdCustomHTTPServer (TIdMimeTable)

Giganews Newsgroups
Subject: Threading problem in TIdCustomHTTPServer (TIdMimeTable)
Posted by:  jgv (jacques.garciavazqu…@telenet.be)
Date: Fri, 25 Jun 2010

Hi all,

There is a threading problem in the http server when serving files dues
to the mime table (which is not thread safe). I think it was there from
the beginning but since the mime table grow in some previous release it
is more evident now.
The problem occurs when the mime table is initialized. Since it is not
thread safe, you get some random exception when you serve several files
at the same time (and a mime lookup is performed). Once the table is
initialized, the problem doesn't occurs.

I suggest to load the cache when the map table is created:

procedure TIdCustomHTTPServer.InitComponent;
...
  FMIMETable := TIdMimeTable.Create(True);

or clearly document that we have to load it manually.

Regards
Jacques

Replies