Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas025.isp.belgacom.be (localhost [127.0.0.1])
        by inav009.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k8MH5u9w010000
        for <joris.at.lebbeke@skynet.be>; Fri, 22 Sep 2006 19:05:56 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx005.isp.belgacom.be (inmx005.isp.belgacom.be [195.238.5.148])
        by inas025.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k8MH5n6t031674
        for <joris.at.lebbeke@skynet.be>; Fri, 22 Sep 2006 19:05:54 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx005.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k8MH5Z7p011731
        for <joris.at.lebbeke@skynet.be>; Fri, 22 Sep 2006 19:05:42 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k8MGliol003283;
	Fri, 22 Sep 2006 12:47:48 -0400
Received: from mail.business.allstream.net (mx.business.allstream.net
	[207.245.244.100])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k8MGlg0O003279
	for <tiff@lists.maptools.org>; Fri, 22 Sep 2006 12:47:42 -0400
Received: from mojo (unknown [216.191.89.138])
	by mail.business.allstream.net (Allstream MTA) with ESMTP
	id 2AE9765D99; Fri, 22 Sep 2006 12:47:41 -0400 (EDT)
From: "Philip Watkinson" <pwatkins@crawfordtech.com>
To: "'Bob Friesenhahn'" <bfriesen@simple.dallas.tx.us>,
        "'Joris'" <joris.at.lebbeke@skynet.be>
Subject: RE: [Tiff] libjpeg
Date: Fri, 22 Sep 2006 12:49:52 -0500
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook, Build 11.0.5510
Thread-Index: AcbeZIcFMylHKoWOTPmN4rcHBFGznwACcWkw
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
In-Reply-To: <Pine.SOC.4.60.0609221126410.1941@blade.simplesystems.org>
Message-Id: <20060922164741.2AE9765D99@mail.business.allstream.net>
Cc: tiff@lists.maptools.org
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
Reply-To: pwatkins@crawfordtech.com
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00001acb
X-MSP-STORE: Fri, 22 Sep 2006 19:06:03 +0200
Status:   

Bob,

I just did some searching on the Internet and found the following from March
2000:

libjpeg is thread-safe as long as (a) you don't have multiple threads
operating concurrently on the same jpeg object, and (b) your underlying
C library (particularly malloc/free) is thread-safe.  You can have
multiple jpeg objects being manipulated concurrently by different
threads.

regards, tom lane
organizer, Independent JPEG Group

Philip



-----Original Message-----
From: Bob Friesenhahn [mailto:bfriesen@simple.dallas.tx.us] 
Sent: September 22, 2006 11:31 AM
To: Joris
Cc: Philip Watkinson; tiff@lists.maptools.org
Subject: Re: [Tiff] libjpeg

On Fri, 22 Sep 2006, Joris wrote:

> Bob Friesenhahn wrote:
>>> Is libjpeg thread safe?
>>
>> An often debated question, but in my opinion `no'.  The only safe way
>> to use it is under a lock.
>
> Are you claiming a lock is necessary for serializing all LibJpeg usage,
> or a lock is necessary per decoding/encoding session? In either of these
> cases, what exactly do you think is the unsafe stuff?

The problem is with the dependence on setjmp/longjmp for error 
recovery.  These APIs were never designed with multi-thread in mind 
and are not thread safe on many (most?) platforms.  Unless 
specifically documented to be thread safe, one must assume not thread 
safe for these APIs.  Other than this, I think that libjpeg is pretty 
thread safe.  Libpng has the same problem as libjpeg.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/


_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
