X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afs.c;h=6210358c4ef075ed4bb13680028b27f1ec430123;hp=e84d9a8839a14b5ec7267b62f2c5065414863276;hb=5b8e525dfb2f18a4e0d67b9da264259159ad2184;hpb=89b30ef7b5ee1bb73b8efa3ccbb53c229066439e diff --git a/afs.c b/afs.c index e84d9a88..6210358c 100644 --- a/afs.c +++ b/afs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Andre Noll + * Copyright (C) 2007-2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -164,7 +164,6 @@ int send_callback_request(callback_function *f, struct osl_object *query, int ret, fd = -1, query_shmid, result_shmid; void *query_shm, *result_shm; char buf[sizeof(afs_socket_cookie) + sizeof(int)]; - struct sockaddr_un unix_addr; size_t query_shm_size = sizeof(*cq); if (query) @@ -189,16 +188,10 @@ int send_callback_request(callback_function *f, struct osl_object *query, *(uint32_t *) buf = afs_socket_cookie; *(int *) (buf + sizeof(afs_socket_cookie)) = query_shmid; - ret = get_stream_socket(PF_UNIX); + ret = create_remote_socket(conf.afs_socket_arg); if (ret < 0) goto out; fd = ret; - ret = init_unix_addr(&unix_addr, conf.afs_socket_arg); - if (ret < 0) - goto out; - ret = PARA_CONNECT(fd, &unix_addr); - if (ret < 0) - goto out; ret = send_bin_buffer(fd, buf, sizeof(buf)); if (ret < 0) goto out; @@ -206,7 +199,7 @@ int send_callback_request(callback_function *f, struct osl_object *query, if (ret < 0) goto out; if (ret != sizeof(int)) { - ret = -E_RECV; + ret = -E_AFS_SHORT_READ; goto out; } ret = *(int *) buf; @@ -491,15 +484,15 @@ again: PARA_NOTICE_LOG("getting next audio file\n"); ret = score_get_best(&aft_row, &score); if (ret < 0) { - PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_ERROR_LOG("%s\n", para_strerror(-ret)); goto no_admissible_files; } ret = open_and_update_audio_file(aft_row, score, &afd); if (ret < 0) { - PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_ERROR_LOG("%s\n", para_strerror(-ret)); ret = score_delete(aft_row); if (ret < 0) { - PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_ERROR_LOG("%s\n", para_strerror(-ret)); goto no_admissible_files; } goto again; @@ -534,10 +527,10 @@ static int activate_mood_or_playlist(char *arg, int *num_admissible) ret = change_current_mood(NULL); /* always successful */ mode = PLAY_MODE_MOOD; } else { - if (!strncmp(arg, "p:", 2)) { + if (!strncmp(arg, "p/", 2)) { ret = playlist_open(arg + 2); mode = PLAY_MODE_PLAYLIST; - } else if (!strncmp(arg, "m:", 2)) { + } else if (!strncmp(arg, "m/", 2)) { ret = change_current_mood(arg + 2); mode = PLAY_MODE_MOOD; } else @@ -583,7 +576,7 @@ static int com_select_callback(const struct osl_object *query, playlist_close(); ret = activate_mood_or_playlist(arg, &num_admissible); if (ret < 0) { - para_printf(&pb, "%s\n", PARA_STRERROR(-ret)); + para_printf(&pb, "%s\n", para_strerror(-ret)); para_printf(&pb, "switching back to %s\n", current_mop? current_mop : "dummy"); ret = activate_mood_or_playlist(current_mop, &num_admissible); @@ -633,7 +626,7 @@ static int setup_command_socket_or_die(void) ret = create_local_socket(socket_name, &unix_addr, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH); if (ret < 0) { - PARA_EMERG_LOG("%s: %s\n", PARA_STRERROR(-ret), socket_name); + PARA_EMERG_LOG("%s: %s\n", para_strerror(-ret), socket_name); exit(EXIT_FAILURE); } socket_fd = ret; @@ -646,7 +639,8 @@ static int setup_command_socket_or_die(void) close(socket_fd); return ret; } - PARA_INFO_LOG("listening on socket %s (fd %d)\n", socket_name, ret); + PARA_INFO_LOG("listening on socket %s (fd %d)\n", socket_name, + socket_fd); return socket_fd; } @@ -698,7 +692,7 @@ static int open_afs_tables(void) if (ret >= 0) continue; PARA_ERROR_LOG("%s init: %s\n", afs_tables[i].name, - PARA_STRERROR(-ret)); + para_strerror(-ret)); break; } if (ret >= 0) @@ -744,7 +738,7 @@ static void signal_post_select(struct sched *s, struct task *t) } t->ret = -E_AFS_SIGNAL; err: - PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret)); + PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret)); unregister_tasks(); } @@ -851,7 +845,7 @@ static void execute_server_command(void) if (ret <= 0) { if (ret < 0) - PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_ERROR_LOG("%s\n", para_strerror(-ret)); return; } buf[ret] = '\0'; @@ -859,7 +853,7 @@ static void execute_server_command(void) if (!strcmp(buf, "new")) { ret = open_next_audio_file(); if (ret < 0) { - PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_EMERG_LOG("%s\n", para_strerror(-ret)); unregister_tasks(); } return; @@ -876,7 +870,7 @@ static void execute_afs_command(int fd, uint32_t expected_cookie) int ret = recv_bin_buffer(fd, buf, sizeof(buf)); if (ret < 0) { - PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); return; } if (ret != sizeof(buf)) { @@ -932,13 +926,13 @@ static void command_post_select(struct sched *s, struct task *t) goto out; t->ret = para_accept(ct->fd, &unix_addr, sizeof(unix_addr)); if (t->ret < 0) { - PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret)); + PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret)); goto out; } fd = t->ret; t->ret = mark_fd_nonblocking(fd); if (t->ret < 0) { - PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret)); + PARA_NOTICE_LOG("%s\n", para_strerror(-t->ret)); close(fd); goto out; } @@ -986,7 +980,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd) ret = open_afs_tables(); if (ret < 0) { - PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_EMERG_LOG("%s\n", para_strerror(-ret)); exit(EXIT_FAILURE); } server_socket = socket_fd; @@ -1001,7 +995,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd) s.default_timeout.tv_usec = 999 * 1000; ret = schedule(&s); if (ret < 0) - PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_EMERG_LOG("%s\n", para_strerror(-ret)); close_afs_tables(); exit(EXIT_FAILURE); } @@ -1152,7 +1146,7 @@ void afs_event(enum afs_events event, struct para_buffer *pb, continue; ret = t->event_handler(event, pb, data); if (ret < 0) - PARA_CRIT_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_CRIT_LOG("%s\n", para_strerror(-ret)); } }