Avoid recursive loop if no socket implementations are loaded.
authorTobias Brunner <tobias@strongswan.org>
Thu, 14 Oct 2010 15:10:13 +0000 (17:10 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 14 Oct 2010 15:36:20 +0000 (17:36 +0200)
src/libcharon/network/receiver.c

index a7eb424..d8cebe1 100644 (file)
@@ -274,9 +274,17 @@ static job_requeue_t receive_packets(private_receiver_t *this)
 {
        packet_t *packet;
        message_t *message;
+       status_t status;
 
        /* read in a packet */
-       if (charon->socket->receive(charon->socket, &packet) != SUCCESS)
+       status = charon->socket->receive(charon->socket, &packet);
+       if (status == NOT_SUPPORTED)
+       {
+               /* the processor destroys this job  */
+               this->job = NULL;
+               return JOB_REQUEUE_NONE;
+       }
+       else if (status != SUCCESS)
        {
                DBG2(DBG_NET, "receiving from socket failed!");
                return JOB_REQUEUE_FAIR;
@@ -368,7 +376,10 @@ static job_requeue_t receive_packets(private_receiver_t *this)
 METHOD(receiver_t, destroy, void,
        private_receiver_t *this)
 {
-       this->job->cancel(this->job);
+       if (this->job)
+       {
+               this->job->cancel(this->job);
+       }
        this->rng->destroy(this->rng);
        this->hasher->destroy(this->hasher);
        free(this);