client: make it explicit that we don't reuse 'eta' after freeing it
authorJens Axboe <axboe@fb.com>
Fri, 14 Aug 2015 15:45:46 +0000 (09:45 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 14 Aug 2015 15:45:46 +0000 (09:45 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
client.c
client.h

index af3407cefe95a55fc211d5deb92bd4687fd922fc..110a01bd99564280245cd59ca7ff27759bf3e936 100644 (file)
--- a/client.c
+++ b/client.c
@@ -184,6 +184,17 @@ void fio_put_client(struct fio_client *client)
        free(client);
 }
 
+static int fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
+{
+       if (!--eta->pending) {
+               eta_fn(&eta->eta);
+               free(eta);
+               return 0;
+       }
+
+       return 1;
+}
+
 static void remove_client(struct fio_client *client)
 {
        assert(client->refs);
@@ -1091,14 +1102,6 @@ void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
        strcpy((char *) dst->run_str, (char *) je->run_str);
 }
 
-void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
-{
-       if (!--eta->pending) {
-               eta_fn(&eta->eta);
-               free(eta);
-       }
-}
-
 static void remove_reply_cmd(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct fio_net_cmd_reply *reply = NULL;
@@ -1573,8 +1576,10 @@ static void request_client_etas(struct client_ops *ops)
                                        (uintptr_t) eta, &client->cmd_list);
        }
 
-       while (skipped--)
-               fio_client_dec_jobs_eta(eta, ops->eta);
+       while (skipped--) {
+               if (!fio_client_dec_jobs_eta(eta, ops->eta))
+                       break;
+       }
 
        dprint(FD_NET, "client: requested eta tag %p\n", eta);
 }
index 8818de2b82119e4787cbb6fd6d63b4941fb5afd9..cfb0b4d4793bef27e5f2086f1b9c1219852aceee 100644 (file)
--- a/client.h
+++ b/client.h
@@ -111,7 +111,6 @@ struct client_eta {
 };
 
 extern int fio_handle_client(struct fio_client *);
-extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
 extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
 
 enum {