qrexec-lib: fail peer_client_init call when domain dies
Don't wait indefinitely.
This commit is contained in:
parent
2739340559
commit
2ee40f16c2
@ -170,9 +170,10 @@ char *peer_client_init(int dom, int port)
|
||||
struct xs_handle *xs;
|
||||
char buf[64];
|
||||
char *name;
|
||||
char *dummy;
|
||||
char *dummy, *dummy2;
|
||||
unsigned int len = 0;
|
||||
char devbuf[128];
|
||||
char dombuf[128];
|
||||
unsigned int count;
|
||||
char **vec;
|
||||
|
||||
@ -192,6 +193,7 @@ char *peer_client_init(int dom, int port)
|
||||
snprintf(devbuf, sizeof(devbuf),
|
||||
"/local/domain/%d/device/vchan/%d/event-channel", dom,
|
||||
port);
|
||||
snprintf(dombuf, sizeof(dombuf), "/local/domain/%d", dom);
|
||||
xs_watch(xs, devbuf, devbuf);
|
||||
do {
|
||||
vec = xs_read_watch(xs, &count);
|
||||
@ -201,6 +203,15 @@ char *peer_client_init(int dom, int port)
|
||||
dummy = xs_read(xs, 0, devbuf, &len);
|
||||
if (dummy)
|
||||
free(dummy);
|
||||
else {
|
||||
/* check if domain still alive */
|
||||
dummy2 = xs_read(xs, 0, dombuf, &len);
|
||||
if (!dummy2) {
|
||||
fprintf(stderr, "domain dead\n");
|
||||
exit(1);
|
||||
}
|
||||
free(dummy2);
|
||||
}
|
||||
}
|
||||
while (!dummy || !len); // wait for the server to create xenstore entries
|
||||
xs_daemon_close(xs);
|
||||
|
Loading…
Reference in New Issue
Block a user