Commit f26c27d8338d89af61fc9877773e9926e9fa0b05
1 parent
8ce1e522
Exists in
master
and in
2 other branches
Adding background task counter.
Showing
5 changed files
with
34 additions
and
2 deletions
Show diff stats
src/core/iocalls.c
| ... | ... | @@ -465,9 +465,10 @@ LIB3270_EXPORT int lib3270_run_task(H3270 *hSession, int(*callback)(H3270 *h, vo |
| 465 | 465 | CHECK_SESSION_HANDLE(hSession); |
| 466 | 466 | |
| 467 | 467 | hSession->cbk.set_timer(hSession,1); |
| 468 | + hSession->tasks++; | |
| 468 | 469 | rc = run_task(hSession,callback,parm); |
| 469 | 470 | hSession->cbk.set_timer(hSession,0); |
| 470 | - | |
| 471 | + hSession->tasks--; | |
| 471 | 472 | return rc; |
| 472 | 473 | |
| 473 | 474 | } | ... | ... |
src/core/properties/unsigned.c
src/core/session.c
| ... | ... | @@ -67,9 +67,24 @@ void lib3270_session_free(H3270 *h) |
| 67 | 67 | if(!h) |
| 68 | 68 | return; |
| 69 | 69 | |
| 70 | - // Terminate session | |
| 71 | 70 | if(lib3270_is_connected(h)) |
| 71 | + { | |
| 72 | + // Connected, disconnect | |
| 72 | 73 | lib3270_disconnect(h); |
| 74 | + } | |
| 75 | + else if(lib3270_get_connection_state(h) == LIB3270_CONNECTING) | |
| 76 | + { | |
| 77 | + // Connecting, disconnect | |
| 78 | + debug("%s: Stopping while connecting",__FUNCTION__); | |
| 79 | + lib3270_disconnect(h); | |
| 80 | + | |
| 81 | + } | |
| 82 | + | |
| 83 | + // Do we have pending tasks? | |
| 84 | + if(h->tasks) | |
| 85 | + { | |
| 86 | + lib3270_write_log(h,LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),"Destroying session with %u active task(s)",h->tasks); | |
| 87 | + } | |
| 73 | 88 | |
| 74 | 89 | shutdown_toggles(h); |
| 75 | 90 | ... | ... |
src/include/internals.h
src/include/lib3270/properties.h
| ... | ... | @@ -275,6 +275,16 @@ |
| 275 | 275 | */ |
| 276 | 276 | LIB3270_EXPORT const char * lib3270_service_get_name(const H3270 *h); |
| 277 | 277 | |
| 278 | + /** | |
| 279 | + * @brief Check if there's an active task. | |
| 280 | + * | |
| 281 | + * @param h Session handle. | |
| 282 | + * | |
| 283 | + * @return Number of background tasks. | |
| 284 | + * | |
| 285 | + */ | |
| 286 | + LIB3270_EXPORT unsigned int lib3270_get_task_count(const H3270 *h); | |
| 287 | + | |
| 278 | 288 | #ifdef __cplusplus |
| 279 | 289 | } |
| 280 | 290 | #endif | ... | ... |