summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-23 17:17:37 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-26 15:34:42 +0200
commitc116f52635c96548986b8e6f877ceaafec2a80bf (patch)
treee589f6e34896610cbff6b8afcce225be513f192b /src
parent45aa74c72e4a315403611ebff5415dc1e8a196ed (diff)
sd-ipv4{acl,ll}: don't make use of RefCnt objects
These objects are only useful when multiple threads are involved, as they operate with atomic operations. Given that our libraries are explicitly not thread-safe don't make use of RefCnt here, and make things a bit simpler.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/sd-ipv4acd.c20
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c1
2 files changed, 14 insertions, 7 deletions
diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c
index 7414f33adb..5f6e0f6c7f 100644
--- a/src/libsystemd-network/sd-ipv4acd.c
+++ b/src/libsystemd-network/sd-ipv4acd.c
@@ -33,7 +33,6 @@
#include "in-addr-util.h"
#include "list.h"
#include "random-util.h"
-#include "refcnt.h"
#include "siphash24.h"
#include "util.h"
@@ -78,7 +77,7 @@ typedef enum IPv4ACDState {
} IPv4ACDState;
struct sd_ipv4acd {
- RefCount n_ref;
+ unsigned n_ref;
IPv4ACDState state;
int ifindex;
@@ -98,14 +97,23 @@ struct sd_ipv4acd {
};
sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *ll) {
- if (ll)
- assert_se(REFCNT_INC(ll->n_ref) >= 2);
+ if (!ll)
+ return NULL;
+
+ assert_se(ll->n_ref >= 1);
+ ll->n_ref++;
return ll;
}
sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *ll) {
- if (!ll || REFCNT_DEC(ll->n_ref) > 0)
+ if (!ll)
+ return NULL;
+
+ assert_se(ll->n_ref >= 1);
+ ll->n_ref--;
+
+ if (ll->n_ref > 0)
return NULL;
ll->receive_message = sd_event_source_unref(ll->receive_message);
@@ -129,7 +137,7 @@ int sd_ipv4acd_new(sd_ipv4acd **ret) {
if (!ll)
return -ENOMEM;
- ll->n_ref = REFCNT_INIT;
+ ll->n_ref = 1;
ll->state = IPV4ACD_STATE_INIT;
ll->ifindex = -1;
ll->fd = -1;
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index f9779a8601..ea6d9d22f1 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -31,7 +31,6 @@
#include "in-addr-util.h"
#include "list.h"
#include "random-util.h"
-#include "refcnt.h"
#include "siphash24.h"
#include "sparse-endian.h"
#include "util.h"