From e21d87f88c3f76acb2e0ffe2d0b91e73a3ef9fc7 Mon Sep 17 00:00:00 2001 From: Ludek Finstrle Date: Thu, 26 Jan 2006 19:13:59 +0000 Subject: [PATCH] fixed ODBC driver failure when log output isn't writeable --- misc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/misc.c b/misc.c index c8cc8cf..5c8eaf8 100644 --- a/misc.c +++ b/misc.c @@ -139,7 +139,10 @@ mylog(char *fmt,...) filedes = open(filebuf, O_WRONLY | O_APPEND | O_CREAT, S_IWUSR | S_IRUSR); LOGFP = fdopen(filedes, PG_BINARY_A); #endif - setbuf(LOGFP, NULL); + if (LOGFP) + setbuf(LOGFP, NULL); + else + mylog_on = 0; } #ifdef WIN_MULTITHREAD_SUPPORT @@ -188,12 +191,15 @@ qlog(char *fmt,...) { generate_filename(QLOGDIR, QLOGFILE, filebuf); #ifdef WIN32 - LOGFP = fopen(filebuf, PG_BINARY_A); + LOGFP = fopen(filebuf, PG_BINARY_A); #else - filedes = open(filebuf, O_WRONLY | O_APPEND | O_CREAT, S_IWUSR | S_IRUSR); - LOGFP = fdopen(filedes, PG_BINARY_A); + filedes = open(filebuf, O_WRONLY | O_APPEND | O_CREAT, S_IWUSR | S_IRUSR); + LOGFP = fdopen(filedes, PG_BINARY_A); #endif - setbuf(LOGFP, NULL); + if (LOGFP) + setbuf(LOGFP, NULL); + else + qlog_on = 0; } if (LOGFP) -- 2.39.5