Terminate clients when 'Disconnect' is clicked
authorJens Axboe <axboe@kernel.dk>
Fri, 2 Mar 2012 12:32:04 +0000 (13:32 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 2 Mar 2012 12:32:04 +0000 (13:32 +0100)
And reports errors in error bar.

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

index a68507f982916f44878f42ac185e7b8528bb38cd..de6c19711d9516b60d948c0d371d24be7d4ff2b1 100644 (file)
--- a/client.h
+++ b/client.h
@@ -95,5 +95,7 @@ extern int fio_handle_clients(struct client_ops *ops);
 extern int fio_client_add(const char *, void **);
 extern struct fio_client *fio_client_add_explicit(const char *, int, int);
 extern void fio_client_add_cmd_option(void *, const char *);
+extern void fio_clients_terminate(void);
+
 #endif
 
diff --git a/gfio.c b/gfio.c
index 718d82174102fdc78178b44071f78413071290af..03b4a139253fddbbe65abc36e9c626b37c369812 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -411,20 +411,6 @@ static GtkWidget *new_info_label_in_frame(GtkWidget *box, const char *label)
        return label_widget;
 }
 
-static GtkWidget *create_text_entry(GtkWidget *hbox, const char *defval)
-{
-       GtkWidget *text, *box;
-
-       box = gtk_hbox_new(FALSE, 3);
-       gtk_container_add(GTK_CONTAINER(hbox), box);
-
-       text = gtk_entry_new();
-       gtk_box_pack_start(GTK_BOX(box), text, TRUE, TRUE, 0);
-       gtk_entry_set_text(GTK_ENTRY(text), defval);
-
-       return text;
-}
-
 static GtkWidget *create_spinbutton(GtkWidget *hbox, double min, double max, double defval)
 {
        GtkWidget *button, *box;
@@ -450,17 +436,22 @@ static void start_job_clicked(__attribute__((unused)) GtkWidget *widget,
        start_job_thread(ui);
 }
 
-static void connect_clicked(__attribute__((unused)) GtkWidget *widget,
-                gpointer data)
+static void file_open(GtkWidget *w, gpointer data);
+
+static void connect_clicked(GtkWidget *widget, gpointer data)
 {
        struct gui *ui = data;
 
        if (!ui->connected) {
+               if (!ui->nr_job_files)
+                       file_open(widget, data);
                fio_clients_connect();
                pthread_create(&ui->t, NULL, job_thread, NULL);
                gfio_set_connected(ui, 1);
-       } else
+       } else {
+               fio_clients_terminate();
                gfio_set_connected(ui, 0);
+       }
 }
 
 static void add_button(struct gui *ui, int i, GtkWidget *buttonbox,
@@ -492,7 +483,7 @@ static void on_info_bar_response(GtkWidget *widget, gint response,
        }
 }
 
-void report_error(GErrorerror)
+void report_error(GError *error)
 {
        if (ui.error_info_bar == NULL) {
                ui.error_info_bar = gtk_info_bar_new_with_buttons(GTK_STOCK_OK,
@@ -629,14 +620,15 @@ static void file_open(GtkWidget *w, gpointer data)
                ui.nr_job_files++;
 
                ui.client = fio_client_add_explicit(host, type, port);
-               ui.client->client_data = &ui;
-#if 0
-               if (error) {
+               if (!ui.client) {
+                       GError *error;
+
+                       error = g_error_new(g_quark_from_string("fio"), 1,
+                                       "Failed to add client %s", host);
                        report_error(error);
                        g_error_free(error);
-                       error = NULL;
                }
-#endif
+               ui.client->client_data = &ui;
                        
                g_free(filenames->data);
                filenames = g_slist_next(filenames);