implemented proper refcounting using atomic operations
This commit is contained in:
@@ -63,7 +63,7 @@ struct private_connection_t {
|
||||
/**
|
||||
* Number of references hold by others to this connection
|
||||
*/
|
||||
u_int refcount;
|
||||
refcount_t refcount;
|
||||
|
||||
/**
|
||||
* Name of the connection
|
||||
@@ -326,7 +326,7 @@ static u_int32_t get_hard_lifetime(private_connection_t *this)
|
||||
*/
|
||||
static void get_ref(private_connection_t *this)
|
||||
{
|
||||
this->refcount++;
|
||||
ref_get(&this->refcount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,7 +334,7 @@ static void get_ref(private_connection_t *this)
|
||||
*/
|
||||
static void destroy(private_connection_t *this)
|
||||
{
|
||||
if (--this->refcount == 0)
|
||||
if (ref_put(&this->refcount))
|
||||
{
|
||||
proposal_t *proposal;
|
||||
|
||||
|
||||
@@ -259,6 +259,9 @@ struct connection_t {
|
||||
*
|
||||
* Get a new reference to this connection by increasing
|
||||
* it's internal reference counter.
|
||||
* Do not call get_ref or any other function until you
|
||||
* already have a reference. Otherwise the object may get
|
||||
* destroyed while calling get_ref(),
|
||||
*
|
||||
* @param this calling object
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ struct private_policy_t {
|
||||
/**
|
||||
* Number of references hold by others to this policy
|
||||
*/
|
||||
u_int refcount;
|
||||
refcount_t refcount;
|
||||
|
||||
/**
|
||||
* Name of the policy, used to query it
|
||||
@@ -377,7 +377,7 @@ static u_int32_t get_hard_lifetime(private_policy_t *this)
|
||||
*/
|
||||
static void get_ref(private_policy_t *this)
|
||||
{
|
||||
this->refcount++;
|
||||
ref_get(&this->refcount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,7 +385,7 @@ static void get_ref(private_policy_t *this)
|
||||
*/
|
||||
static void destroy(private_policy_t *this)
|
||||
{
|
||||
if (--this->refcount == 0)
|
||||
if (ref_put(&this->refcount))
|
||||
{
|
||||
proposal_t *proposal;
|
||||
traffic_selector_t *traffic_selector;
|
||||
|
||||
@@ -227,6 +227,9 @@ struct policy_t {
|
||||
*
|
||||
* Get a new reference to this policy by increasing
|
||||
* it's internal reference counter.
|
||||
* Do not call get_ref or any other function until you
|
||||
* already have a reference. Otherwise the object may get
|
||||
* destroyed while calling get_ref(),
|
||||
*
|
||||
* @param this calling object
|
||||
*/
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <execinfo.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "daemon.h"
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
+ proper delete messages
|
||||
- notifys on connection setup failure
|
||||
+ create child sa message/rekeying
|
||||
/ IKE_SA rekeying
|
||||
- handle all simultaneous rekeying/delete/create cases
|
||||
|
||||
- implement a mechanism against thread exhaustion
|
||||
when a blocked IKE_SA receives a lot of messages
|
||||
|
||||
Reference in New Issue
Block a user