X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=audiod.c;h=df725f96f216afe425e12ec14f0a7a9beba4178b;hp=e7e368c210bd4979447eafdbd34038c7f2e43d2a;hb=8d7bdabd22ed7750086ca660754d8d881dae3832;hpb=f03f1a8115c0b4dcb0a705d8a686ccf511648f60 diff --git a/audiod.c b/audiod.c index e7e368c2..df725f96 100644 --- a/audiod.c +++ b/audiod.c @@ -846,10 +846,11 @@ static int init_stream_io(void) return 1; } +/* does not unlink socket on errors */ static int audiod_get_socket(void) { struct sockaddr_un unix_addr; - int fd; + int ret, fd; if (conf.socket_given) socket_name = para_strdup(conf.socket_arg); @@ -862,18 +863,22 @@ static int audiod_get_socket(void) PARA_NOTICE_LOG("local socket: %s\n", socket_name); if (conf.force_given) unlink(socket_name); - fd = create_local_socket(socket_name, &unix_addr, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH); - if (fd < 0) { - PARA_EMERG_LOG("can not connect to socket\n"); - exit(EXIT_FAILURE); /* do not unlink socket */ - } + ret = create_local_socket(socket_name, &unix_addr, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH); + if (ret < 0) + goto err; + fd = ret; if (listen(fd , 5) < 0) { - PARA_EMERG_LOG("can not listen on socket\n"); - exit(EXIT_FAILURE); /* do not unlink socket */ + ret = -ERRNO_TO_PARA_ERROR(errno); + goto err; } - mark_fd_nonblocking(fd); + ret = mark_fd_nonblocking(fd); + if (ret < 0) + goto err; return fd; +err: + PARA_EMERG_LOG("%s\n", para_strerror(-ret)); + exit(EXIT_FAILURE); } static void signal_event_handler(struct task *t)