Skip to content

Commit

Permalink
pulse: periodically check if vchan connection is alive
Browse files Browse the repository at this point in the history
If the remote domain is killed, vchan may not get the notification. To
avoid hanging process in such a case, periodically check if vchan
connection is open (as other vchan applications do).

This partially reverts d0fcc6c.

Fixes QubesOS/qubes-issues#5760
  • Loading branch information
marmarek committed Apr 5, 2020
1 parent fc65f6a commit ad3b39c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pulse/pacat-simple-vchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,24 @@ static void context_state_callback(pa_context *c, void *userdata) {

}

static void check_vchan_eof_timer(pa_mainloop_api*a, pa_time_event* e,
const struct timeval *UNUSED(tv), void *userdata)
{
struct userdata *u = userdata;
struct timeval restart_tv;
assert(u);

if (!libvchan_is_open(u->play_ctrl)) {
pacat_log("vchan_is_eof (timer)");
quit(u, 0);
return;
}

pa_gettimeofday(&restart_tv);
pa_timeval_add(&restart_tv, (pa_usec_t) 5 * 1000 * PA_USEC_PER_MSEC);
a->time_restart(e, &restart_tv);
}

int main(int argc, char *argv[])
{
struct timeval tv;
Expand Down Expand Up @@ -680,6 +698,12 @@ int main(int argc, char *argv[])

pa_gettimeofday(&tv);
pa_timeval_add(&tv, (pa_usec_t) 5 * 1000 * PA_USEC_PER_MSEC);
time_event = u.mainloop_api->time_new(u.mainloop_api, &tv, check_vchan_eof_timer, &u);
if (!time_event) {
pacat_log("time_event create failed");
goto quit;
}

if (!(u.context = pa_context_new_with_proplist(u.mainloop_api, NULL, u.proplist))) {
pacat_log("pa_context_new() failed.");
goto quit;
Expand Down

0 comments on commit ad3b39c

Please sign in to comment.