Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0zbz-0001HG-72 for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2013 19:15:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U0zbx-0002Ev-W3 for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Jan 2013 19:15:50 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0qlw-0001pt-VX for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:49:33 +0000 Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0qlv-0004uC-8S for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:49:32 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0qlt-0006K8-UM for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:49:30 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1U0qlt-0005um-0d for pgsql-bugs@postgresql.org; Thu, 31 Jan 2013 09:49:29 +0000 Date: Thu, 31 Jan 2013 09:49:29 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7841: Multithreading in libpq is not working To: pgsql-bugs@postgresql.org From: biernatj@interia.pl X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 7841 Logged by: Joanna Biernat-Gerono Email address: biernatj@interia.pl PostgreSQL version: 9.2.2 Operating system: Windows 7 Description:=20=20=20=20=20=20=20=20 Sample code that provides to access violation (I am using the latest libpq that is compiled with multithread support, connection was made to two different dbs). The code is below: #define WINNT_OS #include #include #include "libpq-fe.h" #include #define STD__NULL NULL #define STD__SUCCESS 0 #define STD__FAILED -1 #define STD__FAIL -1 #define TIMEOUT 100 using namespace std; volatile bool m_bLicenseCheckedOut =3D false; enum status { idle,=20 running, stop, done } m_running =3D idle; int m_renewalTime =3D 0; HANDLE m_hThread =3D NULL; HANDLE m_hEvent =3D NULL; DWORD WINAPI threadProc(LPVOID lpvoid) {=20=20=20=20 int step =3D 0; while(m_running =3D=3D running) {=20=20=20=20=20=20=20 PGconn *conn; =20=20=20=20 try {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 const char *keys[]=3D{"dbname", "user", "password", "host", "port", "sslcert", "sslkey", "sslrootcert", "sslmode", NULL}; const char *values[]=3D{"put_value_here", "put_value_here" , "put_value_here" , "put_value_here" , "put_value_here" , "put_value_here", "put_value_here", "put_value_here" ,"verify-full", NULL}; =20=20=20=20=20=20=20=20 // conn =3D PQconnectdbParams(keys,values,0); //conn =3D PQsetdbLogin("put_value_here", "put_value_here", NULL, NULL, "dbname=3Dput_value_here sslcert=3Dput_value_here sslkey=3Dput_value_= here sslrootcert=3Dput_value_here sslmode=3Dverify-full", "put_value_here" , "put_value_here"); conn =3D PQsetdbLogin("put_value_here", "put_value_here", NULL, NUL= L, "put_value_here", "put_value_here" , "put_value_here"); long status =3D PQstatus(conn); =20=20=20=20=20=20=20=20 if (status =3D=3D CONNECTION_OK) { cout << "\nSuccessfully connected to DB:"<