Skip to content

Commit

Permalink
playback: Fix init and clean up of static vars needed for processing …
Browse files Browse the repository at this point in the history
…tracefile.
  • Loading branch information
icculus committed Aug 23, 2019
1 parent aa41c9c commit 288971f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions altrace_playback.c
Expand Up @@ -244,11 +244,14 @@ static void IO_ENTRYINFO(CallerInfo *callerinfo)
#define IO_END() } }


static int init_altrace_playback(const char *filename)
static int init_altrace_playback(const char *filename, void *userdata)
{
int okay = 1;

io_failure = 0;
next_mapped_threadid = 0;
trace_scope = 0;
guserdata = userdata;

logfd = open(filename, O_RDONLY);
if (logfd == -1) {
Expand Down Expand Up @@ -280,6 +283,10 @@ static void quit_altrace_playback(void)
const int io = logfd;

logfd = -1;
io_failure = 0;
next_mapped_threadid = 0;
trace_scope = 0;
guserdata = NULL;

fflush(stdout);

Expand Down Expand Up @@ -1935,7 +1942,7 @@ int process_tracelog(const char *fname, void *userdata)
off_t fdoffset = 0;
off_t fdsize = 0;

if (!init_altrace_playback(fname)) {
if (!init_altrace_playback(fname, userdata)) {
return 0;
}

Expand All @@ -1946,9 +1953,6 @@ int process_tracelog(const char *fname, void *userdata)
io_failure = 1;
}

guserdata = userdata;
trace_scope = 0;

while (!eos) {
if (!io_failure) {
fdoffset = lseek(logfd, 0, SEEK_CUR);
Expand Down Expand Up @@ -2050,7 +2054,6 @@ int process_tracelog(const char *fname, void *userdata)
}
}

guserdata = NULL;
quit_altrace_playback();

return retval;
Expand Down

0 comments on commit 288971f

Please sign in to comment.