Commit 00686953 authored by Slava Monich's avatar Slava Monich

Merge pull request #8 from monich/null-task-id

[mms_dispatcher] Beware of tasks with NULL ids
parents e5d079c0 1ef49f89
...@@ -532,11 +532,11 @@ mms_dispatcher_cancel( ...@@ -532,11 +532,11 @@ mms_dispatcher_cancel(
GList* entry; GList* entry;
for (entry = disp->tasks->head; entry; entry = entry->next) { for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data; MMSTask* task = entry->data;
if (!id || !strcmp(task->id, id)) { if (mms_task_match_id(task, id)) {
mms_task_cancel(task); mms_task_cancel(task);
} }
} }
if (disp->active_task && (!id || !strcmp(disp->active_task->id, id))) { if (mms_task_match_id(disp->active_task, id)) {
mms_task_cancel(disp->active_task); mms_task_cancel(disp->active_task);
} }
} }
......
...@@ -298,6 +298,25 @@ mms_task_queue_and_unref( ...@@ -298,6 +298,25 @@ mms_task_queue_and_unref(
return ok; return ok;
} }
gboolean
mms_task_match_id(
MMSTask* task,
const char* id)
{
if (!task) {
/* No task - no match */
return FALSE;
} else if (!id || !id[0]) {
/* A wildcard matching any task */
return TRUE;
} else if (!task->id || !task->id[0]) {
/* Only wildcard will match that */
return FALSE;
} else {
return !strcmp(task->id, id);
}
}
/** /**
* Generates dummy task id if necessary. * Generates dummy task id if necessary.
*/ */
......
...@@ -144,6 +144,11 @@ mms_task_queue_and_unref( ...@@ -144,6 +144,11 @@ mms_task_queue_and_unref(
MMSTaskDelegate* delegate, MMSTaskDelegate* delegate,
MMSTask* task); MMSTask* task);
gboolean
mms_task_match_id(
MMSTask* task,
const char* id);
const char* const char*
mms_task_make_id( mms_task_make_id(
MMSTask* task); MMSTask* task);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment