gdhcp: Remove dead assignment
[platform/upstream/connman.git] / gdhcp / server.c
index ab6ed27..a342985 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  DHCP Server library with GLib integration
  *
- *  Copyright (C) 2009-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2009-2012  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -49,7 +49,7 @@
 #define OFFER_TIME (5*60)
 
 struct _GDHCPServer {
-       gint ref_count;
+       int ref_count;
        GDHCPType type;
        gboolean started;
        int ifindex;
@@ -317,7 +317,7 @@ static uint32_t get_interface_address(int index)
        struct sockaddr_in *server_ip;
        uint32_t ret = 0;
 
-       sk = socket(PF_INET, SOCK_DGRAM, 0);
+       sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
        if (sk < 0) {
                perror("Open socket error");
                return 0;
@@ -754,7 +754,7 @@ int g_dhcp_server_start(GDHCPServer *dhcp_server)
                return 0;
 
        listener_sockfd = dhcp_l3_socket(SERVER_PORT,
-                               dhcp_server->interface);
+                                       dhcp_server->interface, AF_INET);
        if (listener_sockfd < 0)
                return -EIO;
 
@@ -769,8 +769,8 @@ int g_dhcp_server_start(GDHCPServer *dhcp_server)
 
        g_io_channel_set_close_on_unref(listener_channel, TRUE);
        dhcp_server->listener_watch =
-                       g_io_add_watch_full(listener_channel,
-                                               G_PRIORITY_HIGH, G_IO_IN,
+                       g_io_add_watch_full(listener_channel, G_PRIORITY_HIGH,
+                               G_IO_IN | G_IO_NVAL | G_IO_ERR | G_IO_HUP,
                                                listener_event, dhcp_server,
                                                                NULL);
        g_io_channel_unref(dhcp_server->listener_channel);
@@ -821,7 +821,7 @@ GDHCPServer *g_dhcp_server_ref(GDHCPServer *dhcp_server)
        if (dhcp_server == NULL)
                return NULL;
 
-       g_atomic_int_inc(&dhcp_server->ref_count);
+       __sync_fetch_and_add(&dhcp_server->ref_count, 1);
 
        return dhcp_server;
 }
@@ -846,7 +846,7 @@ void g_dhcp_server_unref(GDHCPServer *dhcp_server)
        if (dhcp_server == NULL)
                return;
 
-       if (g_atomic_int_dec_and_test(&dhcp_server->ref_count) == FALSE)
+       if (__sync_fetch_and_sub(&dhcp_server->ref_count, 1) != 1)
                return;
 
        g_dhcp_server_stop(dhcp_server);