mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-12 21:44:12 +08:00
gobex: Add per-client tracking to test-server
This commit is contained in:
parent
0a262129e4
commit
0b362843b0
@ -29,10 +29,10 @@
|
||||
|
||||
#include <gobex/gobex.h>
|
||||
|
||||
static GObex *obex = NULL;
|
||||
|
||||
static GMainLoop *main_loop = NULL;
|
||||
|
||||
static GSList *clients = NULL;
|
||||
|
||||
static void sig_term(int sig)
|
||||
{
|
||||
g_print("Terminating due to signal %d\n", sig);
|
||||
@ -43,12 +43,19 @@ static GOptionEntry options[] = {
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static void disconn_func(GObex *obex, GError *err, gpointer user_data)
|
||||
{
|
||||
clients = g_slist_remove(clients, obex);
|
||||
g_obex_unref(obex);
|
||||
}
|
||||
|
||||
static gboolean unix_accept(GIOChannel *chan, GIOCondition cond, gpointer data)
|
||||
{
|
||||
struct sockaddr_un addr;
|
||||
socklen_t addrlen;
|
||||
int sk, cli_sk;
|
||||
GIOChannel *io;
|
||||
GObex *obex;
|
||||
|
||||
if (cond & G_IO_NVAL)
|
||||
return FALSE;
|
||||
@ -76,6 +83,8 @@ static gboolean unix_accept(GIOChannel *chan, GIOCondition cond, gpointer data)
|
||||
g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL);
|
||||
|
||||
obex = g_obex_new(io, G_OBEX_TRANSPORT_STREAM, -1, -1);
|
||||
g_obex_set_disconnect_function(obex, disconn_func, NULL);
|
||||
clients = g_slist_append(clients, obex);;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -153,6 +162,7 @@ int main(int argc, char *argv[])
|
||||
g_main_loop_run(main_loop);
|
||||
|
||||
g_io_channel_unref(io);
|
||||
g_slist_free_full(clients, (GDestroyNotify) g_obex_unref);
|
||||
g_option_context_free(context);
|
||||
g_main_loop_unref(main_loop);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user