]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Flush task queues explicitly, not implicitly if task returns ALREADY_DONE
authorMartin Willi <martin@revosec.ch>
Mon, 21 May 2012 12:17:09 +0000 (14:17 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 21 May 2012 12:17:09 +0000 (14:17 +0200)
src/libcharon/sa/ikev1/task_manager_v1.c
src/libcharon/sa/ikev1/tasks/aggressive_mode.c
src/libcharon/sa/ikev1/tasks/main_mode.c
src/libcharon/sa/ikev1/tasks/quick_delete.c
src/libcharon/sa/ikev1/tasks/quick_mode.c
src/libcharon/sa/task.h

index 38fe8ec0acbeb9a50d9ee75b399e6c7b0606d7c8..b52a7e92326dd7eca7442b3c3793886008353936 100644 (file)
@@ -346,7 +346,7 @@ METHOD(task_manager_t, initiate, status_t,
        host_t *me, *other;
        status_t status;
        exchange_type_t exchange = EXCHANGE_TYPE_UNDEFINED;
-       bool new_mid = FALSE, expect_response = FALSE, flushed = FALSE, keep = FALSE;
+       bool new_mid = FALSE, expect_response = FALSE, cancelled = FALSE, keep = FALSE;
 
        if (this->initiating.type != EXCHANGE_TYPE_UNDEFINED &&
                this->initiating.type != INFORMATIONAL_V1)
@@ -511,8 +511,7 @@ METHOD(task_manager_t, initiate, status_t,
                                /* processed, but task needs another exchange */
                                continue;
                        case ALREADY_DONE:
-                               flush_queue(this, TASK_QUEUE_ACTIVE);
-                               flushed = TRUE;
+                               cancelled = TRUE;
                                break;
                        case FAILED:
                        default:
@@ -537,7 +536,7 @@ METHOD(task_manager_t, initiate, status_t,
        {       /* tasks completed, no exchange active anymore */
                this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
        }
-       if (flushed)
+       if (cancelled)
        {
                message->destroy(message);
                return initiate(this);
@@ -600,7 +599,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
        task_t *task;
        message_t *message;
        host_t *me, *other;
-       bool delete = FALSE, flushed = FALSE, expect_request = FALSE;
+       bool delete = FALSE, cancelled = FALSE, expect_request = FALSE;
        status_t status;
 
        me = request->get_destination(request);
@@ -638,8 +637,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
                                }
                                continue;
                        case ALREADY_DONE:
-                               flush_queue(this, TASK_QUEUE_PASSIVE);
-                               flushed = TRUE;
+                               cancelled = TRUE;
                                break;
                        case FAILED:
                        default:
@@ -656,7 +654,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
 
        DESTROY_IF(this->responding.packet);
        this->responding.packet = NULL;
-       if (flushed)
+       if (cancelled)
        {
                message->destroy(message);
                return initiate(this);
@@ -887,7 +885,6 @@ static status_t process_request(private_task_manager_t *this,
                                continue;
                        case ALREADY_DONE:
                                send_response = FALSE;
-                               flush_queue(this, TASK_QUEUE_PASSIVE);
                                break;
                        case FAILED:
                        default:
@@ -960,7 +957,6 @@ static status_t process_response(private_task_manager_t *this,
                                /* processed, but task needs another exchange */
                                continue;
                        case ALREADY_DONE:
-                               flush_queue(this, TASK_QUEUE_ACTIVE);
                                break;
                        case FAILED:
                        default:
index 9621e7099079d900b6a7e164ee69d84cf8510a2e..4c581cdb6dc4981ef16afe6e0f514beb4eb9bb81 100644 (file)
@@ -174,6 +174,8 @@ static status_t send_notify(private_aggressive_mode_t *this, notify_type_t type)
        this->ike_sa->queue_task(this->ike_sa,
                                                (task_t*)informational_create(this->ike_sa, notify));
        /* cancel all active/passive tasks in favour of informational */
+       this->ike_sa->flush_queue(this->ike_sa,
+                                       this->initiator ? TASK_QUEUE_ACTIVE : TASK_QUEUE_PASSIVE);
        return ALREADY_DONE;
 }
 
@@ -185,6 +187,8 @@ static status_t send_delete(private_aggressive_mode_t *this)
        this->ike_sa->queue_task(this->ike_sa,
                                                (task_t*)isakmp_delete_create(this->ike_sa, TRUE));
        /* cancel all active tasks in favour of informational */
+       this->ike_sa->flush_queue(this->ike_sa,
+                                       this->initiator ? TASK_QUEUE_ACTIVE : TASK_QUEUE_PASSIVE);
        return ALREADY_DONE;
 }
 
index 53c38748e3866cd61242b54173c0143399d14526..ff78764da325ab65f246edeb6dd52d704d1faf45 100644 (file)
@@ -186,6 +186,8 @@ static status_t send_notify(private_main_mode_t *this, notify_type_t type)
        this->ike_sa->queue_task(this->ike_sa,
                                                (task_t*)informational_create(this->ike_sa, notify));
        /* cancel all active/passive tasks in favour of informational */
+       this->ike_sa->flush_queue(this->ike_sa,
+                                       this->initiator ? TASK_QUEUE_ACTIVE : TASK_QUEUE_PASSIVE);
        return ALREADY_DONE;
 }
 
@@ -197,6 +199,8 @@ static status_t send_delete(private_main_mode_t *this)
        this->ike_sa->queue_task(this->ike_sa,
                                                (task_t*)isakmp_delete_create(this->ike_sa, TRUE));
        /* cancel all active tasks in favour of informational */
+       this->ike_sa->flush_queue(this->ike_sa,
+                                       this->initiator ? TASK_QUEUE_ACTIVE : TASK_QUEUE_PASSIVE);
        return ALREADY_DONE;
 }
 
index 6e4194ee2eea43e7a6608963d1ef3d36ebc07732..db48bc58ece494bebcb6bdc053db81e3b2f0f8b8 100644 (file)
@@ -137,6 +137,7 @@ METHOD(task_t, build_i, status_t,
 
                return SUCCESS;
        }
+       this->ike_sa->flush_queue(this->ike_sa, TASK_QUEUE_ACTIVE);
        return ALREADY_DONE;
 }
 
index f98bfa2b61f593cdf07567871b6594efa2a1b913..7c843e85e6ef9635ffac936dd120531e63e2229c 100644 (file)
@@ -605,6 +605,8 @@ static status_t send_notify(private_quick_mode_t *this, notify_type_t type)
        this->ike_sa->queue_task(this->ike_sa,
                                                (task_t*)informational_create(this->ike_sa, notify));
        /* cancel all active/passive tasks in favour of informational */
+       this->ike_sa->flush_queue(this->ike_sa,
+                                       this->initiator ? TASK_QUEUE_ACTIVE : TASK_QUEUE_PASSIVE);
        return ALREADY_DONE;
 }
 
@@ -892,6 +894,7 @@ METHOD(task_t, process_r, status_t,
                        }
                        if (!install(this))
                        {
+                               this->ike_sa->flush_queue(this->ike_sa, TASK_QUEUE_PASSIVE);
                                this->ike_sa->queue_task(this->ike_sa,
                                        (task_t*)quick_delete_create(this->ike_sa,
                                                                this->proposal->get_protocol(this->proposal),
index 8bf9217be2009e71df04f6fea3449e812affb341..c37221a775e89670aeea4a473a3b1f28c4f61ad7 100644 (file)
@@ -131,7 +131,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
+        *                                              - ALREADY_DONE to cancel task processing
         *                                              - SUCCESS if task completed
         */
        status_t (*build) (task_t *this, message_t *message);
@@ -144,7 +144,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
+        *                                              - ALREADY_DONE to cancel task processing
         *                                              - SUCCESS if task completed
         */
        status_t (*process) (task_t *this, message_t *message);