[Poppler-bugs] [Bug 50992] library should be thread-safe

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Aug 6 01:01:53 PDT 2012


https://bugs.freedesktop.org/show_bug.cgi?id=50992

--- Comment #28 from Thomas Freitag <Thomas.Freitag at alfa.de> 2012-08-06 08:01:53 UTC ---
Here just the try of an additonal explanation of my solution:
Even if it seems so that the essential part of the implementation is the XRef
part, it is substantial the UniqueFileStream, even if this has only a few lines
of code.
To clearify that I simplify a little bit what the problem is:
Getting a PDF stream object is done over XRef and FileStream with a FILE
pointer, which doesn't read always the stream object in one step but expects
that nobody changes the file position in then meantime when reading the next
portion of an object stream. But this is not true if we share the FILE pointer
between different threads.
So we need a unique FILE pointer for every thread, and that is done by the
implementation of UniqueFileStream. Only because that the stream is a member of
an XRef instance, we need a private instance of XRef for every thread and
therefore I spend the XRef::copy functionality.

Of course there are other possible solutions for the problem, i.e. buffer each
(object) stream as MemStream in XRef and use mutex locking there, but this
would mean a basically change of the core stuff and could cause memory problems
if there are for example quite huge images. 

Hope this clearifies it a little bit for everyone who is interested in my
solution.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Poppler-bugs mailing list