if (job->tag) {
context = g_main_context_get_thread_default();
source = g_main_context_find_source_by_id(context, job->tag);
- if (source && !g_source_is_destroyed(source))
+ _W("GMainContext(%p), GSource(%p)", context, source);
+ if (source && !g_source_is_destroyed(source)) {
+ _W("Destroy GSource(%p)", source);
g_source_destroy(source);
+ }
}
free(job->name);
{
int fd = g_io_channel_unix_get_fd(io);
struct job_s *job = (struct job_s *)data;
- aul_worker_io_job_cb callback = (aul_worker_io_job_cb)job->callback;
+ aul_worker_io_job_cb callback;
+ GSource *source;
+
+ source = g_main_current_source();
+ if (!source || g_source_is_destroyed(source)) {
+ _E("[__JOB__] GSource(%p) is destroyed", source);
+ return G_SOURCE_REMOVE;
+ }
+
+ if (condition & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
+ _E("[__JOB__] name(%s), condition(%d)", job->name, condition);
+ job->tag = 0;
+ return G_SOURCE_REMOVE;
+ }
+ callback = (aul_worker_io_job_cb)job->callback;
if (callback(fd, job->user_data))
return G_SOURCE_CONTINUE;
int aul_worker_add_io_job(aul_worker_h handle, const char *job_name,
int fd, aul_worker_io_job_cb callback, void *user_data)
{
- GIOCondition cond = G_IO_IN | G_IO_PRI | G_IO_HUP | G_IO_ERR;
+ GIOCondition cond = G_IO_IN | G_IO_PRI | G_IO_HUP | G_IO_ERR |
+ G_IO_NVAL;
struct aul_worker_s *worker = (struct aul_worker_s *)handle;
struct job_s *job;
GIOChannel *channel;
g_mutex_lock(&worker->mutex);
worker->jobs = g_list_append(worker->jobs, job);
job->tag = g_source_attach(source, worker->context);
+ _W("GMainContext(%p), GSource(%p)", worker->context, source);
g_mutex_unlock(&worker->mutex);
g_source_unref(source);
return NULL;
}
+ _W("GMainContext(%p)", worker->context);
g_source_set_callback(source, (GSourceFunc)__notify_cb, worker, NULL);
g_source_set_priority(source, G_PRIORITY_HIGH);
g_source_attach(source, worker->context);