Commit e77aae75f05df769b059d52eb6437e2afa6e0d51
1 parent
4953c414
Exists in
master
and in
3 other branches
Fixing windows performance issues.
Showing
3 changed files
with
41 additions
and
22 deletions
Show diff stats
src/core/host.c
... | ... | @@ -60,6 +60,7 @@ |
60 | 60 | #include <lib3270/log.h> |
61 | 61 | #include <lib3270/trace.h> |
62 | 62 | #include <lib3270/toggle.h> |
63 | +#include <lib3270/keyboard.h> | |
63 | 64 | |
64 | 65 | /** |
65 | 66 | * @brief Called from timer to attempt an automatic reconnection. |
... | ... | @@ -209,6 +210,7 @@ void lib3270_set_disconnected(H3270 *hSession) |
209 | 210 | lib3270_set_cstate(hSession,LIB3270_NOT_CONNECTED); |
210 | 211 | mcursor_set(hSession,LIB3270_POINTER_LOCKED); |
211 | 212 | |
213 | + hSession->kybdlock = LIB3270_KL_NOT_CONNECTED; | |
212 | 214 | hSession->starting = 0; |
213 | 215 | |
214 | 216 | #if defined(HAVE_LIBSSL) | ... | ... |
src/core/keyboard/kybd.c
... | ... | @@ -2240,25 +2240,3 @@ int kybd_prime(H3270 *hSession) |
2240 | 2240 | } |
2241 | 2241 | #endif /*]*/ |
2242 | 2242 | |
2243 | -LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_wait_for_keyboard_unlock(H3270 *hSession, int seconds) | |
2244 | -{ | |
2245 | - time_t end = time(0)+seconds; | |
2246 | - | |
2247 | - lib3270_main_iterate(hSession,0); | |
2248 | - | |
2249 | - do | |
2250 | - { | |
2251 | - if(!lib3270_is_connected(hSession)) | |
2252 | - return LIB3270_KL_NOT_CONNECTED; | |
2253 | - | |
2254 | - if(KYBDLOCK_IS_OERR(hSession)) | |
2255 | - break; | |
2256 | - | |
2257 | - lib3270_main_iterate(hSession,1); | |
2258 | - | |
2259 | - } | |
2260 | - while(hSession->kybdlock && time(0) < end); | |
2261 | - | |
2262 | - return (LIB3270_KEYBOARD_LOCK_STATE) hSession->kybdlock; | |
2263 | -} | |
2264 | - | ... | ... |
src/core/wait.c
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | #include <internals.h> |
31 | 31 | #include <lib3270/log.h> |
32 | 32 | #include <lib3270/trace.h> |
33 | +#include <lib3270/keyboard.h> | |
33 | 34 | #include "kybdc.h" |
34 | 35 | #include "utilc.h" |
35 | 36 | |
... | ... | @@ -232,3 +233,41 @@ LIB3270_EXPORT int lib3270_wait_for_cstate(H3270 *hSession, LIB3270_CSTATE cstat |
232 | 233 | |
233 | 234 | return errno = rc; |
234 | 235 | } |
236 | + | |
237 | +LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_wait_for_keyboard_unlock(H3270 *hSession, int seconds) | |
238 | +{ | |
239 | + debug("Session lock state is %d",lib3270_get_lock_status(hSession)); | |
240 | + | |
241 | + int rc = 0; | |
242 | + int timeout = 0; | |
243 | + void * timer = AddTimer(seconds * 1000, hSession, timer_expired, &timeout); | |
244 | + | |
245 | + while(!rc) | |
246 | + { | |
247 | + if(timeout) { | |
248 | + // Timeout! The timer was destroyed. | |
249 | + debug("%s exits with ETIMEDOUT",__FUNCTION__); | |
250 | + errno = ETIMEDOUT; | |
251 | + return (LIB3270_KEYBOARD_LOCK_STATE) hSession->kybdlock; | |
252 | + } | |
253 | + | |
254 | + if(lib3270_is_disconnected(hSession)) | |
255 | + { | |
256 | + errno = ENOTCONN; | |
257 | + break; | |
258 | + } | |
259 | + | |
260 | + if(KYBDLOCK_IS_OERR(hSession)) | |
261 | + break; | |
262 | + | |
263 | + debug("%s: Waiting",__FUNCTION__); | |
264 | + lib3270_main_iterate(hSession,1); | |
265 | + | |
266 | + } | |
267 | + | |
268 | + RemoveTimer(hSession,timer); | |
269 | + | |
270 | + debug("%s exits with rc=%d",__FUNCTION__,rc); | |
271 | + return (LIB3270_KEYBOARD_LOCK_STATE) hSession->kybdlock; | |
272 | + | |
273 | +} | ... | ... |