From c6e4778e9cbc61e77ef9d8721bc04343af11d7e9 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 13 Jan 2007 23:30:30 +0000 Subject: Turn it into a full SDP server library --- sdpd/server.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 sdpd/server.c (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c new file mode 100644 index 00000000..67622e60 --- /dev/null +++ b/sdpd/server.c @@ -0,0 +1,245 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2001-2002 Nokia Corporation + * Copyright (C) 2002-2003 Maxim Krasnyansky + * Copyright (C) 2002-2007 Marcel Holtmann + * Copyright (C) 2002-2003 Stephen Crane + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "glib-ectomy.h" +#include "logging.h" +#include "sdpd.h" + +static GIOChannel *l2cap_io, *unix_io; + +static int l2cap_sock, unix_sock; + +/* + * SDP server initialization on startup includes creating the + * l2cap and unix sockets over which discovery and registration clients + * access us respectively + */ +static int init_server(uint16_t mtu, int master, int public) +{ + struct l2cap_options opts; + struct sockaddr_l2 l2addr; + struct sockaddr_un unaddr; + socklen_t optlen; + + /* Register the public browse group root */ + register_public_browse_group(public); + + /* Register the SDP server's service record */ + register_server_service(public); + + /* Create L2CAP socket */ + l2cap_sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); + if (l2cap_sock < 0) { + error("opening L2CAP socket: %s", strerror(errno)); + return -1; + } + + memset(&l2addr, 0, sizeof(l2addr)); + l2addr.l2_family = AF_BLUETOOTH; + bacpy(&l2addr.l2_bdaddr, BDADDR_ANY); + l2addr.l2_psm = htobs(SDP_PSM); + + if (bind(l2cap_sock, (struct sockaddr *) &l2addr, sizeof(l2addr)) < 0) { + error("binding L2CAP socket: %s", strerror(errno)); + return -1; + } + + if (master) { + int opt = L2CAP_LM_MASTER; + if (setsockopt(l2cap_sock, SOL_L2CAP, L2CAP_LM, &opt, sizeof(opt)) < 0) { + error("setsockopt: %s", strerror(errno)); + return -1; + } + } + + if (mtu > 0) { + memset(&opts, 0, sizeof(opts)); + optlen = sizeof(opts); + + if (getsockopt(l2cap_sock, SOL_L2CAP, L2CAP_OPTIONS, &opts, &optlen) < 0) { + error("getsockopt: %s", strerror(errno)); + return -1; + } + + opts.imtu = mtu; + + if (setsockopt(l2cap_sock, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts)) < 0) { + error("setsockopt: %s", strerror(errno)); + return -1; + } + } + + listen(l2cap_sock, 5); + + /* Create local Unix socket */ + unix_sock = socket(PF_UNIX, SOCK_STREAM, 0); + if (unix_sock < 0) { + error("opening UNIX socket: %s", strerror(errno)); + return -1; + } + + memset(&unaddr, 0, sizeof(unaddr)); + unaddr.sun_family = AF_UNIX; + strcpy(unaddr.sun_path, SDP_UNIX_PATH); + + unlink(unaddr.sun_path); + + if (bind(unix_sock, (struct sockaddr *) &unaddr, sizeof(unaddr)) < 0) { + error("binding UNIX socket: %s", strerror(errno)); + return -1; + } + + listen(unix_sock, 5); + + chmod(SDP_UNIX_PATH, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + + return 0; +} + +static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer data) +{ + sdp_pdu_hdr_t hdr; + uint8_t *buf; + int sk, len, size; + + if (cond & (G_IO_HUP | G_IO_ERR)) { + g_io_channel_unref(chan); + return FALSE; + } + + sk = g_io_channel_unix_get_fd(chan); + + len = recv(sk, &hdr, sizeof(sdp_pdu_hdr_t), MSG_PEEK); + if (len <= 0) { + sdp_svcdb_collect_all(sk); + return FALSE; + } + + size = sizeof(sdp_pdu_hdr_t) + ntohs(hdr.plen); + buf = malloc(size); + if (!buf) + return TRUE; + + len = recv(sk, buf, size, 0); + if (len <= 0) { + sdp_svcdb_collect_all(sk); + return FALSE; + } + + handle_request(sk, buf, len); + + return TRUE; +} + +static gboolean io_accept_event(GIOChannel *chan, GIOCondition cond, gpointer data) +{ + GIOChannel *io; + int nsk; + + if (cond & (G_IO_HUP | G_IO_ERR)) { + g_io_channel_unref(chan); + return FALSE; + } + + if (data == &l2cap_sock) { + struct sockaddr_l2 addr; + socklen_t len = sizeof(addr); + + nsk = accept(l2cap_sock, (struct sockaddr *) &addr, &len); + } else if (data == &unix_sock) { + struct sockaddr_un addr; + socklen_t len = sizeof(addr); + + nsk = accept(unix_sock, (struct sockaddr *) &addr, &len); + } else + return FALSE; + + if (nsk < 0) { + error("Can't accept connection: %s", strerror(errno)); + return TRUE; + } + + io = g_io_channel_unix_new(nsk); + g_io_channel_set_close_on_unref(io, TRUE); + + g_io_add_watch(io, G_IO_IN, io_session_event, data); + + return TRUE; +} + +int start_sdp_server(uint16_t mtu, uint32_t flags) +{ + int master = flags & SDP_SERVER_MASTER; + int public = flags & SDP_SERVER_PUBLIC; + + info("Starting SDP server"); + + if (init_server(mtu, master, public) < 0) { + error("Server initialization failed"); + return -1; + } + + l2cap_io = g_io_channel_unix_new(l2cap_sock); + g_io_channel_set_close_on_unref(l2cap_io, TRUE); + + g_io_add_watch(l2cap_io, G_IO_IN, io_accept_event, &l2cap_sock); + + unix_io = g_io_channel_unix_new(unix_sock); + g_io_channel_set_close_on_unref(unix_io, TRUE); + + g_io_add_watch(unix_io, G_IO_IN, io_accept_event, &unix_sock); + + return 0; +} + +void stop_sdp_server(void) +{ + info("Stopping SDP server"); + + sdp_svcdb_reset(); + + g_io_channel_unref(unix_io); + + g_io_channel_unref(l2cap_io); +} -- cgit From fa70fc6dfb0912b116aabdd39436a8b0be55123e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 14 Jan 2007 00:33:09 +0000 Subject: Implement compat mode for the Unix socket access --- sdpd/server.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 67622e60..65d36996 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -55,7 +55,7 @@ static int l2cap_sock, unix_sock; * l2cap and unix sockets over which discovery and registration clients * access us respectively */ -static int init_server(uint16_t mtu, int master, int public) +static int init_server(uint16_t mtu, int master, int public, int compat) { struct l2cap_options opts; struct sockaddr_l2 l2addr; @@ -112,6 +112,11 @@ static int init_server(uint16_t mtu, int master, int public) listen(l2cap_sock, 5); + if (!compat) { + unix_sock = -1; + return 0; + } + /* Create local Unix socket */ unix_sock = socket(PF_UNIX, SOCK_STREAM, 0); if (unix_sock < 0) { @@ -210,12 +215,13 @@ static gboolean io_accept_event(GIOChannel *chan, GIOCondition cond, gpointer da int start_sdp_server(uint16_t mtu, uint32_t flags) { + int compat = flags & SDP_SERVER_COMPAT; int master = flags & SDP_SERVER_MASTER; int public = flags & SDP_SERVER_PUBLIC; info("Starting SDP server"); - if (init_server(mtu, master, public) < 0) { + if (init_server(mtu, master, public, compat) < 0) { error("Server initialization failed"); return -1; } @@ -225,10 +231,13 @@ int start_sdp_server(uint16_t mtu, uint32_t flags) g_io_add_watch(l2cap_io, G_IO_IN, io_accept_event, &l2cap_sock); - unix_io = g_io_channel_unix_new(unix_sock); - g_io_channel_set_close_on_unref(unix_io, TRUE); + if (compat) { + unix_io = g_io_channel_unix_new(unix_sock); + g_io_channel_set_close_on_unref(unix_io, TRUE); - g_io_add_watch(unix_io, G_IO_IN, io_accept_event, &unix_sock); + g_io_add_watch(unix_io, G_IO_IN, io_accept_event, &unix_sock); + } else + unix_io = NULL; return 0; } @@ -239,7 +248,8 @@ void stop_sdp_server(void) sdp_svcdb_reset(); - g_io_channel_unref(unix_io); + if (unix_io) + g_io_channel_unref(unix_io); g_io_channel_unref(l2cap_io); } -- cgit From 8cc5595d9091b484b9a4abe314c0f3ec055e0581 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 20 Jan 2007 05:26:15 +0000 Subject: Make it possible to support an embedded GLib --- sdpd/server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 65d36996..c5458aac 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -42,7 +42,8 @@ #include #include -#include "glib-ectomy.h" +#include + #include "logging.h" #include "sdpd.h" -- cgit From 7899df370a9395fe016f54a311e58487be04c66c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 20 Jan 2007 20:42:27 +0000 Subject: Fix memory leaks --- sdpd/server.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index c5458aac..4316746b 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -211,6 +211,8 @@ static gboolean io_accept_event(GIOChannel *chan, GIOCondition cond, gpointer da g_io_add_watch(io, G_IO_IN, io_session_event, data); + g_io_channel_unref(io); + return TRUE; } -- cgit From 5d3f7702c50861f7f7f5ebeb160ef0073a5470f5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 20 Jan 2007 21:09:28 +0000 Subject: Fix GIOChannel refcounting for io_session_event --- sdpd/server.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 4316746b..eeda8a86 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -149,10 +149,8 @@ static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer d uint8_t *buf; int sk, len, size; - if (cond & (G_IO_HUP | G_IO_ERR)) { - g_io_channel_unref(chan); + if (cond & (G_IO_HUP | G_IO_ERR)) return FALSE; - } sk = g_io_channel_unix_get_fd(chan); -- cgit From 84dc067ee69533534a9e79359f17ab337f2a37e1 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 21 Jan 2007 18:52:46 +0000 Subject: Only create watch if Unix socket can be created --- sdpd/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index eeda8a86..6e632237 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -232,7 +232,7 @@ int start_sdp_server(uint16_t mtu, uint32_t flags) g_io_add_watch(l2cap_io, G_IO_IN, io_accept_event, &l2cap_sock); - if (compat) { + if (compat && unix_sock > fileno(stderr)) { unix_io = g_io_channel_unix_new(unix_sock); g_io_channel_set_close_on_unref(unix_io, TRUE); -- cgit From f274c01bde0e88ee7aa86f0197ad59b125930ad4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 21 Jan 2007 18:57:15 +0000 Subject: Fix cleanup in case the SDP server startup fails --- sdpd/server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 6e632237..3f29bbef 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -47,7 +47,7 @@ #include "logging.h" #include "sdpd.h" -static GIOChannel *l2cap_io, *unix_io; +static GIOChannel *l2cap_io = NULL, *unix_io = NULL; static int l2cap_sock, unix_sock; @@ -237,8 +237,7 @@ int start_sdp_server(uint16_t mtu, uint32_t flags) g_io_channel_set_close_on_unref(unix_io, TRUE); g_io_add_watch(unix_io, G_IO_IN, io_accept_event, &unix_sock); - } else - unix_io = NULL; + } return 0; } @@ -252,5 +251,6 @@ void stop_sdp_server(void) if (unix_io) g_io_channel_unref(unix_io); - g_io_channel_unref(l2cap_io); + if (l2cap_io) + g_io_channel_unref(l2cap_io); } -- cgit From 559a9a2ef363a2d9e81581f5846c59b0209c3575 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 16 Feb 2007 20:18:37 +0000 Subject: Add missing flags to g_io_add_watch calls --- sdpd/server.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 3f29bbef..8f13a051 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -207,7 +207,8 @@ static gboolean io_accept_event(GIOChannel *chan, GIOCondition cond, gpointer da io = g_io_channel_unix_new(nsk); g_io_channel_set_close_on_unref(io, TRUE); - g_io_add_watch(io, G_IO_IN, io_session_event, data); + g_io_add_watch(io, G_IO_IN | G_IO_ERR | G_IO_HUP, io_session_event, + data); g_io_channel_unref(io); @@ -230,13 +231,15 @@ int start_sdp_server(uint16_t mtu, uint32_t flags) l2cap_io = g_io_channel_unix_new(l2cap_sock); g_io_channel_set_close_on_unref(l2cap_io, TRUE); - g_io_add_watch(l2cap_io, G_IO_IN, io_accept_event, &l2cap_sock); + g_io_add_watch(l2cap_io, G_IO_IN | G_IO_ERR | G_IO_HUP, + io_accept_event, &l2cap_sock); if (compat && unix_sock > fileno(stderr)) { unix_io = g_io_channel_unix_new(unix_sock); g_io_channel_set_close_on_unref(unix_io, TRUE); - g_io_add_watch(unix_io, G_IO_IN, io_accept_event, &unix_sock); + g_io_add_watch(unix_io, G_IO_IN | G_IO_ERR | G_IO_HUP, + io_accept_event, &unix_sock); } return 0; -- cgit From a36be2a103e95b04d5b348c83b41dc8c06439990 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 4 Apr 2007 07:30:14 +0000 Subject: Fix missing G_IO_NVAL handling --- sdpd/server.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 8f13a051..2abcc6bc 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -149,7 +149,7 @@ static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer d uint8_t *buf; int sk, len, size; - if (cond & (G_IO_HUP | G_IO_ERR)) + if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) return FALSE; sk = g_io_channel_unix_get_fd(chan); @@ -181,7 +181,7 @@ static gboolean io_accept_event(GIOChannel *chan, GIOCondition cond, gpointer da GIOChannel *io; int nsk; - if (cond & (G_IO_HUP | G_IO_ERR)) { + if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) { g_io_channel_unref(chan); return FALSE; } @@ -207,8 +207,8 @@ static gboolean io_accept_event(GIOChannel *chan, GIOCondition cond, gpointer da io = g_io_channel_unix_new(nsk); g_io_channel_set_close_on_unref(io, TRUE); - g_io_add_watch(io, G_IO_IN | G_IO_ERR | G_IO_HUP, io_session_event, - data); + g_io_add_watch(io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, + io_session_event, data); g_io_channel_unref(io); @@ -231,15 +231,15 @@ int start_sdp_server(uint16_t mtu, uint32_t flags) l2cap_io = g_io_channel_unix_new(l2cap_sock); g_io_channel_set_close_on_unref(l2cap_io, TRUE); - g_io_add_watch(l2cap_io, G_IO_IN | G_IO_ERR | G_IO_HUP, - io_accept_event, &l2cap_sock); + g_io_add_watch(l2cap_io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, + io_accept_event, &l2cap_sock); if (compat && unix_sock > fileno(stderr)) { unix_io = g_io_channel_unix_new(unix_sock); g_io_channel_set_close_on_unref(unix_io, TRUE); - g_io_add_watch(unix_io, G_IO_IN | G_IO_ERR | G_IO_HUP, - io_accept_event, &unix_sock); + g_io_add_watch(unix_io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, + io_accept_event, &unix_sock); } return 0; -- cgit From eefb64d927b48d2de2e100b1f7ee715bf86bbb57 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 25 Apr 2007 18:59:55 +0000 Subject: Add device ID support --- sdpd/server.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 2abcc6bc..fab17f00 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -215,7 +216,7 @@ static gboolean io_accept_event(GIOChannel *chan, GIOCondition cond, gpointer da return TRUE; } -int start_sdp_server(uint16_t mtu, uint32_t flags) +int start_sdp_server(uint16_t mtu, const char *did, uint32_t flags) { int compat = flags & SDP_SERVER_COMPAT; int master = flags & SDP_SERVER_MASTER; @@ -228,6 +229,21 @@ int start_sdp_server(uint16_t mtu, uint32_t flags) return -1; } + if (did && strlen(did) > 0) { + const char *ptr = did; + uint16_t vid = 0x0000, pid = 0x0000, ver = 0x0000; + + vid = (uint16_t) strtol(ptr, NULL, 16); + ptr = strchr(ptr, ':'); + if (ptr) { + pid = (uint16_t) strtol(ptr + 1, NULL, 16); + ptr = strchr(ptr + 1, ':'); + if (ptr) + ver = (uint16_t) strtol(ptr + 1, NULL, 16); + register_device_id(vid, pid, ver); + } + } + l2cap_io = g_io_channel_unix_new(l2cap_sock); g_io_channel_set_close_on_unref(l2cap_io, TRUE); -- cgit From 09e129d5ef90ad61775517e752b8b9918f1a7c3e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 22 May 2007 11:43:30 +0000 Subject: Minimize SDP root records and browse groups --- sdpd/server.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index fab17f00..2750dec2 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -57,7 +57,7 @@ static int l2cap_sock, unix_sock; * l2cap and unix sockets over which discovery and registration clients * access us respectively */ -static int init_server(uint16_t mtu, int master, int public, int compat) +static int init_server(uint16_t mtu, int master, int compat) { struct l2cap_options opts; struct sockaddr_l2 l2addr; @@ -65,10 +65,10 @@ static int init_server(uint16_t mtu, int master, int public, int compat) socklen_t optlen; /* Register the public browse group root */ - register_public_browse_group(public); + register_public_browse_group(); /* Register the SDP server's service record */ - register_server_service(public); + register_server_service(); /* Create L2CAP socket */ l2cap_sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); @@ -220,11 +220,10 @@ int start_sdp_server(uint16_t mtu, const char *did, uint32_t flags) { int compat = flags & SDP_SERVER_COMPAT; int master = flags & SDP_SERVER_MASTER; - int public = flags & SDP_SERVER_PUBLIC; info("Starting SDP server"); - if (init_server(mtu, master, public, compat) < 0) { + if (init_server(mtu, master, compat) < 0) { error("Server initialization failed"); return -1; } -- cgit From 7cc971c79cd88798c5c40f9cdf85532a7aeab8a9 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 23 May 2007 14:31:02 +0000 Subject: Set input and output MTU when requested --- sdpd/server.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index 2750dec2..baac03d0 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -104,6 +104,7 @@ static int init_server(uint16_t mtu, int master, int compat) return -1; } + opts.omtu = mtu; opts.imtu = mtu; if (setsockopt(l2cap_sock, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts)) < 0) { -- cgit From e823c15e43a6f924779e466d434c51157002d9ee Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 2 Feb 2008 03:37:05 +0000 Subject: Update copyright information --- sdpd/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index baac03d0..fcdbf49f 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -4,7 +4,7 @@ * * Copyright (C) 2001-2002 Nokia Corporation * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2002-2007 Marcel Holtmann + * Copyright (C) 2002-2008 Marcel Holtmann * Copyright (C) 2002-2003 Stephen Crane * * -- cgit From f65077489960f0dda7f02461de9cedc89ef347a5 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 23 Jun 2008 01:10:06 +0000 Subject: Fix collect for non-persistent service records --- sdpd/server.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sdpd/server.c') diff --git a/sdpd/server.c b/sdpd/server.c index fcdbf49f..1524d1c0 100644 --- a/sdpd/server.c +++ b/sdpd/server.c @@ -151,11 +151,16 @@ static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer d uint8_t *buf; int sk, len, size; - if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) + if (cond & G_IO_NVAL) return FALSE; sk = g_io_channel_unix_get_fd(chan); + if (cond & (G_IO_HUP | G_IO_ERR)) { + sdp_svcdb_collect_all(sk); + return FALSE; + } + len = recv(sk, &hdr, sizeof(sdp_pdu_hdr_t), MSG_PEEK); if (len <= 0) { sdp_svcdb_collect_all(sk); -- cgit