Skip to content

Commit

Permalink
Improved timeout logic in quartzplugin
Browse files Browse the repository at this point in the history
When GKSTerm is in the background, its response time can vary wildly and it
can exceed the current 50ms timeout. The changes in this commit reduce the
time between checking for a response from 10ms to 1ms and increase the timeout
for the GKSTerm 'is running' response from 50ms to 500ms after the first
succesful 'is running' check.
  • Loading branch information
FlorianRhiem committed Feb 13, 2019
1 parent 1a547c0 commit 41b44a6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/gks/plugin/quartzplugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ DLLEXPORT void gks_quartzplugin(int fctid, int dx, int dy, int dimx, int *i_arr,
#endif

#define GKSTERM_DEFAULT_TIMEOUT 5000

static int gksterm_has_run_before = 0;
/* Timeout for is running is short so that GKSTerm will be started quickly. */
#define GKSTERM_IS_RUNNING_TIMEOUT 50
#define GKSTERM_IS_RUNNING_TIMEOUT (gksterm_has_run_before ? 500 : 50)

static gks_state_list_t *gkss;

Expand Down Expand Up @@ -93,7 +95,7 @@ static void gksterm_communicate(const char *request, size_t request_len, int tim
}
if (rc == -1 && errno == EAGAIN)
{
usleep(10000);
usleep(1000);
}
rc = zmq_msg_send(&message, socket, ZMQ_DONTWAIT);
}
Expand All @@ -115,7 +117,7 @@ static void gksterm_communicate(const char *request, size_t request_len, int tim
}
if (rc == -1 && errno == EAGAIN)
{
usleep(10000);
usleep(1000);
}
rc = zmq_msg_recv(&message, socket, ZMQ_DONTWAIT);
}
Expand Down Expand Up @@ -148,6 +150,7 @@ static bool gksterm_is_running()
{
return false;
}
gksterm_has_run_before = 1;
return true;
}

Expand Down

0 comments on commit 41b44a6

Please sign in to comment.