int ref_cnt;
twe_tdm_source *tdm_source;
+ twe_del_source *tdm_del_source;
GMutex thread_mutex;
GCond thread_cond;
gpointer tag;
tdm_client *tdm_client;
int tdm_fd;
- twe_del_source *tdm_del_source;
};
struct _twe_wl_disp_source {
return;
}
+ _twe_ctx->tdm_source = NULL;
+
g_source_remove_unix_fd(&tdm_source->gsource, tdm_source->tag);
g_source_destroy(&tdm_source->gsource);
g_source_unref(&tdm_source->gsource);
if (_twe_ctx->tdm_source) {
twe_tdm_source *tdm_source = _twe_ctx->tdm_source;
- tdm_source->tdm_del_source = _twe_del_source_init(_twe_ctx, tdm_source);
- if (tdm_source->tdm_del_source)
- tdm_source->tdm_del_source->destroy_target_source_func
+ _twe_ctx->tdm_del_source = _twe_del_source_init(_twe_ctx, tdm_source);
+ if (_twe_ctx->tdm_del_source)
+ _twe_ctx->tdm_del_source->destroy_target_source_func
= _twe_thread_tdm_source_destroy;
}
thread->ctx->ref_cnt--;
if (thread->ctx->ref_cnt == 0) {
- if (_twe_ctx->tdm_source) {
- twe_del_source *tdm_del_source = _twe_ctx->tdm_source->tdm_del_source;
- _twe_ctx->tdm_source->tdm_del_source = NULL;
+ twe_del_source *tdm_del_source = _twe_ctx->tdm_del_source;
+ if (_twe_ctx->tdm_source) {
g_mutex_lock(&_twe_ctx->thread_mutex);
- _twe_thread_del_source_trigger(tdm_del_source);
+ if (tdm_del_source)
+ _twe_thread_del_source_trigger(tdm_del_source);
g_cond_wait(&_twe_ctx->thread_cond, &_twe_ctx->thread_mutex);
g_mutex_unlock(&_twe_ctx->thread_mutex);
+ }
- _twe_ctx->tdm_source = NULL;
-
+ if (tdm_del_source)
_twe_del_source_fini(tdm_del_source);
- }
+
+ _twe_ctx->tdm_del_source = NULL;
g_main_loop_quit(thread->ctx->twe_loop);
g_thread_join(thread->ctx->twe_thread);