Skip to content

Commit

Permalink
Merge pull request #121 from tklengyel/timer
Browse files Browse the repository at this point in the history
Only start timeout on loop start
  • Loading branch information
tklengyel committed Apr 19, 2016
2 parents 4899ada + 733879b commit 1ed1dd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/drakvuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ static gpointer timer(gpointer data)
{
drakvuf_c* drakvuf = (drakvuf_c*)data;

/* Wait for the loop to start */
g_mutex_lock(&drakvuf->loop_signal);
g_mutex_unlock(&drakvuf->loop_signal);

while(drakvuf->timeout && !drakvuf->interrupted) {
sleep(1);
--drakvuf->timeout;
Expand Down Expand Up @@ -159,6 +163,8 @@ drakvuf_c::drakvuf_c(const char* domain,
this->interrupted = 0;
this->timeout = timeout;
this->rekall_profile = rekall_profile;
g_mutex_init(&this->loop_signal);
g_mutex_lock(&this->loop_signal);

if (!drakvuf_init(&this->drakvuf, domain, rekall_profile))
throw -1;
Expand All @@ -172,6 +178,8 @@ drakvuf_c::drakvuf_c(const char* domain,

void drakvuf_c::close()
{
g_mutex_clear(&this->loop_signal);

if (this->plugins)
delete this->plugins;

Expand Down Expand Up @@ -206,6 +214,7 @@ void drakvuf_c::interrupt(int signal)

void drakvuf_c::loop()
{
g_mutex_unlock(&this->loop_signal);
drakvuf_loop(this->drakvuf);
}

Expand Down
1 change: 1 addition & 0 deletions src/drakvuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class drakvuf_c {
public:
int timeout;
int interrupted;
GMutex loop_signal;

drakvuf_c(const char* domain,
const char *rekall_profile,
Expand Down

0 comments on commit 1ed1dd0

Please sign in to comment.