projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix crash in client with NULL hostname
[fio.git]
/
client.c
diff --git
a/client.c
b/client.c
index 05439e1d2ea9b53565fb02fb22e83a5b2fe1ad3c..1dded0966cf9bcba261fb1fe5282d20bc3b67c94 100644
(file)
--- a/
client.c
+++ b/
client.c
@@
-388,7
+388,7
@@
static int fio_client_connect_sock(struct fio_client *client)
memset(addr, 0, sizeof(*addr));
addr->sun_family = AF_UNIX;
memset(addr, 0, sizeof(*addr));
addr->sun_family = AF_UNIX;
- str
cpy(addr->sun_path, client->hostname
);
+ str
ncpy(addr->sun_path, client->hostname, sizeof(addr->sun_path) - 1
);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
@@
-823,9
+823,11
@@
static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src)
}
static void json_object_add_client_info(struct json_object *obj,
}
static void json_object_add_client_info(struct json_object *obj,
-struct fio_client *client)
+
struct fio_client *client)
{
{
- json_object_add_value_string(obj, "hostname", client->hostname);
+ const char *hostname = client->hostname ? client->hostname : "";
+
+ json_object_add_value_string(obj, "hostname", hostname);
json_object_add_value_int(obj, "port", client->port);
}
json_object_add_value_int(obj, "port", client->port);
}
@@
-987,7
+989,12
@@
void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
dst->eta_sec = je->eta_sec;
dst->nr_threads += je->nr_threads;
dst->eta_sec = je->eta_sec;
dst->nr_threads += je->nr_threads;
- /* we need to handle je->run_str too ... */
+
+ /*
+ * This wont be correct for multiple strings, but at least it
+ * works for the basic cases.
+ */
+ strcpy((char *) dst->run_str, (char *) je->run_str);
}
void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
}
void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
@@
-1149,9
+1156,9
@@
static struct cmd_iolog_pdu *convert_iolog_gz(struct fio_net_cmd *cmd,
/*
* Get header first, it's not compressed
*/
/*
* Get header first, it's not compressed
*/
- nr_samples = le
32
_to_cpu(pdu->nr_samples);
+ nr_samples = le
64
_to_cpu(pdu->nr_samples);
- total = nr_samples *
sizeof(struct io_sample
);
+ total = nr_samples *
__log_entry_sz(le32_to_cpu(pdu->log_offset)
);
ret = malloc(total + sizeof(*pdu));
ret->nr_samples = nr_samples;
ret = malloc(total + sizeof(*pdu));
ret->nr_samples = nr_samples;
@@
-1201,7
+1208,8
@@
static struct cmd_iolog_pdu *convert_iolog(struct fio_net_cmd *cmd)
{
struct cmd_iolog_pdu *pdu = (struct cmd_iolog_pdu *) cmd->payload;
struct cmd_iolog_pdu *ret;
{
struct cmd_iolog_pdu *pdu = (struct cmd_iolog_pdu *) cmd->payload;
struct cmd_iolog_pdu *ret;
- int i;
+ uint64_t i;
+ void *samples;
/*
* Convert if compressed and we support it. If it's not
/*
* Convert if compressed and we support it. If it's not
@@
-1220,18
+1228,27
@@
static struct cmd_iolog_pdu *convert_iolog(struct fio_net_cmd *cmd)
} else
ret = pdu;
} else
ret = pdu;
+ ret->nr_samples = le64_to_cpu(ret->nr_samples);
ret->thread_number = le32_to_cpu(ret->thread_number);
ret->thread_number = le32_to_cpu(ret->thread_number);
- ret->nr_samples = le32_to_cpu(ret->nr_samples);
ret->log_type = le32_to_cpu(ret->log_type);
ret->compressed = le32_to_cpu(ret->compressed);
ret->log_type = le32_to_cpu(ret->log_type);
ret->compressed = le32_to_cpu(ret->compressed);
+ ret->log_offset = le32_to_cpu(ret->log_offset);
+ samples = &ret->samples[0];
for (i = 0; i < ret->nr_samples; i++) {
for (i = 0; i < ret->nr_samples; i++) {
- struct io_sample *s = &ret->samples[i];
+ struct io_sample *s;
+
+ s = __get_sample(samples, ret->log_offset, i);
+ s->time = le64_to_cpu(s->time);
+ s->val = le64_to_cpu(s->val);
+ s->__ddir = le32_to_cpu(s->__ddir);
+ s->bs = le32_to_cpu(s->bs);
- s->time = le64_to_cpu(s->time);
- s->val = le64_to_cpu(s->val);
- s->ddir = le32_to_cpu(s->ddir);
- s->bs = le32_to_cpu(s->bs);
+ if (ret->log_offset) {
+ struct io_sample_offset *so = (void *) s;
+
+ so->offset = le64_to_cpu(so->offset);
+ }
}
return ret;
}
return ret;
@@
-1374,8
+1391,7
@@
static void request_client_etas(struct client_ops *ops)
dprint(FD_NET, "client: request eta (%d)\n", nr_clients);
dprint(FD_NET, "client: request eta (%d)\n", nr_clients);
- eta = malloc(sizeof(*eta));
- memset(&eta->eta, 0, sizeof(eta->eta));
+ eta = calloc(1, sizeof(*eta) + __THREAD_RUNSTR_SZ(REAL_MAX_JOBS));
eta->pending = nr_clients;
flist_for_each(entry, &client_list) {
eta->pending = nr_clients;
flist_for_each(entry, &client_list) {