#include <glib.h>
#include <glib-unix.h>
+#ifndef WORKER_TEST_ONLY
+#define WORKER_TEST_ONLY
+#endif
+
#ifdef WORKER_TEST_ONLY
#include <glib.h>
#include <sys/syscall.h>
syscall(SYS_gettid), __func__, ##x)
#define TPL_ERR(f, x...) tpl_log_e("[TPL_ERROR]", f, ##x)
-#define TPL_DEBUG_M(f, x...) tpl_log_d("[MAIN]", f, ##x)
-#define TPL_DEBUG_T(f, x...) tpl_log_t("[THREAD]", f, ##x)
-
+#define TPL_DEBUG(f, x...) \
+ ((int)getpid() == (int)syscall(SYS_gettid)) ? tpl_log_d("[MAIN]", f, ##x) : tpl_log_t("[THREAD]", f, ##x)
typedef struct _twe_thread twe_thread;
typedef struct _twe_thread_context twe_thread_context;
#else
twe_thread_context* context = user_data;
tdm_error tdm_err;
+ TPL_DEBUG("tdm_dispatch| tdm_client(%p)", context->tdm_client);
tdm_err = tdm_client_handle_events(context->tdm_client);
if (tdm_err) {
- TPL_ERR("TDM_ERROR:%d context:%p, tdm_cleint:%p\n", context, context->tdm_client);
+ TPL_ERR("TDM_ERROR:%d context:%p, tdm_cleint:%p\n", tdm_err, context, context->tdm_client);
return G_SOURCE_REMOVE;
}
{
twe_thread_context* context = user_data;
+ TPL_DEBUG("tdm_destroy| tdm_gsource(%p) tdm_client(%p)",
+ context->tdm_gsource, context->tdm_client);
g_source_destroy(context->tdm_gsource);
g_source_unref(context->tdm_gsource);
context->tdm_gsource = NULL;
_twe_ctx,
_twe_thread_tdm_source_destroy);
g_source_attach(_twe_ctx->tdm_gsource, g_main_loop_get_context(_twe_ctx->twe_loop));
+ TPL_DEBUG("tdm g_source(%p) attached to twe_loop(%p)",
+ _twe_ctx->tdm_gsource, _twe_ctx->twe_loop);
}
}
thread->ctx = _twe_ctx;
_twe_ctx->ref_cnt++;
+ TPL_DEBUG("_twe_ctx(%p) twe_thread(%p)", _twe_ctx, thread);
return thread;
}
thread->ctx = NULL;
}
+ TPL_DEBUG("twe_thread(%p)", thread);
+
thread->ctx = NULL;
free(thread);
}
{
twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source;
+ TPL_DEBUG("prepare| gsource(%p) wl_display(%p)", source, wl_source->disp);
while (wl_display_prepare_read_queue(wl_source->disp, wl_source->ev_queue) != 0) {
wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue);
}
twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source;
if (wl_source->gfd.revents) {
+ TPL_DEBUG("read_events| gsource(%p) wl_display(%p)",
+ source, wl_source->disp);
wl_display_read_events(wl_source->disp);
return TRUE;
} else {
+ TPL_DEBUG("cancel_read| gsource(%p) wl_display(%p)",
+ source, wl_source->disp);
wl_display_cancel_read(wl_source->disp);
}
{
twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source;
- if (wl_source->gfd.revents & G_IO_IN)
+ if (wl_source->gfd.revents & G_IO_IN) {
+ TPL_DEBUG("dispatch| gsource(%p) wl_display(%p)",
+ source, wl_source->disp);
wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue);
+ }
wl_display_flush(wl_source->disp);
wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue);
wl_event_queue_destroy(wl_source->ev_queue);
+ TPL_DEBUG("finalize| wl_event_queue(%p)",
+ wl_source->ev_queue);
return;
}
wl_proxy_set_queue(wl_tbm, ev_queue);
+ TPL_DEBUG("wl_tbm_client init| wl_tbm_client(%p)", wl_tbm_client);
return wl_tbm_client;
}
wl_proxy_set_queue(wl_tbm, NULL);
}
+ TPL_DEBUG("wl_tbm_client deinit| wl_tbm_client(%p)", wl_tbm_client);
wayland_tbm_client_deinit(wl_tbm_client);
}
g_source_add_poll(&source->gsource, &source->gfd);
g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
g_source_unref(&source->gsource);
+
+ TPL_DEBUG("add| gsource(%p) ev_queue(%p) wl_display(%p)",
+ source, source->ev_queue, display);
}
void
g_source_remove_poll(&source->gsource, &source->gfd);
g_source_destroy(&source->gsource);
g_source_unref(&source->gsource);
+
+ TPL_DEBUG("del| gsource(%p) wl_display(%p)", source, display);
}
static gboolean
ssize_t s;
uint64_t u;
+ TPL_DEBUG("finalize| gsource(%p) read event_fd(%d)",
+ wl_surf_source, wl_surf_source->event_fd);
s = read(wl_surf_source->event_fd, &u, sizeof(uint64_t));
if (s != sizeof(uint64_t))
TPL_ERR("Failed to read from event_fd(%d)\n",
g_source_remove_unix_fd(source, wl_surf_source->tag);
+ TPL_DEBUG("gsource(%p) event_fd(%d)",
+ source, wl_surf_source->event_fd);
close(wl_surf_source->event_fd);
return;
g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
g_source_unref(&source->gsource);
+ TPL_DEBUG("gsource(%p) wl_surface(%p) event_fd(%d)",
+ source, surface, source->event_fd);
return source->event_fd;
}
g_source_destroy(&source->gsource);
g_source_unref(&source->gsource);
+
+ TPL_DEBUG("gsource(%p) wl_surface(%p)",
+ source, surface);
}
#ifdef WORKER_TEST_ONLY
const char *interface,
uint32_t version)
{
- TPL_DEBUG_M("reg_global: %s_v_%d\n", interface, version);
+ TPL_DEBUG("reg_global: %s_v_%d\n", interface, version);
}
twe_thread *t_thread = NULL;
- TPL_DEBUG_M("[[GLIB_WL_THREAD_TEST]]");
+ TPL_DEBUG("[[GLIB_WL_THREAD_TEST]]");
/*Create the twe_thread*/
t_thread = twe_thread_create();
if (count == 3) {
TPL_DEBUG_M("#### PRE_DEL");
twe_thread_del_wl_display(t_thread, display);
- TPL_DEBUG_M("#### DEL");
+ TPL_DEBUG("#### DEL");
}
}