Skip site navigation (1) Skip section navigation (2)

Re: Win32 open items

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: Win32 open items
Date: 2004-10-26 15:07:45
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE476012@algol.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-hackers-win32
> > The problem with this is that PQrequestCancel() is not thread-safe.
> 
> What is your basis for asserting that?

Looking at the source code?

We are talking about two different threads *accessing the same PGconn*.
For example:
	if (conn->sock < 0)
	{
		strcpy(conn->errorMessage.data,
			   "PQrequestCancel() -- connection is not
open\n");
		conn->errorMessage.len =
strlen(conn->errorMessage.data);
#ifdef WIN32
		WSASetLastError(save_errno);
#else
		errno = save_errno;
#endif
		return FALSE;
	}

What if another thread is modifying or reading the errorMessage variable
at the same time? Or what if another thread just PQfinished() the entire
conenction, which causes a free() call? None of this stuff is
thread-protected...

It may be re-entrant-safe, but I don't beleive it's thread safe. libpq
in general is only thread safe as long as a single connection is only
used on a single thread.

//Magnus

pgsql-hackers-win32 by date

Next:From: Andrew DunstanDate: 2004-10-26 15:34:46
Subject: Re: pg_ctl strangeness under msys
Previous:From: Tom LaneDate: 2004-10-26 14:41:09
Subject: Re: Win32 open items

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group