p2p: Add new_client method in p2p struct
authorOlivier Guiter <olivier.guiter@linux.intel.com>
Mon, 2 Sep 2013 10:32:15 +0000 (12:32 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 2 Sep 2013 13:09:14 +0000 (15:09 +0200)
p2p registrees will be notified through this method of a new client
connection.

plugins/p2p.c
plugins/p2p.h

index bf6ee8b..64935d0 100644 (file)
@@ -129,7 +129,6 @@ static gboolean p2p_client_event(GIOChannel *channel, GIOCondition condition,
                                                        gpointer user_data)
 {
        struct p2p_data *client_data = user_data;
-       bool more;
 
        DBG("condition 0x%x", condition);
 
@@ -171,13 +170,15 @@ static gboolean p2p_client_event(GIOChannel *channel, GIOCondition condition,
                return FALSE;
        }
 
-       more = client_data->driver->read(client_data->fd,
+       if (client_data->driver->new_client)
+               return true;
+
+       return client_data->driver->read(client_data->fd,
                                                client_data->adapter_idx,
                                                client_data->target_idx,
                                                client_data->cb,
                                                client_data->driver->user_data);
 
-       return more;
 }
 
 static void free_client_data(gpointer data)
@@ -275,6 +276,12 @@ static gboolean p2p_listener_event(GIOChannel *channel, GIOCondition condition,
        client_channel = g_io_channel_unix_new(client_fd);
        g_io_channel_set_close_on_unref(client_channel, TRUE);
 
+       /* This would enable passthru active */
+       if (server_data->driver->new_client)
+               server_data->driver->new_client(
+                               client_data->driver->service_name, client_fd,
+                               server_data->driver->user_data);
+
        client_data->watch = g_io_add_watch(client_channel,
                                G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR,
                                p2p_client_event,
index 9616cd6..fbcbbf0 100644 (file)
@@ -45,6 +45,7 @@ struct near_p2p_driver {
                                                near_device_io_cb cb,
                                                gpointer data);
        void (*close)(int client_fd, int err, gpointer data);
+       bool (*new_client)(char *service_name, int client_fd, gpointer data);
 };
 
 int npp_init(void);