if (!sender)
return;
+ SLOG(LOG_INFO, tts_tag(), ">>>>> Client connect. appid(%s)", sender);
free(sender);
}
static void __destroy_client_cb(rpc_port_stub_tts_context_h context, void *user_data)
{
- char *sender = NULL;
+ void* tag = NULL;
+ rpc_port_stub_tts_context_get_tag(context, &tag);
+
+ if (NULL != tag) {
+ SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS FINALIZE");
+ int uid = (intptr_t)tag;
+
+ if (0 != ttsd_server_finalize(uid)) {
+ return;
+ }
+
+ pthread_mutex_lock(&g_tidl_proxy_infos_mutex);
+ tts_tidl_proxy_info_s* info = __get_tidl_proxy_info_s(uid);
+ if (NULL == info) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to set notify callback");
+ pthread_mutex_unlock(&g_tidl_proxy_infos_mutex);
+ return;
+ }
+
+ rpc_port_tts_notify_cb_destroy(info->notify_cb_h);
+ info->notify_cb_h = NULL;
+
+ g_tidl_proxy_infos = g_list_remove(g_tidl_proxy_infos, info);
+ free(info);
+
+ SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+
+ pthread_mutex_unlock(&g_tidl_proxy_infos_mutex);
+ }
+ rpc_port_stub_tts_context_set_tag(context, NULL);
+ char *sender = NULL;
rpc_port_stub_tts_context_get_sender(context, &sender);
if (!sender)
return;
+ SLOG(LOG_INFO, tts_tag(), ">>>>> Client disconnect. appid(%s)", sender);
free(sender);
}
credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED;
}
- tts_tidl_proxy_info_s* info = (tts_tidl_proxy_info_s*)calloc(1, sizeof(tts_tidl_proxy_info_s));
+ intptr_t ptr_uid = uid;
+ rpc_port_stub_tts_context_set_tag(context, (void*)ptr_uid);
+
+ tts_tidl_proxy_info_s* info = __get_tidl_proxy_info_s(uid);
if (NULL == info) {
- SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to allocate memory for tidl proxy");
- return;
+ info = (tts_tidl_proxy_info_s*)calloc(1, sizeof(tts_tidl_proxy_info_s));
+ if (NULL == info) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to allocate memory for tidl proxy");
+ return;
+ }
+ } else {
+ rpc_port_tts_notify_cb_destroy(info->notify_cb_h);
+ info->notify_cb_h = NULL;
}
if (0 != rpc_port_tts_notify_cb_clone(callback, &info->notify_cb_h)) {
{
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS REGISTER CALLBACK synchronously uid(%d)", uid);
- tts_tidl_proxy_info_s* info = (tts_tidl_proxy_info_s*)calloc(1, sizeof(tts_tidl_proxy_info_s));
+ intptr_t ptr_uid = uid;
+ rpc_port_stub_tts_context_set_tag(context, (void*)ptr_uid);
+
+ tts_tidl_proxy_info_s* info = __get_tidl_proxy_info_s(uid);
if (NULL == info) {
- SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to allocate memory for tidl proxy");
- return TTSD_ERROR_OPERATION_FAILED;
+ info = (tts_tidl_proxy_info_s*)calloc(1, sizeof(tts_tidl_proxy_info_s));
+ if (NULL == info) {
+ SLOG(LOG_ERROR, tts_tag(), "[TIDL ERROR] Fail to allocate memory for tidl proxy");
+ return TTSD_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ rpc_port_tts_notify_cb_destroy(info->notify_cb_h);
+ info->notify_cb_h = NULL;
}
if (0 != rpc_port_tts_notify_cb_clone(callback, &info->notify_cb_h)) {
SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
pthread_mutex_unlock(&g_tidl_proxy_infos_mutex);
+
+ rpc_port_stub_tts_context_set_tag(context, NULL);
return TTSE_ERROR_NONE;
}