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.
This commit is contained in:
@@ -591,7 +591,7 @@ main(int argc, char **argv)
|
|||||||
struct sigaction sigint;
|
struct sigaction sigint;
|
||||||
struct display display = { 0 };
|
struct display display = { 0 };
|
||||||
struct window window = { 0 };
|
struct window window = { 0 };
|
||||||
int i;
|
int i, ret = 0;
|
||||||
|
|
||||||
window.display = &display;
|
window.display = &display;
|
||||||
display.window = &window;
|
display.window = &window;
|
||||||
@@ -627,8 +627,8 @@ main(int argc, char **argv)
|
|||||||
sigint.sa_flags = SA_RESETHAND;
|
sigint.sa_flags = SA_RESETHAND;
|
||||||
sigaction(SIGINT, &sigint, NULL);
|
sigaction(SIGINT, &sigint, NULL);
|
||||||
|
|
||||||
while (running)
|
while (running && ret != -1)
|
||||||
wl_display_dispatch(display.display);
|
ret = wl_display_dispatch(display.display);
|
||||||
|
|
||||||
fprintf(stderr, "simple-egl exiting\n");
|
fprintf(stderr, "simple-egl exiting\n");
|
||||||
|
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ main(int argc, char **argv)
|
|||||||
struct sigaction sigint;
|
struct sigaction sigint;
|
||||||
struct display *display;
|
struct display *display;
|
||||||
struct window *window;
|
struct window *window;
|
||||||
|
int ret;
|
||||||
|
|
||||||
display = create_display();
|
display = create_display();
|
||||||
window = create_window(display, 250, 250);
|
window = create_window(display, 250, 250);
|
||||||
@@ -344,8 +345,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
redraw(window, NULL, 0);
|
redraw(window, NULL, 0);
|
||||||
|
|
||||||
while (running)
|
while (running && ret != -1)
|
||||||
wl_display_dispatch(display->display);
|
ret = wl_display_dispatch(display->display);
|
||||||
|
|
||||||
fprintf(stderr, "simple-shm exiting\n");
|
fprintf(stderr, "simple-shm exiting\n");
|
||||||
destroy_window(window);
|
destroy_window(window);
|
||||||
|
|||||||
@@ -316,11 +316,12 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct touch *touch;
|
struct touch *touch;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
touch = touch_create(600, 500);
|
touch = touch_create(600, 500);
|
||||||
|
|
||||||
while (true)
|
while (ret != -1)
|
||||||
wl_display_dispatch(touch->display);
|
ret = wl_display_dispatch(touch->display);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -3837,8 +3837,13 @@ handle_display_data(struct task *task, uint32_t events)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events & EPOLLIN)
|
if (events & EPOLLIN) {
|
||||||
wl_display_dispatch(display->display);
|
ret = wl_display_dispatch(display->display);
|
||||||
|
if (ret == -1) {
|
||||||
|
display_exit(display);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (events & EPOLLOUT) {
|
if (events & EPOLLOUT) {
|
||||||
ret = wl_display_flush(display->display);
|
ret = wl_display_flush(display->display);
|
||||||
|
|||||||
Reference in New Issue
Block a user