server: ensure to set proper port
authorJens Axboe <axboe@kernel.dk>
Fri, 7 Oct 2011 10:55:14 +0000 (12:55 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 7 Oct 2011 10:55:14 +0000 (12:55 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
server.c

index 8bd39a8bc7886990f835e4f89fa9dae94df46429..2d9c0fef21faec39dafd72ca02f9a0201c9b34bb 100644 (file)
--- a/client.c
+++ b/client.c
@@ -176,7 +176,8 @@ static int fio_client_connect_ip(struct fio_client *client)
 
        if (connect(fd, (struct sockaddr *) &client->addr, sizeof(client->addr)) < 0) {
                log_err("fio: connect: %s\n", strerror(errno));
-               log_err("fio: failed to connect to %s\n", client->hostname);
+               log_err("fio: failed to connect to %s:%u\n", client->hostname,
+                                                               client->port);
                close(fd);
                return -1;
        }
index 4f9b362455970dd54d22f965682402a3dc3e54ee..f7be89a7ef8262e273daea43fc70d9f4e9cb6246 100644 (file)
--- a/server.c
+++ b/server.c
@@ -802,7 +802,6 @@ int fio_server_parse_string(const char *str, char **ptr, int *is_sock,
 
                        hent = gethostbyname(host);
                        if (!hent) {
-                               printf("FAIL\n");
                                free(*ptr);
                                *ptr = NULL;
                                return 1;
@@ -832,13 +831,12 @@ int fio_server_parse_string(const char *str, char **ptr, int *is_sock,
  */
 static int fio_handle_server_arg(void)
 {
-       int is_sock, ret;
+       int is_sock, ret = 0;
 
        saddr_in.sin_addr.s_addr = htonl(INADDR_ANY);
-       saddr_in.sin_port = htons(fio_net_port);
 
        if (!fio_server_arg)
-               return 0;
+               goto out;
 
        ret = fio_server_parse_string(fio_server_arg, &bind_sock, &is_sock,
                                        &fio_net_port, &saddr_in.sin_addr);
@@ -848,6 +846,8 @@ static int fio_handle_server_arg(void)
                bind_sock = NULL;
        }
 
+out:
+       saddr_in.sin_port = htons(fio_net_port);
        return ret;
 }