Re: Win32 open items

"Magnus Hagander" <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32
Message-ID <[email protected]>
> > 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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.