client: check for error in wl_display_read_events

This prevents from blocking shown in one display test. Also, it
makes sense to not proceed further in the code of the function
when an error ocurred.

v2. set errno
    put note about the errno into wl_display_prepare_read doc
    check for error with mutex locked

v3.
    set errno to display->last_error

    check for the error only in wl_display_read_events. It's sufficient
    as prevention for the hanging and programmer doesn't need to
    check if wl_display_prepare_read (that was previously covered by
    this patch too) returned an error or the queue just was not empty.
    Without the check, it could result in indefinite looping.

Thanks to Pekka Paalanen <pekka.paalanen@collabora.co.uk> for
constant reviewing and discussing this patch.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Marek Chalupa 2014-08-22 14:28:59 +02:00 committed by Pekka Paalanen
parent 574b710ef8
commit 8c061d1b7e

View file

@ -1200,6 +1200,13 @@ wl_display_read_events(struct wl_display *display)
pthread_mutex_lock(&display->mutex); pthread_mutex_lock(&display->mutex);
if (display->last_error) {
pthread_mutex_unlock(&display->mutex);
errno = display->last_error;
return -1;
}
ret = read_events(display); ret = read_events(display);
pthread_mutex_unlock(&display->mutex); pthread_mutex_unlock(&display->mutex);