pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hiroshi Inoue <Inoue@tpf.co.jp>
To: swampler@noao.edu
Cc: 'Postgres-ODBC' <pgsql-odbc@postgresql.org>
Subject: Re: Help with hang on empty query (PG 7.3.2,
Date: Mon, 10 Nov 2003 16:20:50 +0900
Message-ID: <3FAF3C52.82D8A4E0@tpf.co.jp> (raw)
References: <012c01c3a650$bb5a07e0$3d283ddb@PbgX>
	<1068398142.12206.64.camel@weaver.tuc.noao.edu>

Steve Wampler wrote:
> 
> On Sat, 2003-11-08 at 16:33, Hiroshi Inoue wrote:
> > > -----Original Message-----
> > > From: Steve Wampler
> > >
> > > On Fri, 2003-11-07 at 09:05, Steve Wampler wrote:
> > > > I recently upgraded a system from RedHat 8 to RedHat 9, which
> > > > meant an upgrade of PG 7.2 to 7.3.2.  Several applications
> > > > that are written in a language that relies upon odbc to access
> > > > postgresql have stopped working.
> > >
> > > I've now verified that the same hang occurs when using the
> > > odbctest program that comes with libiodbc.
> > >
> > > Can anyone suggest a way to track this down further?  Thanks!
> >
> > Could you try to remove ENTER_CONN_CS in CC_send_query
> > in connection.c and change all RETURN_AFTER_LEAVE_CS(self, ..)
> > to "return ..(the 2nd parameter) "?
> 
> Hi Hiroshi,
> 
> Thanks for the suggestion.  I get the same behavior, but
> the mylog file has more information in it (the other logs
> are unchanged):

OK I can reproduce the phenomenon here.
Please try the attached patch.

regards,
Hiroshi Inoue
	http://www.geocities.jp/inocchichichi/psqlodbc/

Attachments:

thread.diff (application/x-unknown-content-type-hidemaru.diff, 5.8K) download *** connection.h.save Mon Sep 15 17:25:03 2003 --- connection.h Mon Nov 10 14:22:07 2003 *************** *** 93,99 **** #define LEAVE_CONN_CS(x) LeaveCriticalSection(&((x)->cs)) #define DELETE_CONN_CS(x) DeleteCriticalSection(&((x)->cs)) #elif defined(POSIX_MULTITHREAD_SUPPORT) ! #define INIT_CONN_CS(x) pthread_mutex_init(&((x)->cs),0) #define ENTER_CONN_CS(x) pthread_mutex_lock(&((x)->cs)) #define LEAVE_CONN_CS(x) pthread_mutex_unlock(&((x)->cs)) #define DELETE_CONN_CS(x) pthread_mutex_destroy(&((x)->cs)) --- 93,99 ---- #define LEAVE_CONN_CS(x) LeaveCriticalSection(&((x)->cs)) #define DELETE_CONN_CS(x) DeleteCriticalSection(&((x)->cs)) #elif defined(POSIX_MULTITHREAD_SUPPORT) ! #define INIT_CONN_CS(x) pthread_mutex_init(&((x)->cs), getMutexAttr()) #define ENTER_CONN_CS(x) pthread_mutex_lock(&((x)->cs)) #define LEAVE_CONN_CS(x) pthread_mutex_unlock(&((x)->cs)) #define DELETE_CONN_CS(x) pthread_mutex_destroy(&((x)->cs)) *** psqlodbc.h.save Wed Aug 27 19:17:53 2003 --- psqlodbc.h Mon Nov 10 13:41:28 2003 *************** *** 5,11 **** * * Comments: See "notice.txt" for copyright and license information. * ! * $Id: psqlodbc.h,v 1.78 2003/08/27 10:17:53 hinoue Exp $ * */ --- 5,11 ---- * * Comments: See "notice.txt" for copyright and license information. * ! * $Id: psqlodbc.h,v 1.79 2003/10/25 04:19:22 hinoue Exp $ * */ *************** *** 279,295 **** #include "misc.h" #ifdef UNICODE_SUPPORT UInt4 ucs2strlen(const SQLWCHAR *ucs2str); char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen, BOOL tolower); UInt4 utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen); #define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen) #endif /* UNICODE_SUPPORT */ /*#define _MEMORY_DEBUG_ */ #ifdef _MEMORY_DEBUG_ ! void *debug_alloc(size_t); ! void *debug_realloc(void *, size_t); ! char *debug_strdup(const char *); void debug_free(void *); void debug_memory_check(void); --- 279,300 ---- #include "misc.h" + int initialize_global_cs(void); + #ifdef POSIX_MULTITHTREAD_SUPPORT + const pthread_mutexattr_t *getMutexAttr(void); + #endif /* POSIX_MULTITHTREAD_SUPPORT */ #ifdef UNICODE_SUPPORT UInt4 ucs2strlen(const SQLWCHAR *ucs2str); char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen, BOOL tolower); UInt4 utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen); #define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen) #endif /* UNICODE_SUPPORT */ + /*#define _MEMORY_DEBUG_ */ #ifdef _MEMORY_DEBUG_ ! void *debug_alloc(size_t); ! void *debug_realloc(void *, size_t); ! char *debug_strdup(const char *); void debug_free(void *); void debug_memory_check(void); *** psqlodbc.c.save Tue Dec 17 00:01:34 2002 --- psqlodbc.c Mon Nov 10 15:21:25 2003 *************** *** 25,38 **** RETCODE SQL_API SQLDummyOrdinal(void); - #ifdef WIN32 - HINSTANCE NEAR s_hModule; /* Saved module handle. */ #if defined(WIN_MULTITHREAD_SUPPORT) extern CRITICAL_SECTION qlog_cs, mylog_cs, conns_cs; #elif defined(POSIX_MULTITHREAD_SUPPORT) extern pthread_mutex_t qlog_cs, mylog_cs, conns_cs; #endif /* WIN_MULTITHREAD_SUPPORT */ /* This is where the Driver Manager attaches to this Driver */ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) --- 25,78 ---- RETCODE SQL_API SQLDummyOrdinal(void); #if defined(WIN_MULTITHREAD_SUPPORT) extern CRITICAL_SECTION qlog_cs, mylog_cs, conns_cs; #elif defined(POSIX_MULTITHREAD_SUPPORT) extern pthread_mutex_t qlog_cs, mylog_cs, conns_cs; + static pthread_mutexattr_t recur_attr; + const pthread_mutexattr_t* getMutexAttr(void) + { + static int init = 1; + + if (init) + { + if (0 != pthread_mutexattr_init(&recur_attr)) + return NULL; + if (0 != pthread_mutexattr_settype(&recur_attr, PTHREAD_MUTEX_RECURSIVE_NP)) + return NULL; + } + init = 0; + + return &recur_attr; + } #endif /* WIN_MULTITHREAD_SUPPORT */ + int initialize_global_cs(void) + { + static int init = 1; + + if (!init) + return 0; + init = 0; + #ifdef POSIX_MULTITHREAD_SUPPORT + getMutexAttr(); + #endif /* POSIX_MULTITHREAD_SUPPORT */ + INIT_QLOG_CS; + INIT_MYLOG_CS; + INIT_CONNS_CS; + + return 0; + } + + static void finalize_global_cs(void) + { + DELETE_CONNS_CS; + DELETE_QLOG_CS; + DELETE_MYLOG_CS; + } + + #ifdef WIN32 + HINSTANCE NEAR s_hModule; /* Saved module handle. */ /* This is where the Driver Manager attaches to this Driver */ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) *************** *** 59,67 **** return FALSE; } ! INIT_QLOG_CS; ! INIT_MYLOG_CS; ! INIT_CONNS_CS; getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL); break; --- 99,105 ---- return FALSE; } ! initialize_global_cs(); getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL); break; *************** *** 69,77 **** break; case DLL_PROCESS_DETACH: ! DELETE_CONNS_CS; ! DELETE_QLOG_CS; ! DELETE_MYLOG_CS; WSACleanup(); return TRUE; --- 107,113 ---- break; case DLL_PROCESS_DETACH: ! finalize_global_cs(); WSACleanup(); return TRUE; *************** *** 104,109 **** --- 140,146 ---- __attribute__((constructor)) init(void) { + initialize_global_cs(); getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL); return TRUE; } *************** *** 117,122 **** --- 154,160 ---- BOOL _init(void) { + initialize_global_cs(); getCommonDefaults(DBMS_NAME, ODBCINST_INI, NULL); return TRUE; } *************** *** 124,129 **** --- 162,168 ---- BOOL _fini(void) { + finalize_global_cs(); return TRUE; } #endif /* not __GNUC__ */

view thread (9+ messages)  latest in thread

Message-ID: <3FAF3C52.82D8A4E0@tpf.co.jp>
Permalink:  ../3FAF3C52.82D8A4E0@tpf.co.jp/
Also on:    postgresql.org/message-id/3FAF3C52.82D8A4E0@tpf.co.jp

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: Inoue@tpf.co.jp, swampler@noao.edu
  Subject: Re: Help with hang on empty query (PG 7.3.2,
  In-Reply-To: <3FAF3C52.82D8A4E0@tpf.co.jp>
  References: <012c01c3a650$bb5a07e0$3d283ddb@PbgX> <1068398142.12206.64.camel@weaver.tuc.noao.edu> <3FAF3C52.82D8A4E0@tpf.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox