From: Hyongtaek Lim Date: Thu, 1 Dec 2016 09:33:18 +0000 (+0900) Subject: Re-wait at the spurious wakeup of g_cond_wait_until X-Git-Tag: accepted/tizen/common/20161220.191015~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F101511%2F2;p=platform%2Fcore%2Fapi%2Fplayer.git Re-wait at the spurious wakeup of g_cond_wait_until Change-Id: Idb14c155c6adf9da5b2a925b00ef165dc71b8c5a Signed-off-by: Hyongtaek Lim --- diff --git a/src/player.c b/src/player.c index 785b6d4..5f63afa 100644 --- a/src/player.c +++ b/src/player.c @@ -1389,6 +1389,20 @@ static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s * cb_in return NULL; } +static void _remove_all_ret_msg(callback_cb_info_s * cb_info) +{ + ret_msg_s *msg = cb_info->buff.retMsgHead; + ret_msg_s *prev = NULL; + while (msg) { + prev = msg; + msg = msg->next; + LOGI("Remove %s", prev->msg); + g_free(prev->msg); + prev->msg = NULL; + g_free(prev); + } +} + static void _notify_disconnected(callback_cb_info_s * cb_info) { int code = PLAYER_ERROR_SERVICE_DISCONNECTED; @@ -1550,6 +1564,7 @@ static void callback_destroy(callback_cb_info_s * cb_info) g_mutex_clear(&cb_info->seek_cb_mutex); g_free(cb_info->buff.recvMsg); + _remove_all_ret_msg(cb_info); if (cb_info->buff.part_of_msg) g_free(cb_info->buff.part_of_msg); g_free(cb_info); @@ -1588,28 +1603,28 @@ int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s * cb_inf g_mutex_lock(&cb_info->player_mutex); msg = _get_ret_msg(api, cb_info); - if (!buff->recved || !msg) { - if (!g_cond_wait_until(&cb_info->player_cond[api], &cb_info->player_mutex, end_time)) { - LOGW("api %d return msg does not received %dms", api, time_out); - g_mutex_unlock(&cb_info->player_mutex); - return PLAYER_ERROR_INVALID_OPERATION; + do { + if (!buff->recved || !msg) { + if (!g_cond_wait_until(&cb_info->player_cond[api], &cb_info->player_mutex, end_time)) { + LOGW("api %d return msg does not received %dms", api, time_out); + ret = PLAYER_ERROR_INVALID_OPERATION; + break; + } } - } - if (!msg) - msg = _get_ret_msg(api, cb_info); - if (msg) { - *ret_buf = msg->msg; - g_free(msg); - if (!player_msg_get(ret, *ret_buf)) - ret = PLAYER_ERROR_INVALID_OPERATION; - } else { - LOGE("api %d return msg is not exist", api); - ret = PLAYER_ERROR_INVALID_OPERATION; - } - buff->recved--; + if (!msg) + msg = _get_ret_msg(api, cb_info); + if (msg) { + *ret_buf = msg->msg; + buff->recved--; + g_free(msg); + if (!player_msg_get(ret, *ret_buf)) + ret = PLAYER_ERROR_INVALID_OPERATION; + } else { + LOGE("api %d is the spurious wakeup", api); + } + } while (!msg); g_mutex_unlock(&cb_info->player_mutex); - return ret; }