[Poppler-bugs] [Bug 50992] library should be thread-safe
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Sat Sep 29 09:21:20 PDT 2012
https://bugs.freedesktop.org/show_bug.cgi?id=50992
--- Comment #62 from Thomas Freitag <Thomas.Freitag at alfa.de> ---
(In reply to comment #54)
>
> Seems a bit weird leaving the non thread safe versions of getDocInfo and
> getDocInfoNF there, no? What's the use of them?
>
After reviewing my own patch :-) I now also understand what You mean, it wasn't
in my mind anymore that I made an additional, thread safe version of getDocInfo
when I answered the last time.
So here now the attempt to explain why it is necessary: an instance of XRef is
not thread safe by nature and therefore cannot be shared over threads. The
reason is the file stream member of XRef which is used to fetch objects.
But the non thread safe versions of getDocInfo and getDocInfoNF returns a
PDFObject which could have references to an instance of XRef (i.e. a Dict which
points to other objects which then will be fetched over the xref member), so
they are also not thread safe. It would be a hard work and a lot of changes to
make these functions thread safe without changing the parameters, a copy of
xref is needed than in the objects referenced by the info object, too, and this
copy must be deleted in the destructors of every object where the copy is
created.
So the thread safe version has an additional paramter, the thread own xref
pointer, and this xref pointer is then injected in all objects referenced by
the info object, and so it's quite easy to create an xref copy in the thread if
necessary and delete this xref pointer when no more needed. That's what I did
in the qt-library in poppler-document.cc.
Last but not least I cannot remove the non thread safe versions, they are
public and therefore probably used in a lot of programs which use poppler.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler-bugs/attachments/20120929/1ce60b6b/attachment.html>
More information about the Poppler-bugs
mailing list