From 55facbbc2f31356508b55d22da01690e6ffa9725 Mon Sep 17 00:00:00 2001 From: Olivier Guiter Date: Mon, 2 Sep 2013 12:32:15 +0200 Subject: [PATCH] p2p: Add new_client method in p2p struct p2p registrees will be notified through this method of a new client connection. --- plugins/p2p.c | 13 ++++++++++--- plugins/p2p.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/p2p.c b/plugins/p2p.c index bf6ee8b..64935d0 100644 --- a/plugins/p2p.c +++ b/plugins/p2p.c @@ -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, diff --git a/plugins/p2p.h b/plugins/p2p.h index 9616cd6..fbcbbf0 100644 --- a/plugins/p2p.h +++ b/plugins/p2p.h @@ -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); -- 2.7.4