summaryrefslogtreecommitdiffstats
path: root/src/module-protocol-stub.c
diff options
context:
space:
mode:
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;
}