From 25095e1bbcdc9f79f7052f6ff79e4b7245cce955 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 9 Mar 2012 17:09:55 +0100 Subject: [PATCH] client: return more errors Signed-off-by: Jens Axboe --- client.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/client.c b/client.c index 98c8b28b..7eb0cdcf 100644 --- a/client.c +++ b/client.c @@ -275,16 +275,20 @@ static int fio_client_connect_ip(struct fio_client *client) fd = socket(domain, SOCK_STREAM, 0); if (fd < 0) { + int ret = -errno; + log_err("fio: socket: %s\n", strerror(errno)); - return -errno; + return ret; } if (connect(fd, addr, socklen) < 0) { + int ret = -errno; + log_err("fio: connect: %s\n", strerror(errno)); log_err("fio: failed to connect to %s:%u\n", client->hostname, client->port); close(fd); - return -errno; + return ret; } return fd; @@ -302,15 +306,19 @@ static int fio_client_connect_sock(struct fio_client *client) fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) { + int ret = -errno; + log_err("fio: socket: %s\n", strerror(errno)); - return -errno; + return ret; } len = sizeof(addr->sun_family) + strlen(addr->sun_path) + 1; if (connect(fd, (struct sockaddr *) addr, len) < 0) { + int ret = -errno; + log_err("fio: connect; %s\n", strerror(errno)); close(fd); - return -errno; + return ret; } return fd; @@ -506,14 +514,18 @@ static int __fio_client_send_ini(struct fio_client *client, const char *filename fd = open(filename, O_RDONLY); if (fd < 0) { + int ret = -errno; + log_err("fio: job file <%s> open: %s\n", filename, strerror(errno)); - return 1; + return ret; } if (fstat(fd, &sb) < 0) { + int ret = -errno; + log_err("fio: job file stat: %s\n", strerror(errno)); close(fd); - return 1; + return ret; } buf = malloc(sb.st_size); @@ -550,13 +562,16 @@ static int __fio_client_send_ini(struct fio_client *client, const char *filename int fio_client_send_ini(struct fio_client *client, const char *filename) { - if (__fio_client_send_ini(client, filename)) { + int ret; + + ret = __fio_client_send_ini(client, filename); + if (ret) { remove_client(client); - return 1; + return ret; } client->sent_job = 1; - return 0; + return ret; } int fio_clients_send_ini(const char *filename) -- 2.25.1