Skip to content

Commit

Permalink
Merge pull request #14 from v-chojas/fix-trace-refcount
Browse files Browse the repository at this point in the history
Fix tracing with multiple environments
  • Loading branch information
lurcher authored May 7, 2018
2 parents 4318216 + edc50eb commit 8656d0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions DriverManager/__info.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@

static char const rcsid[]= "$RCSfile: __info.c,v $ $Revision: 1.50 $";

struct log_structure log_info = { NULL, NULL, 0 };
struct log_structure log_info = { NULL, NULL, 0, 0 };

SQLINTEGER ODBCSharedTraceFlag = 0;

Expand Down Expand Up @@ -5815,6 +5815,7 @@ void dm_log_open( char *program_name,
*/

log_info.pid_logging = pid_logging;
log_info.ref_count++;
}

void dm_log_write( char *function_name, int line, int type, int severity,
Expand Down Expand Up @@ -5954,9 +5955,16 @@ void dm_log_write_diag( char *message )

void dm_log_close( void )
{
free( log_info.program_name );
free( log_info.log_file_name );
log_info.program_name = NULL;
log_info.log_file_name = NULL;
log_info.log_flag = 0;
if ( !log_info.ref_count )
return;

log_info.ref_count--;
if ( !log_info.ref_count )
{
free( log_info.program_name );
free( log_info.log_file_name );
log_info.program_name = NULL;
log_info.log_file_name = NULL;
log_info.log_flag = 0;
}
}
2 changes: 1 addition & 1 deletion DriverManager/drivermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct log_structure
int log_flag;
int pid_logging; /* the log path specifies a directory, and a */
/* log file per pid is created */

int ref_count; /* number of times dm_log_open()'d without dm_log_close() */
};

extern struct log_structure log_info;
Expand Down

0 comments on commit 8656d0f

Please sign in to comment.