Add support for client timed out ops
authorJens Axboe <axboe@kernel.dk>
Fri, 2 Mar 2012 11:14:40 +0000 (12:14 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 2 Mar 2012 11:14:40 +0000 (12:14 +0100)
Just opens a dialog window.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
client.h
gfio.c

index a84b92c4739ff7f83492b49d8567a70776893226..feb1eba52440eb5a3bda9f53cef6f64e3ff2df1e 100644 (file)
--- a/client.c
+++ b/client.c
@@ -984,7 +984,7 @@ static int client_check_cmd_timeout(struct fio_client *client,
        return flist_empty(&client->cmd_list) && ret;
 }
 
-static int fio_client_timed_out(void)
+static int fio_client_timed_out(struct client_ops *ops)
 {
        struct fio_client *client;
        struct flist_head *entry, *tmp;
@@ -1002,7 +1002,11 @@ static int fio_client_timed_out(void)
                if (!client_check_cmd_timeout(client, &tv))
                        continue;
 
-               log_err("fio: client %s timed out\n", client->hostname);
+               if (ops->timed_out)
+                       ops->timed_out(client);
+               else
+                       log_err("fio: client %s timed out\n", client->hostname);
+
                remove_client(client);
                ret = 1;
        }
@@ -1055,7 +1059,7 @@ int fio_handle_clients(struct client_ops *ops)
                                request_client_etas();
                                memcpy(&eta_tv, &tv, sizeof(tv));
 
-                               if (fio_client_timed_out())
+                               if (fio_client_timed_out(ops))
                                        break;
                        }
 
index ea297897957a4a9073a6fd24ebf50947785a74a7..a68507f982916f44878f42ac185e7b8528bb38cd 100644 (file)
--- a/client.h
+++ b/client.h
@@ -56,6 +56,7 @@ typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *c
 typedef void (*client_thread_status_display_op)(char *status_message, double perc);
 typedef void (*client_quit_op)(struct fio_client *);
 typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *);
+typedef void (*client_timed_out)(struct fio_client *);
 
 struct client_ops {
        client_text_op_func text_op;
@@ -66,6 +67,7 @@ struct client_ops {
        client_probe_op probe;
        client_quit_op quit;
        client_add_job_op add_job;
+       client_timed_out timed_out;
        int stay_connected;
 };
 
diff --git a/gfio.c b/gfio.c
index 9d781afb37694c61532f62124bf0e7cdffb23719..85e43786509b9836fb8c9b8df5f62ef69a3612bf 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -320,6 +320,35 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
        gtk_label_set_text(GTK_LABEL(ui->eta.iodepth), tmp);
 }
 
+static void gfio_client_timed_out(struct fio_client *client)
+{
+       struct gui *ui = client->client_data;
+       GtkWidget *dialog, *label, *content;
+       char buf[256];
+
+       gdk_threads_enter();
+
+       gfio_set_connected(ui, 0);
+
+       sprintf(buf, "Client %s: timeout talking to server.\n", client->hostname);
+
+       dialog = gtk_dialog_new_with_buttons("Timed out!",
+                       GTK_WINDOW(ui->window),
+                       GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                       GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+       content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+       label = gtk_label_new((const gchar *) buf);
+       gtk_container_add(GTK_CONTAINER(content), label);
+       gtk_widget_show_all(dialog);
+       gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+
+       gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_destroy(dialog);
+
+       gdk_threads_leave();
+}
+
 struct client_ops gfio_client_ops = {
        .text_op                = gfio_text_op,
        .disk_util              = gfio_disk_util_op,
@@ -329,6 +358,7 @@ struct client_ops gfio_client_ops = {
        .probe                  = gfio_probe_op,
        .quit                   = gfio_quit_op,
        .add_job                = gfio_add_job_op,
+       .timed_out              = gfio_client_timed_out,
        .stay_connected         = 1,
 };
 
@@ -340,9 +370,7 @@ static void quit_clicked(__attribute__((unused)) GtkWidget *widget,
 
 static void *job_thread(void *arg)
 {
-       printf("job thread starts\n");
        fio_handle_clients(&gfio_client_ops);
-       printf("job thread exits\n");
        return NULL;
 }
 
@@ -660,7 +688,7 @@ static void init_ui(int *argc, char **argv[], struct gui *ui)
         * Without it, the update that happens in gfio_update_thread_status
         * doesn't really happen in a timely fashion, you need expose events
         */
-       if (!g_thread_supported ())
+       if (!g_thread_supported())
                g_thread_init(NULL);
        gdk_threads_init();