From: Boram Park Date: Tue, 13 Mar 2018 04:17:23 +0000 (+0900) Subject: client: lock / unlock in tdm_client_handle_events_timeout X-Git-Tag: accepted/tizen/unified/20180314.062059~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F83%2F172283%2F2;p=platform%2Fcore%2Fuifw%2Flibtdm.git client: lock / unlock in tdm_client_handle_events_timeout Change-Id: I6749fef9293951b5e188634756e74d2e56f5c81f --- diff --git a/client/tdm_client.c b/client/tdm_client.c index 84b4c07..81998e6 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -592,8 +592,12 @@ _tdm_client_dispatch_timeout(tdm_private_client *private_client, int timeout) int ret; struct wl_display *display = private_client->display; - if (wl_display_prepare_read(display) == -1) - return wl_display_dispatch_pending(display); + if (wl_display_prepare_read(display) == -1) { + if (wl_display_dispatch_pending(display) > 0) + return TDM_ERROR_NONE; + else + return TDM_ERROR_OPERATION_FAILED; + } while (true) { ret = wl_display_flush(display); @@ -647,12 +651,34 @@ tdm_error tdm_client_handle_events_timeout(tdm_client *client, int ms_timeout) { tdm_private_client *private_client; - + tdm_error ret; TDM_RETURN_VAL_IF_FAIL(client != NULL, TDM_ERROR_INVALID_PARAMETER); private_client = (tdm_private_client*)client; - return _tdm_client_dispatch_timeout(private_client, ms_timeout); + pthread_mutex_lock(&private_client->lock); + + if (CHECK_WL_PROTOCOL_ERROR(private_client)) { + pthread_mutex_unlock(&private_client->lock); + return TDM_ERROR_PROTOCOL_ERROR; + } + + if (private_client->enable_ttrace) + TDM_TRACE_ASYNC_BEGIN((int)private_client->stamp, "TDM_Client_Events_Timeout:%u", (unsigned int)private_client->stamp); + + ret = _tdm_client_dispatch_timeout(private_client, ms_timeout); + + if (private_client->enable_ttrace) + TDM_TRACE_ASYNC_END((int)private_client->stamp, "TDM_Client_Events_Timeout:%u", (unsigned int)private_client->stamp); + + if (CHECK_WL_PROTOCOL_ERROR(private_client)) { + pthread_mutex_unlock(&private_client->lock); + return TDM_ERROR_PROTOCOL_ERROR; + } + + pthread_mutex_unlock(&private_client->lock); + + return ret; } typedef struct _tdm_client_vblank_temp {