summaryrefslogtreecommitdiffstats
path: root/src/module-protocol-stub.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-06 00:08:44 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-06 00:08:44 +0000
commitf8cbde54dab2783e2c6ba699dfaee9ef51b1e098 (patch)
tree7bdcc21f3b25d521207d19c8ca26eb26229b6bb7 /src/module-protocol-stub.c
parent722c2c8c8785d215ec3ec8757168b82c9600f4a3 (diff)
auth support in esound and native
AUTH and SET_NAME operatins in native simple library git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@51 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/module-protocol-stub.c')
-rw-r--r--src/module-protocol-stub.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/module-protocol-stub.c b/src/module-protocol-stub.c
index 1a655454..713e0ab8 100644
--- a/src/module-protocol-stub.c
+++ b/src/module-protocol-stub.c
@@ -1,3 +1,5 @@
+#include <string.h>
+#include <errno.h>
#include <stdio.h>
#include <assert.h>
#include <arpa/inet.h>
@@ -50,13 +52,24 @@ int module_init(struct pa_core *c, struct pa_module*m) {
assert(c && m);
#ifdef USE_TCP_SOCKETS
- if (!(s = pa_socket_server_new_ipv4(c->mainloop, INADDR_LOOPBACK, IPV4_PORT)))
+ if (!(s = pa_socket_server_new_ipv4(c->mainloop, INADDR_ANY, IPV4_PORT)))
return -1;
#else
if (pa_make_secure_dir(UNIX_SOCKET_DIR) < 0) {
fprintf(stderr, "Failed to create secure socket directory.\n");
return -1;
}
+
+ {
+ int r;
+ if ((r = pa_unix_socket_remove_stale(UNIX_SOCKET)) < 0) {
+ fprintf(stderr, "Failed to remove stale UNIX socket '%s': %s\n", UNIX_SOCKET, strerror(errno));
+ return -1;
+ }
+
+ if (r)
+ fprintf(stderr, "Removed stale UNIX socket '%s'.", UNIX_SOCKET);
+ }
if (!(s = pa_socket_server_new_unix(c->mainloop, UNIX_SOCKET))) {
rmdir(UNIX_SOCKET_DIR);
@@ -69,8 +82,12 @@ int module_init(struct pa_core *c, struct pa_module*m) {
#else
m->userdata = protocol_new(c, s);
#endif
-
- assert(m->userdata);
+
+ if (!m->userdata) {
+ pa_socket_server_free(s);
+ return -1;
+ }
+
return 0;
}