Allow IKEv1 tasks to return ALREADY_DONE to flush all active or passive tasks

This commit is contained in:
Martin Willi
2012-03-20 17:31:18 +01:00
parent 0f61964ed7
commit 590ca1d482
2 changed files with 23 additions and 10 deletions
+21 -10
View File
@@ -371,10 +371,13 @@ METHOD(task_manager_t, initiate, status_t,
/* task completed, remove it */
this->active_tasks->remove_at(this->active_tasks, enumerator);
task->destroy(task);
break;
continue;
case NEED_MORE:
expect_response = TRUE;
/* processed, but task needs another exchange */
continue;
case ALREADY_DONE:
flush_queue(this, this->active_tasks);
break;
case FAILED:
default:
@@ -390,6 +393,7 @@ METHOD(task_manager_t, initiate, status_t,
flush(this);
return DESTROY_ME;
}
break;
}
enumerator->destroy(enumerator);
@@ -464,7 +468,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
{
task->destroy(task);
}
break;
continue;
case NEED_MORE:
/* processed, but task needs another exchange */
if (handle_collisions(this, task))
@@ -472,6 +476,9 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
this->passive_tasks->remove_at(this->passive_tasks,
enumerator);
}
continue;
case ALREADY_DONE:
flush_queue(this, this->passive_tasks);
break;
case FAILED:
default:
@@ -482,10 +489,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
delete = TRUE;
break;
}
if (delete)
{
break;
}
break;
}
enumerator->destroy(enumerator);
@@ -700,13 +704,15 @@ static status_t process_request(private_task_manager_t *this,
/* task completed, remove it */
this->passive_tasks->remove_at(this->passive_tasks, enumerator);
task->destroy(task);
break;
continue;
case NEED_MORE:
/* processed, but task needs at least another call to build() */
send_response = TRUE;
continue;
case ALREADY_DONE:
send_response = FALSE;
flush_queue(this, this->passive_tasks);
break;
case FAILED_SEND_ERROR:
send_notify_response(this, NULL, 0, chunk_empty, task);
case FAILED:
default:
charon->bus->ike_updown(charon->bus, this->ike_sa, FALSE);
@@ -718,6 +724,7 @@ static status_t process_request(private_task_manager_t *this,
task->destroy(task);
return DESTROY_ME;
}
break;
}
enumerator->destroy(enumerator);
@@ -765,9 +772,12 @@ static status_t process_response(private_task_manager_t *this,
/* task completed, remove it */
this->active_tasks->remove_at(this->active_tasks, enumerator);
task->destroy(task);
break;
continue;
case NEED_MORE:
/* processed, but task needs another exchange */
continue;
case ALREADY_DONE:
flush_queue(this, this->active_tasks);
break;
case FAILED:
default:
@@ -780,6 +790,7 @@ static status_t process_response(private_task_manager_t *this,
task->destroy(task);
return DESTROY_ME;
}
break;
}
enumerator->destroy(enumerator);
+2
View File
@@ -121,6 +121,7 @@ struct task_t {
* - FAILED if a critical error occurred
* - DESTROY_ME if IKE_SA has been properly deleted
* - NEED_MORE if another call to build/process needed
* - ALREADY_DONE to cancel all active or passive tasks
* - SUCCESS if task completed
*/
status_t (*build) (task_t *this, message_t *message);
@@ -133,6 +134,7 @@ struct task_t {
* - FAILED if a critical error occurred
* - DESTROY_ME if IKE_SA has been properly deleted
* - NEED_MORE if another call to build/process needed
* - ALREADY_DONE to cancel all active or passive tasks
* - SUCCESS if task completed
*/
status_t (*process) (task_t *this, message_t *message);