Subject: Re: Threading problems
To: Bill Studenmund <>
From: Eric Haszlakiewicz <>
List: tech-kern
Date: 11/24/2004 02:45:11
On Tue, Nov 23, 2004 at 06:59:43PM -0800, Bill Studenmund wrote:
> Also, you're assuming that the program is fine being suddenly-threaded. 
> Say _it_ is built different if threads are enabled or not. Adding -pthread 
> to the command line defines "_REENTRANT", which a program certainly can 
> use to change its behavior. Looking in stdio.h, its behavior will be 
> different. Some things it does will never be able to work right adding 
> threading later.
	I didn't think of that.  That just about kills my idea.  oh well.

> Given how much code really needs to be _REENTRANT or not at compile time, 
> I don't see how we can ever make "magic add pthread later" work right. So 
> I think what we're doing now is the right thing, by making it obvious the 
> code needs recompiling.

	uhm... I guess I'm not entirely up to speed on what all the requirements
for a threaded program are.  What you're saying seems to imply that
(going back to the original problem) the postgres binary needs to be built
with -pthread from the very beginning if it is to dlopen a pthread-linked
library.  It is not enough to use LD_PRELOAD.  Correct?
	The best that can be done is to do (magic handwaving) to build postgres
as if it was a library that is intended to be used in both threaded and
non-threaded apps.  If that is done, then LD_PRELOAD could be used to
selectively turn on full pthread support at exec time if it is known that
a pthread library will be loaded later.
	btw, what is the (magic handwaving) necessary?  Just define _REENTRANT?