X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afs.c;h=a40948f27014813cc1fbbf26867da28e124ad07a;hp=a7778a5854ce782221cc7090b09eaa1a07e62049;hb=2c679eeb8bbc93220f85403eca6e9380dc624a6a;hpb=32c51e5eef9085285cc4ec4f4d713edb2fab9ac0 diff --git a/afs.c b/afs.c index a7778a58..a40948f2 100644 --- a/afs.c +++ b/afs.c @@ -174,15 +174,13 @@ int send_callback_request(callback_function *f, struct osl_object *query, ret = init_unix_addr(&unix_addr, conf.afs_socket_arg); if (ret < 0) goto out; - ret = -E_CONNECT; - if (connect(fd, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0) /* FIXME: Use para_connect() */ + ret = PARA_CONNECT(fd, &unix_addr); + if (ret < 0) goto out; ret = send_bin_buffer(fd, buf, sizeof(buf)); - PARA_NOTICE_LOG("bin buffer ret: %d\n", ret); if (ret < 0) goto out; ret = recv_bin_buffer(fd, buf, sizeof(buf)); - PARA_NOTICE_LOG("ret: %d\n", ret); if (ret < 0) goto out; if (ret != sizeof(int)) { @@ -190,7 +188,6 @@ int send_callback_request(callback_function *f, struct osl_object *query, goto out; } ret = *(int *) buf; - PARA_NOTICE_LOG("result_shmid: %d\n", ret); if (ret <= 0) goto out; result_shmid = ret; @@ -214,7 +211,7 @@ out: PARA_ERROR_LOG("%s\n", "shm destroy error"); if (fd >= 0) close(fd); - PARA_DEBUG_LOG("callback_ret: %d\n", ret); +// PARA_DEBUG_LOG("callback_ret: %d\n", ret); return ret; } @@ -673,36 +670,29 @@ static void command_post_select(struct sched *s, struct task *t) t->ret = recv_bin_buffer(fd, buf, sizeof(buf)); if (t->ret < 0) { PARA_NOTICE_LOG("%s (%d)\n", PARA_STRERROR(-t->ret), t->ret); - t->ret = 1; goto out; } if (t->ret != sizeof(buf)) { PARA_NOTICE_LOG("short read (%d bytes, expected %lu)\n", t->ret, (long unsigned) sizeof(buf)); - t->ret = 1; goto out; } cookie = *(uint32_t *)buf; if (cookie != ct->cookie) { PARA_NOTICE_LOG("received invalid cookie(got %u, expected %u)\n", (unsigned)cookie, (unsigned)ct->cookie); - t->ret = 1; goto out; } query_shmid = *(int *)(buf + sizeof(cookie)); if (query_shmid < 0) { PARA_WARNING_LOG("received invalid query shmid %d)\n", query_shmid); - t->ret = 1; - goto out; - } - t->ret = call_callback(fd, query_shmid); - if (t->ret < 0) { - PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret)); - t->ret = 1; goto out; } + /* Ignore return value: Errors might be ok here. */ + call_callback(fd, query_shmid); out: + t->ret = 1; close(fd); } @@ -805,6 +795,9 @@ __noreturn int afs_init(uint32_t cookie, int socket_fd) exit(EXIT_FAILURE); } server_socket = socket_fd; + ret = mark_fd_nonblock(server_socket); + if (ret < 0) + exit(EXIT_FAILURE); PARA_INFO_LOG("server_socket: %d, afs_socket_cookie: %u\n", server_socket, (unsigned) cookie); current_play_mode = init_admissible_files();