summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-14 00:33:09 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-14 00:33:09 +0000
commitfa70fc6dfb0912b116aabdd39436a8b0be55123e (patch)
treee3286ea1acd17321318f45b5303ea51f87b5691f
parent61df552d044d5b72c52b19ff8e323f0b6e83e9bc (diff)
Implement compat mode for the Unix socket access
-rw-r--r--sdpd/server.c22
1 files changed, 16 insertions, 6 deletions
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);
}