diff -Nacr a/msdtc_enlist.cpp b/msdtc_enlist.cpp *** a/msdtc_enlist.cpp 2016-04-15 22:11:34.000000000 +0900 --- b/msdtc_enlist.cpp 2016-05-30 10:05:00.000000000 +0900 *************** *** 103,115 **** DeleteCriticalSection(&life_cs); } } init_crit; - #ifdef _LOCK_DEBUG_ - #define LIFELOCK_ACQUIRE (forcelog("LIFELOCK_ACQUIRE\n"), EnterCriticalSection(&init_crit.life_cs), forcelog("LIFELOCK ACQUIRED\n")) - #define LIFELOCK_RELEASE (forcelog("LIFELOCK_RELEASE\n"), LeaveCriticalSection(&init_crit.life_cs)) - #else #define LIFELOCK_ACQUIRE EnterCriticalSection(&init_crit.life_cs) #define LIFELOCK_RELEASE LeaveCriticalSection(&init_crit.life_cs) - #endif /* * Some helper macros about connection handling. --- 103,110 ---- *************** *** 236,252 **** bool CloseThread(DWORD type); private: ~IAsyncPG(); - #ifdef _LOCK_DEBUG_ - void SLOCK_ACQUIRE() {forcelog("SLOCK_ACQUIRE %d\n", spin_cnt); EnterCriticalSection(&as_spin); spin_cnt++;} - void SLOCK_RELEASE() {forcelog("SLOCK_RELEASE=%d\n", spin_cnt); LeaveCriticalSection(&as_spin); spin_cnt--;} - void ELOCK_ACQUIRE() {forcelog("%p->ELOCK_ACQUIRE\n", this); EnterCriticalSection(&as_exec); forcelog("ELOCK ACQUIRED\n");} - void ELOCK_RELEASE() {forcelog("ELOCK_RELEASE\n"); LeaveCriticalSection(&as_exec);} - #else void SLOCK_ACQUIRE() {EnterCriticalSection(&as_spin);} void SLOCK_RELEASE() {LeaveCriticalSection(&as_spin);} void ELOCK_ACQUIRE() {EnterCriticalSection(&as_exec);} void ELOCK_RELEASE() {LeaveCriticalSection(&as_exec);} - #endif /* _LOCK_DEBUG_ */ void *getLockedXAConn(void); void *generateXAConn(bool spinAcquired); void *isolateXAConn(bool spinAcquired, bool continueConnection); --- 231,240 ---- *************** *** 301,307 **** } HRESULT STDMETHODCALLTYPE IAsyncPG::QueryInterface(REFIID riid, void ** ppvObject) { ! forcelog("%p QueryInterface called\n", this); if (riid == IID_IUnknown || riid == IID_ITransactionResourceAsync) { *ppvObject = this; --- 289,295 ---- } HRESULT STDMETHODCALLTYPE IAsyncPG::QueryInterface(REFIID riid, void ** ppvObject) { ! mylog("%p QueryInterface called\n", this); if (riid == IID_IUnknown || riid == IID_ITransactionResourceAsync) { *ppvObject = this; *************** *** 910,916 **** } HRESULT STDMETHODCALLTYPE IAsyncPG::TMDown(void) { ! forcelog("%p TMDown called\n", this); return S_OK; } --- 898,904 ---- } HRESULT STDMETHODCALLTYPE IAsyncPG::TMDown(void) { ! mylog("%p TMDown called\n", this); return S_OK; } *************** *** 1082,1088 **** res = pDtc->QueryInterface(IID_IDtcToXaHelperSinglePipe, (void **) &pHelper); if (res != S_OK || !pHelper) { ! forcelog("DtcToXaHelperSingelPipe get error %d\n", res); pHelper = NULL; return SQL_ERROR; } --- 1070,1076 ---- res = pDtc->QueryInterface(IID_IDtcToXaHelperSinglePipe, (void **) &pHelper); if (res != S_OK || !pHelper) { ! mylog("DtcToXaHelperSingelPipe get error %d\n", res); pHelper = NULL; return SQL_ERROR; } *************** *** 1252,1258 **** grfOptions, NULL, (void **) &pDtc); if (FAILED(res)) { ! forcelog("DtcGetTransactionManager error %x\n", res); pDtc = NULL; } } --- 1240,1246 ---- grfOptions, NULL, (void **) &pDtc); if (FAILED(res)) { ! mylog("DtcGetTransactionManager error %x\n", res); pDtc = NULL; } } diff -Nacr a/mylog.c b/mylog.c *** a/mylog.c 2016-04-15 22:11:34.000000000 +0900 --- b/mylog.c 2016-05-30 10:05:12.000000000 +0900 *************** *** 108,114 **** #elif defined(POSIX_MULTITHREAD_SUPPORT) static pthread_mutex_t qlog_cs, mylog_cs; #endif /* WIN_MULTITHREAD_SUPPORT */ - static int force_log = 0; static int mylog_on = 0, qlog_on = 0; #if defined(WIN_MULTITHREAD_SUPPORT) --- 108,113 ---- *************** *** 140,162 **** #define DELETE_MYLOG_CS #endif /* WIN_MULTITHREAD_SUPPORT */ - #ifdef MY_LOG #define MYLOGFILE "mylog_" #ifndef WIN32 #define MYLOGDIR "/tmp" #else #define MYLOGDIR "c:" #endif /* WIN32 */ - #endif /* MY_LOG */ - #ifdef Q_LOG #define QLOGFILE "psqlodbc_" #ifndef WIN32 #define QLOGDIR "/tmp" #else #define QLOGDIR "c:" #endif /* WIN32 */ - #endif /* QLOG */ int get_mylog(void) --- 139,157 ---- *************** *** 193,200 **** mylog_on = 0; else if (globals.debug > 0) mylog_on = globals.debug; - else - mylog_on = force_log; if (qlog_onoff) qlog_on_count += cnopen; else --- 188,193 ---- *************** *** 205,212 **** qlog_on = 0; else if (globals.commlog > 0) qlog_on = globals.commlog; - else - qlog_on = force_log; LEAVE_QLOG_CS; LEAVE_MYLOG_CS; } --- 198,203 ---- *************** *** 214,226 **** #ifdef WIN32 #define LOGGING_PROCESS_TIME #include - #define PODBCLOGDIR "C:\\podbclog" #endif /* WIN32 */ #ifdef LOGGING_PROCESS_TIME #include static DWORD start_time = 0; #endif /* LOGGING_PROCESS_TIME */ - #ifdef MY_LOG static FILE *MLOGFP = NULL; static void MLOG_open() --- 205,215 ---- *************** *** 235,252 **** { generate_homefile(MYLOGFILE, filebuf); MLOGFP = fopen(filebuf, PG_BINARY_A); - if (!MLOGFP) - { - generate_filename("C:\\podbclog", MYLOGFILE, filebuf); - MLOGFP = fopen(filebuf, PG_BINARY_A); - #ifdef WIN32 - if (!MLOGFP) - { - if (0 == _mkdir(PODBCLOGDIR)) - MLOGFP = fopen(filebuf, PG_BINARY_A); - } - #endif /* WIN32 */ - } } if (MLOGFP) setbuf(MLOGFP, NULL); --- 224,229 ---- *************** *** 295,345 **** LEAVE_MYLOG_CS; GENERAL_ERRNO_SET(gerrno); } - DLL_DECLARE void - forcelog(const char *fmt,...) - { - static BOOL force_on = TRUE; - va_list args; - int gerrno = GENERAL_ERRNO; - - if (!force_on) - return; - - ENTER_MYLOG_CS; - va_start(args, fmt); - - if (!MLOGFP) - { - MLOG_open(); - if (!MLOGFP) - force_on = FALSE; - } - if (MLOGFP) - { - #ifdef WIN_MULTITHREAD_SUPPORT - #ifdef WIN32 - time_t ntime; - char ctim[128]; - - time(&ntime); - strcpy(ctim, ctime(&ntime)); - ctim[strlen(ctim) - 1] = '\0'; - fprintf(MLOGFP, "[%d.%d(%s)]", GetCurrentProcessId(), GetCurrentThreadId(), ctim); - #endif /* WIN32 */ - #endif /* WIN_MULTITHREAD_SUPPORT */ - #if defined(POSIX_MULTITHREAD_SUPPORT) - fprintf(MLOGFP, "[%lu]", pthread_self()); - #endif /* POSIX_MULTITHREAD_SUPPORT */ - vfprintf(MLOGFP, fmt, args); - } - va_end(args); - LEAVE_MYLOG_CS; - GENERAL_ERRNO_SET(gerrno); - } static void mylog_initialize(void) { INIT_MYLOG_CS; - mylog_on = force_log; } static void mylog_finalize(void) { --- 272,280 ---- *************** *** 351,363 **** } DELETE_MYLOG_CS; } - #else - static void mylog_initialize(void) {} - static void mylog_finalize(void) {} - #endif /* MY_LOG */ - #ifdef Q_LOG static FILE *QLOGFP = NULL; void qlog(char *fmt,...) --- 286,293 ---- *************** *** 407,413 **** static void qlog_initialize(void) { INIT_QLOG_CS; - qlog_on = force_log; } static void qlog_finalize(void) { --- 337,342 ---- *************** *** 419,428 **** } DELETE_QLOG_CS; } - #else - static void qlog_initialize(void) {} - static void qlog_finalize(void) {} - #endif /* Q_LOG */ void InitializeLogging(void) { --- 348,353 ---- diff -Nacr a/mylog.h b/mylog.h *** a/mylog.h 2016-04-15 22:11:34.000000000 +0900 --- b/mylog.h 2016-05-30 10:05:12.000000000 +0900 *************** *** 32,88 **** #ifdef __cplusplus extern "C" { #endif - /* Uncomment MY_LOG define to compile in the mylog() statements. - Then, debug logging will occur if 'Debug' is set to 1 in the ODBCINST.INI - portion of the registry. You may have to manually add this key. - This logfile is intended for development use, not for an end user! - */ - #define MY_LOG - - /* Uncomment Q_LOG to compile in the qlog() statements (Communications log, i.e. CommLog). - This logfile contains serious log statements that are intended for an - end user to be able to read and understand. It is controlled by the - 'CommLog' flag in the ODBCINST.INI portion of the registry (see above), - which is manipulated on the setup/connection dialog boxes. - */ - #define Q_LOG - - #ifdef MY_LOG DLL_DECLARE void mylog(const char *fmt,...); - DLL_DECLARE void forcelog(const char *fmt,...); #define inolog if (get_mylog() > 1) mylog /* for really temporary debug */ - #else /* MY_LOG */ - #ifndef WIN32 - #define mylog(args...) /* GNU convention for variable arguments */ - #define forcelog(args...) /* GNU convention for variable arguments */ - #define inolog(args...) /* GNU convention for variable arguments */ - #else - #define _DUMMY_LOG_IMPL_ - static void DumLog(const char *fmt,...) {} - #define mylog if (0) DumLog /* mylog */ - #define forcelog if (0) DumLog /* forcelog */ - #define inolog if (0) DumLog /* inolog */ - #endif /* WIN32 */ - #endif /* MY_LOG */ - - #ifdef Q_LOG extern void qlog(char *fmt,...); #define inoqlog if (get_qlog() > 1) qlog /* for really temporary debug */ - #else - #ifndef WIN32 - #define qlog(args...) /* GNU convention for variable arguments */ - #define inoqlog(args...) /* GNU convention for variable arguments */ - #else - #ifndef _DUMMY_LOG_IMPL_ - #define _DUMMY_LOG_IMPL_ - static void DumLog(const char *fmt,...) {} - #endif /* _DUMMY_LOG_IMPL_ */ - #define qlog if (0) DumLog /* qlog */ - #define inoqlog if (0) DumLog /* inoqlog */ - #endif /* WIN32 */ - #endif /* QLOG */ int get_qlog(void); int get_mylog(void); --- 32,43 ----