clients: Check return value of wl_display_dispatch()

The simple clients all just call wl_display_dispatch() in a while loop
without checking the return value.  Now, if the server dies or other
error occurs, we get a -1 return value instead and need to break the loop.
Kristian Høgsberg 12 years ago
parent 7a92ea494c
commit a17f7a13fd
  1. 6
      clients/simple-egl.c
  2. 5
      clients/simple-shm.c
  3. 5
      clients/simple-touch.c
  4. 9
      clients/window.c

@ -591,7 +591,7 @@ main(int argc, char **argv)
struct sigaction sigint;
struct display display = { 0 };
struct window window = { 0 };
int i;
int i, ret = 0;
window.display = &display;
display.window = &window;
@ -627,8 +627,8 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
while (running)
wl_display_dispatch(display.display);
while (running && ret != -1)
ret = wl_display_dispatch(display.display);
fprintf(stderr, "simple-egl exiting\n");

@ -328,6 +328,7 @@ main(int argc, char **argv)
struct sigaction sigint;
struct display *display;
struct window *window;
int ret;
display = create_display();
window = create_window(display, 250, 250);
@ -344,8 +345,8 @@ main(int argc, char **argv)
redraw(window, NULL, 0);
while (running)
wl_display_dispatch(display->display);
while (running && ret != -1)
ret = wl_display_dispatch(display->display);
fprintf(stderr, "simple-shm exiting\n");
destroy_window(window);

@ -316,11 +316,12 @@ int
main(int argc, char **argv)
{
struct touch *touch;
int ret = 0;
touch = touch_create(600, 500);
while (true)
wl_display_dispatch(touch->display);
while (ret != -1)
ret = wl_display_dispatch(touch->display);
return 0;
}

@ -3837,8 +3837,13 @@ handle_display_data(struct task *task, uint32_t events)
return;
}
if (events & EPOLLIN)
wl_display_dispatch(display->display);
if (events & EPOLLIN) {
ret = wl_display_dispatch(display->display);
if (ret == -1) {
display_exit(display);
return;
}
}
if (events & EPOLLOUT) {
ret = wl_display_flush(display->display);

Loading…
Cancel
Save