summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-server.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-26 21:05:53 +0200
committerLennart Poettering <lennart@poettering.net>2015-08-26 21:05:53 +0200
commit3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8 (patch)
tree0bacacbb979dba4f5095391d65360ff709a3657d /src/libsystemd-network/sd-dhcp-server.c
parent57de20dd8fcf156ce8071810f0be8a22786bb1c0 (diff)
dhcp: stop using refcnt.h
No need to invole atomic ops in single-threaded APIs, let's simplify this.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-server.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index 730d95e2c0..e2cd52ac0c 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -73,8 +73,12 @@ bool sd_dhcp_server_is_running(sd_dhcp_server *server) {
}
sd_dhcp_server *sd_dhcp_server_ref(sd_dhcp_server *server) {
- if (server)
- assert_se(REFCNT_INC(server->n_ref) >= 2);
+
+ if (!server)
+ return NULL;
+
+ assert(server->n_ref >= 1);
+ server->n_ref++;
return server;
}
@@ -127,7 +131,10 @@ sd_dhcp_server *sd_dhcp_server_unref(sd_dhcp_server *server) {
if (!server)
return NULL;
- if (REFCNT_DEC(server->n_ref) > 0)
+ assert(server->n_ref >= 1);
+ server->n_ref--;
+
+ if (server->n_ref > 0)
return NULL;
log_dhcp_server(server, "UNREF");
@@ -158,7 +165,7 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) {
if (!server)
return -ENOMEM;
- server->n_ref = REFCNT_INIT;
+ server->n_ref = 1;
server->fd_raw = -1;
server->fd = -1;
server->address = htobe32(INADDR_ANY);