Commit 48c976f5ef66a1880c586fb18af578dbbd59b3a7
1 parent
3d6bf4b9
Exists in
master
and in
1 other branch
Fixing exit hang.
Showing
1 changed file
with
23 additions
and
4 deletions
Show diff stats
src/terminal/widget.c
| @@ -184,6 +184,18 @@ static void v3270_toggle_changed(G_GNUC_UNUSED v3270 *widget, G_GNUC_UNUSED LIB3 | @@ -184,6 +184,18 @@ static void v3270_toggle_changed(G_GNUC_UNUSED v3270 *widget, G_GNUC_UNUSED LIB3 | ||
| 184 | { | 184 | { |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | +static gboolean delayed_cleanup(H3270 *hSession) { | ||
| 188 | + | ||
| 189 | + if(lib3270_get_task_count(hSession)) | ||
| 190 | + return G_SOURCE_CONTINUE; | ||
| 191 | + | ||
| 192 | + g_message("Delayed cleanup complete"); | ||
| 193 | + lib3270_free(hSession); | ||
| 194 | + | ||
| 195 | + return G_SOURCE_REMOVE; | ||
| 196 | + | ||
| 197 | +} | ||
| 198 | + | ||
| 187 | static void finalize(GObject *object) { | 199 | static void finalize(GObject *object) { |
| 188 | 200 | ||
| 189 | debug("V3270::%s",__FUNCTION__); | 201 | debug("V3270::%s",__FUNCTION__); |
| @@ -196,13 +208,18 @@ static void finalize(GObject *object) { | @@ -196,13 +208,18 @@ static void finalize(GObject *object) { | ||
| 196 | lib3270_disconnect(terminal->host); | 208 | lib3270_disconnect(terminal->host); |
| 197 | 209 | ||
| 198 | debug("Task count: %u",lib3270_get_task_count(terminal->host)); | 210 | debug("Task count: %u",lib3270_get_task_count(terminal->host)); |
| 199 | - while(lib3270_get_task_count(terminal->host)) | 211 | + if(lib3270_get_task_count(terminal->host)) |
| 212 | + { | ||
| 213 | + // Should wait. | ||
| 214 | + g_message("TN3270 session is busy, delaying cleanup"); | ||
| 215 | + lib3270_set_user_data(terminal->host,NULL); | ||
| 216 | + g_idle_add((GSourceFunc) delayed_cleanup,terminal->host); | ||
| 217 | + } | ||
| 218 | + else | ||
| 200 | { | 219 | { |
| 201 | - debug("%s: waiting",__FUNCTION__); | ||
| 202 | - usleep(100); | 220 | + lib3270_session_free(terminal->host); |
| 203 | } | 221 | } |
| 204 | 222 | ||
| 205 | - lib3270_session_free(terminal->host); | ||
| 206 | terminal->host = NULL; | 223 | terminal->host = NULL; |
| 207 | } | 224 | } |
| 208 | 225 | ||
| @@ -608,6 +625,8 @@ static void v3270_destroy(GtkWidget *widget) | @@ -608,6 +625,8 @@ static void v3270_destroy(GtkWidget *widget) | ||
| 608 | // Cleanup | 625 | // Cleanup |
| 609 | lib3270_reset_callbacks(terminal->host); | 626 | lib3270_reset_callbacks(terminal->host); |
| 610 | lib3270_set_user_data(terminal->host,NULL); | 627 | lib3270_set_user_data(terminal->host,NULL); |
| 628 | + | ||
| 629 | + debug("%s: disconnecting", __FUNCTION__); | ||
| 611 | lib3270_disconnect(terminal->host); | 630 | lib3270_disconnect(terminal->host); |
| 612 | } | 631 | } |
| 613 | 632 |