Skip to content

Commit

Permalink
first rewrite (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Nov 10, 2023
1 parent 775650d commit 5b6e58a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions libcob/profiling.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,24 +395,24 @@ cob_prof_end ()
FILE *file;
char prof_file_buf[COB_NORMAL_BUFF];
const char* prof_filename = NULL;
if (!cobsetptr || !is_active) return;

if (!cobsetptr || !is_active || !prof_program_id) return;

while (current_idx >= 0) {
cob_prof_exit_section (called_runtimes[current_idx], called_procedures[current_idx]);
}

prof_filename = cobsetptr->cob_prof_filename;
if (!prof_filename){

/* Do not use cob_sys_getpid() in case of fork() */
int pid = getpid();
sprintf(prof_file_buf, "%d-%s-prof.csv", pid, prof_program_id);
prof_filename = prof_file_buf;
}

file = fopen (prof_filename, !cobsetptr->cob_unix_lf ? "w" : "wb");

/* XXX
The filename should use the "normal" way filenames are
Expand All @@ -424,10 +424,9 @@ Please include the PID in each line, this way it is no problem if multiple runni
To not break the tests under MinGW, please handle COB_UNIX_LF here, too.
*/

if (!!file) {
/* XXX
Should we wait (with a timeout) if we get a file lock (another process
writing to the file)? Should we allow multiple processes to write to
the same file in parallel?
Expand Down

0 comments on commit 5b6e58a

Please sign in to comment.