Re: [PATCHES] PostgreSQL libraries - PThread Support, but

Поиск
Список
Период
Сортировка
Искать

Re: [PATCHES] PostgreSQL libraries - PThread Support, but

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

This patch handles two more gethostbyname calls.

---------------------------------------------------------------------------

Lee Kindness wrote:
Content-Description: message body text

> Patch attached, along with new libpq-reentrant.c and libpq-reentrant.h
> files for src/interfaces/libpq.
> 
> Also at http://services.csl.co.uk/postgresql/
> 
> Thanks, Lee.
> 
> Lee Kindness writes:
>  > Ok guys, I propose that the new libpq diff and 2 source files which
>  > i'll soon send to pgsql-patches is applied to the source. This diff is
>  > a cleaned up version of the previous version with the wrapper
>  > functions moved out into their own file and more comments added. Also
>  > the use of crypt_r() has been removed (not worth the effort), the
>  > cpp defines have been renamed to be consistent with each other and
>  > Tom's concerns with loose #defines has been partly addressed.
>  > 
>  > This diff does not include any configure changes. I plan to tackle
>  > this separately ASAP, and hopefully produce something more acceptable.
>  > 
>  > I will add checks for appropriate compiler thread flags (for compiling
>  > libpq, and alow the removal of #defines in libpq-reentrant.h), and
>  > link flags & libs (for a planned threaded libpq test program and
>  > renentrant ecpg library). If a thread environment is found then check
>  > for the reentrant functions will be done.
>  > 
>  > Looking at various open source projects configure.in files there seems
>  > to be little commonality in the thread test macros (telp gratefully
>  > accepted!), I currently think that something like the approach used by
>  > glib is most suitable (switch on OS).
>  > 
>  > All sound acceptable?
>  > 
>  > Thanks, Lee.
>  > 
>  > Peter Eisentraut writes:
>  >  > Lee Kindness writes:
>  >  > 
>  >  > > Patches attached to make libpq thread-safe, now uses strerror_r(),
>  >  > > gethostbyname_r(), getpwuid_r() and crypt_r() where available. Where
>  >  > > strtok() was previously used strchr() is now used.
>  >  > 
>  >  > AC_TRY_RUN tests are prohibited.  Also, try to factor out some of these
>  >  > huge tests into separate macros and put them into config/c-library.m4.
>  >  > And it would be nice if there was some documentation about what was
>  >  > checked for.  If you just want to check whether gethostbyname_r() has 5 or
>  >  > 6 arguments you can do that in half the space.
> 

[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/interfaces/libpq/fe-secure.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-secure.c,v
retrieving revision 1.24
diff -c -c -r1.24 fe-secure.c
*** src/interfaces/libpq/fe-secure.c	14 Jun 2003 17:49:54 -0000	1.24
--- src/interfaces/libpq/fe-secure.c	14 Jun 2003 18:08:54 -0000
***************
*** 453,460 ****
  	if (addr.sa_family == AF_UNIX)
  		return 0;
  
  	/* what do we know about the peer's common name? */
! 	if ((h = gethostbyname(conn->peer_cn)) == NULL)
  	{
  		printfPQExpBuffer(&conn->errorMessage,
  		libpq_gettext("could not get information about host (%s): %s\n"),
--- 453,469 ----
  	if (addr.sa_family == AF_UNIX)
  		return 0;
  
+ 	{
+ 		struct hostent hpstr;
+ 		char buf[BUFSIZ];
+ 		int herrno = 0;
+ 
+ 		pqGethostbyname(conn->peer_cn, &hpstr, buf, sizeof(buf),
+ 		                &h, &herrno);
+ 	}
+ 	
  	/* what do we know about the peer's common name? */
! 	if ((h == NULL)
  	{
  		printfPQExpBuffer(&conn->errorMessage,
  		libpq_gettext("could not get information about host (%s): %s\n"),
Index: src/port/getaddrinfo.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/getaddrinfo.c,v
retrieving revision 1.7
diff -c -c -r1.7 getaddrinfo.c
*** src/port/getaddrinfo.c	12 Jun 2003 08:15:29 -0000	1.7
--- src/port/getaddrinfo.c	14 Jun 2003 18:08:55 -0000
***************
*** 84,91 ****
--- 84,99 ----
  		else
  		{
  			struct hostent *hp;
+ #ifdef FRONTEND
+ 			struct hostent hpstr;
+ 			char buf[BUFSIZ];
+ 			int herrno = 0;
  
+ 			pqGethostbyname(node, &hpstr, buf, sizeof(buf),
+ 			                &hp, &herrno);
+ #else
  			hp = gethostbyname(node);
+ #endif
  			if (hp == NULL)
  			{
  				switch (h_errno)

Re: [PATCHES] PostgreSQL libraries - PThread Support, but

От:
Kurt Roeckx <Q@ping.be>
Дата:
On Sat, Jun 14, 2003 at 02:20:44PM -0400, Bruce Momjian wrote:
> 
> This patch handles two more gethostbyname calls.
> 
[...]
> diff -c -c -r1.24 fe-secure.c
> *** src/interfaces/libpq/fe-secure.c	14 Jun 2003 17:49:54 -0000	1.24
> --- src/interfaces/libpq/fe-secure.c	14 Jun 2003 18:08:54 -0000
> ***************
> *** 453,460 ****
>   	if (addr.sa_family == AF_UNIX)
>   		return 0;
>   
>   	/* what do we know about the peer's common name? */
> ! 	if ((h = gethostbyname(conn->peer_cn)) == NULL)
>   	{
>   		printfPQExpBuffer(&conn->errorMessage,
>   		libpq_gettext("could not get information about host (%s): %s\n"),

That code is inside #ifdef NOT_USED, which is why I didn't change
it in my ipv6 patch.

Should I convert that function to use getaddrinfo too?

Others I didn't change where pg_krb4_sendauth() and
pg_krb5_sendauth(), because I don't have a clue about kerberos.



Kurt

Re: [PATCHES] PostgreSQL libraries - PThread Support, but

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Kurt Roeckx wrote:
> On Sat, Jun 14, 2003 at 02:20:44PM -0400, Bruce Momjian wrote:
> > 
> > This patch handles two more gethostbyname calls.
> > 
> [...]
> > diff -c -c -r1.24 fe-secure.c
> > *** src/interfaces/libpq/fe-secure.c	14 Jun 2003 17:49:54 -0000	1.24
> > --- src/interfaces/libpq/fe-secure.c	14 Jun 2003 18:08:54 -0000
> > ***************
> > *** 453,460 ****
> >   	if (addr.sa_family == AF_UNIX)
> >   		return 0;
> >   
> >   	/* what do we know about the peer's common name? */
> > ! 	if ((h = gethostbyname(conn->peer_cn)) == NULL)
> >   	{
> >   		printfPQExpBuffer(&conn->errorMessage,
> >   		libpq_gettext("could not get information about host (%s): %s\n"),
> 
> That code is inside #ifdef NOT_USED, which is why I didn't change
> it in my ipv6 patch.

Yes, I noticed that, but it seemed reasonable to get things consistent.

> 
> Should I convert that function to use getaddrinfo too?
> 
> Others I didn't change where pg_krb4_sendauth() and
> pg_krb5_sendauth(), because I don't have a clue about kerberos.

I understand.  I guess we should be consisent if we can be.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
FAQ