handover: Fix to allow two handover requests
authorOlivier Guiter <olivier.guiter@linux.intel.com>
Mon, 22 Oct 2012 13:52:57 +0000 (15:52 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 24 Oct 2012 15:55:04 +0000 (17:55 +0200)
Test case 7 verifies that the remote handover server does not close the data
link connection after the first handover request message.

plugins/handover.c
plugins/p2p.c

index 10f7be6..b4dd148 100644 (file)
@@ -149,8 +149,6 @@ static int handover_ndef_parse(int client_fd, struct hr_ndef *ndef)
 
                near_info("Send Hs frame");
                err = send(client_fd, msg->data, msg->length, MSG_DONTWAIT);
-               if (err >= 0)
-                       err = 0;
 
                g_free(msg->data);
                g_free(msg);
@@ -188,6 +186,7 @@ static near_bool_t handover_read_cfg_records(int client_fd,
        struct hr_ndef *ndef;
        int bytes_recv;
        int ndef_size;
+       int err;
 
        ndef = g_hash_table_lookup(hr_ndef_hash, GINT_TO_POINTER(client_fd));
        if (ndef == NULL) {
@@ -248,7 +247,13 @@ static near_bool_t handover_read_cfg_records(int client_fd,
 
        if (ndef->extra_ndef_count == 0) {
                /* All the bytes are read so now, parse the frame */
-               handover_ndef_parse(client_fd, ndef);
+               err = handover_ndef_parse(client_fd, ndef);
+               if (err > 0) {
+                       /* clean memory */
+                       handover_close(client_fd, 0);
+                       return TRUE;
+               }
+
                return FALSE;
        }
 
index a7236ea..fa1930f 100644 (file)
@@ -91,12 +91,6 @@ static gboolean p2p_client_event(GIOChannel *channel, GIOCondition condition,
                                                client_data->target_idx,
                                                client_data->cb);
 
-       if (more == FALSE) {
-               if (client_data->driver->close != NULL)
-                       client_data->driver->close(client_data->fd, 0);
-               close(client_data->fd);
-       }
-
        return more;
 }