Commit 33c9609656415ea7e892b2662a066fde5e8474d1
1 parent
3577dc18
Exists in
master
and in
3 other branches
Processo de conexao instavel em windows, tentando mudar para select para ver se melhora
Showing
6 changed files
with
95 additions
and
138 deletions
Show diff stats
connect.c
| @@ -113,15 +113,10 @@ static void net_connected(H3270 *hSession) | @@ -113,15 +113,10 @@ static void net_connected(H3270 *hSession) | ||
| 113 | return; | 113 | return; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | -#ifdef _WIN32 | ||
| 117 | - hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); | ||
| 118 | - hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); | ||
| 119 | -#else | ||
| 120 | hSession->ns_exception_id = AddExcept(hSession->sock, hSession, net_exception); | 116 | hSession->ns_exception_id = AddExcept(hSession->sock, hSession, net_exception); |
| 121 | hSession->ns_read_id = AddInput(hSession->sock, hSession, net_input); | 117 | hSession->ns_read_id = AddInput(hSession->sock, hSession, net_input); |
| 122 | -#endif // WIN32 | ||
| 123 | - hSession->excepting = 1; | ||
| 124 | - hSession->reading = 1; | 118 | + hSession->excepting = 1; |
| 119 | + hSession->reading = 1; | ||
| 125 | 120 | ||
| 126 | #if defined(HAVE_LIBSSL) | 121 | #if defined(HAVE_LIBSSL) |
| 127 | if(hSession->ssl_con && hSession->secure == LIB3270_SSL_UNDEFINED) | 122 | if(hSession->ssl_con && hSession->secure == LIB3270_SSL_UNDEFINED) |
| @@ -348,34 +343,6 @@ static void net_connected(H3270 *hSession) | @@ -348,34 +343,6 @@ static void net_connected(H3270 *hSession) | ||
| 348 | 343 | ||
| 349 | #ifdef WIN32 | 344 | #ifdef WIN32 |
| 350 | 345 | ||
| 351 | - if(hSession->sockEvent == NULL) | ||
| 352 | - { | ||
| 353 | - char ename[256]; | ||
| 354 | - | ||
| 355 | - snprintf(ename, 255, "%s-%d", PACKAGE_NAME, getpid()); | ||
| 356 | - | ||
| 357 | - hSession->sockEvent = CreateEvent(NULL, TRUE, FALSE, ename); | ||
| 358 | - if(hSession->sockEvent == NULL) | ||
| 359 | - { | ||
| 360 | - lib3270_popup_dialog( hSession, | ||
| 361 | - LIB3270_NOTIFY_CRITICAL, | ||
| 362 | - N_( "Network startup error" ), | ||
| 363 | - N_( "Cannot create socket event" ), | ||
| 364 | - "%s", lib3270_win32_strerror(GetLastError()) ); | ||
| 365 | - _exit(1); | ||
| 366 | - } | ||
| 367 | - } | ||
| 368 | - | ||
| 369 | - if (WSAEventSelect(hSession->sock, hSession->sockEvent, FD_READ | FD_CONNECT | FD_CLOSE) != 0) | ||
| 370 | - { | ||
| 371 | - lib3270_popup_dialog( hSession, | ||
| 372 | - LIB3270_NOTIFY_CRITICAL, | ||
| 373 | - N_( "Network startup error" ), | ||
| 374 | - N_( "WSAEventSelect failed" ), | ||
| 375 | - "%s", lib3270_win32_strerror(GetLastError()) ); | ||
| 376 | - _exit(1); | ||
| 377 | - } | ||
| 378 | - | ||
| 379 | WSASetLastError(0); | 346 | WSASetLastError(0); |
| 380 | u_long iMode=1; | 347 | u_long iMode=1; |
| 381 | trace("sock=%d",hSession->sock); | 348 | trace("sock=%d",hSession->sock); |
| @@ -523,12 +490,7 @@ static void net_connected(H3270 *hSession) | @@ -523,12 +490,7 @@ static void net_connected(H3270 *hSession) | ||
| 523 | hSession->cstate = LIB3270_PENDING; | 490 | hSession->cstate = LIB3270_PENDING; |
| 524 | lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); | 491 | lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); |
| 525 | 492 | ||
| 526 | -#ifdef _WIN32 | ||
| 527 | - trace("Sockevent=%08lx callback=%p",hSession->sockEvent,net_connected); | ||
| 528 | - hSession->ns_write_id = AddOutput(hSession->sockEvent, hSession, net_connected); | ||
| 529 | -#else | ||
| 530 | hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected); | 493 | hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected); |
| 531 | -#endif // WIN32 | ||
| 532 | 494 | ||
| 533 | trace("%s: Connection in progress",__FUNCTION__); | 495 | trace("%s: Connection in progress",__FUNCTION__); |
| 534 | 496 |
iocalls.c
| @@ -51,15 +51,9 @@ static void internal_remove_timeout(void *timer); | @@ -51,15 +51,9 @@ static void internal_remove_timeout(void *timer); | ||
| 51 | static void internal_remove_source(void *id); | 51 | static void internal_remove_source(void *id); |
| 52 | static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); | 52 | static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); |
| 53 | 53 | ||
| 54 | -#ifdef WIN32 | ||
| 55 | - static void * internal_add_input(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 56 | - static void * internal_add_output(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 57 | - static void * internal_add_except(HANDLE source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 58 | -#else | ||
| 59 | - static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 60 | - static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 61 | - static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 62 | -#endif // WIN32 | 54 | +static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *session)); |
| 55 | +static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 56 | +static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 *session)); | ||
| 63 | 57 | ||
| 64 | static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); | 58 | static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); |
| 65 | static int internal_wait(H3270 *hSession, int seconds); | 59 | static int internal_wait(H3270 *hSession, int seconds); |
| @@ -78,16 +72,6 @@ static void internal_ring_bell(H3270 *); | @@ -78,16 +72,6 @@ static void internal_ring_bell(H3270 *); | ||
| 78 | static void (*remove_source)(void *id) | 72 | static void (*remove_source)(void *id) |
| 79 | = internal_remove_source; | 73 | = internal_remove_source; |
| 80 | 74 | ||
| 81 | -#ifdef WIN32 | ||
| 82 | - static void * (*add_input)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 83 | - = internal_add_input; | ||
| 84 | - | ||
| 85 | - static void * (*add_output)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 86 | - = internal_add_output; | ||
| 87 | - | ||
| 88 | - static void * (*add_except)(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 89 | - = internal_add_except; | ||
| 90 | -#else | ||
| 91 | static void * (*add_input)(int source, H3270 *session, void (*fn)(H3270 *session)) | 75 | static void * (*add_input)(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 92 | = internal_add_input; | 76 | = internal_add_input; |
| 93 | 77 | ||
| @@ -96,7 +80,6 @@ static void internal_ring_bell(H3270 *); | @@ -96,7 +80,6 @@ static void internal_ring_bell(H3270 *); | ||
| 96 | 80 | ||
| 97 | static void * (*add_except)(int source, H3270 *session, void (*fn)(H3270 *session)) | 81 | static void * (*add_except)(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 98 | = internal_add_except; | 82 | = internal_add_except; |
| 99 | -#endif // WIN32 | ||
| 100 | 83 | ||
| 101 | static int (*callthread)(int(*callback)(H3270 *, void *), H3270 *session, void *parm) | 84 | static int (*callthread)(int(*callback)(H3270 *, void *), H3270 *session, void *parm) |
| 102 | = internal_callthread; | 85 | = internal_callthread; |
| @@ -131,11 +114,7 @@ static void internal_ring_bell(H3270 *); | @@ -131,11 +114,7 @@ static void internal_ring_bell(H3270 *); | ||
| 131 | typedef struct input | 114 | typedef struct input |
| 132 | { | 115 | { |
| 133 | struct input *next; | 116 | struct input *next; |
| 134 | -#if defined(_WIN32) | ||
| 135 | - HANDLE source; | ||
| 136 | -#else | ||
| 137 | int source; | 117 | int source; |
| 138 | -#endif // WIN32 | ||
| 139 | int condition; | 118 | int condition; |
| 140 | void (*proc)(H3270 *session); | 119 | void (*proc)(H3270 *session); |
| 141 | H3270 *session; | 120 | H3270 *session; |
| @@ -261,11 +240,7 @@ static void internal_remove_timeout(void * timer) | @@ -261,11 +240,7 @@ static void internal_remove_timeout(void * timer) | ||
| 261 | 240 | ||
| 262 | /* Input events. */ | 241 | /* Input events. */ |
| 263 | 242 | ||
| 264 | -#ifdef WIN32 | ||
| 265 | -static void * internal_add_input(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 266 | -#else | ||
| 267 | static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *session)) | 243 | static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 268 | -#endif // WIN32 | ||
| 269 | { | 244 | { |
| 270 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); | 245 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); |
| 271 | 246 | ||
| @@ -280,11 +255,7 @@ static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *s | @@ -280,11 +255,7 @@ static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *s | ||
| 280 | return ip; | 255 | return ip; |
| 281 | } | 256 | } |
| 282 | 257 | ||
| 283 | -#ifdef WIN32 | ||
| 284 | -static void * internal_add_output(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 285 | -#else | ||
| 286 | static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 *session)) | 258 | static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 287 | -#endif // WIN32 | ||
| 288 | { | 259 | { |
| 289 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); | 260 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); |
| 290 | 261 | ||
| @@ -299,13 +270,6 @@ static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 * | @@ -299,13 +270,6 @@ static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 * | ||
| 299 | return ip; | 270 | return ip; |
| 300 | } | 271 | } |
| 301 | 272 | ||
| 302 | - | ||
| 303 | -#if defined(_WIN32) | ||
| 304 | -static void * internal_add_except(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 305 | -{ | ||
| 306 | - return 0; | ||
| 307 | -} | ||
| 308 | -#else | ||
| 309 | static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 *session)) | 273 | static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 310 | { | 274 | { |
| 311 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); | 275 | input_t *ip = (input_t *) lib3270_malloc(sizeof(input_t)); |
| @@ -322,7 +286,6 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | @@ -322,7 +286,6 @@ static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 * | ||
| 322 | 286 | ||
| 323 | return ip; | 287 | return ip; |
| 324 | } | 288 | } |
| 325 | -#endif // WIN32 | ||
| 326 | 289 | ||
| 327 | static void internal_remove_source(void *id) | 290 | static void internal_remove_source(void *id) |
| 328 | { | 291 | { |
| @@ -356,19 +319,19 @@ static void internal_remove_source(void *id) | @@ -356,19 +319,19 @@ static void internal_remove_source(void *id) | ||
| 356 | static int internal_event_dispatcher(H3270 *hSession, int block) | 319 | static int internal_event_dispatcher(H3270 *hSession, int block) |
| 357 | { | 320 | { |
| 358 | #if defined(_WIN32) | 321 | #if defined(_WIN32) |
| 359 | - HANDLE ha[MAX_HA]; | ||
| 360 | - DWORD events; | ||
| 361 | - DWORD tmo; | ||
| 362 | unsigned long long now; | 322 | unsigned long long now; |
| 363 | - int i; | 323 | +// int i; |
| 324 | + int maxSock; | ||
| 325 | + DWORD tmo; | ||
| 364 | #else | 326 | #else |
| 365 | - fd_set rfds, wfds, xfds; | ||
| 366 | int ns; | 327 | int ns; |
| 367 | struct timeval now, twait, *tp; | 328 | struct timeval now, twait, *tp; |
| 368 | int events; | 329 | int events; |
| 369 | #endif | 330 | #endif |
| 331 | + | ||
| 332 | + fd_set rfds, wfds, xfds; | ||
| 333 | + | ||
| 370 | input_t *ip; | 334 | input_t *ip; |
| 371 | - struct timeout *t; | ||
| 372 | int processed_any = 0; | 335 | int processed_any = 0; |
| 373 | 336 | ||
| 374 | retry: | 337 | retry: |
| @@ -379,16 +342,33 @@ retry: | @@ -379,16 +342,33 @@ retry: | ||
| 379 | if(processed_any) | 342 | if(processed_any) |
| 380 | block = 0; | 343 | block = 0; |
| 381 | 344 | ||
| 382 | - events = 0; | ||
| 383 | - | ||
| 384 | #if defined(_WIN32) | 345 | #if defined(_WIN32) |
| 385 | 346 | ||
| 347 | + maxSock = 0; | ||
| 348 | + | ||
| 349 | + FD_ZERO(&rfds); | ||
| 350 | + FD_ZERO(&wfds); | ||
| 351 | + FD_ZERO(&xfds); | ||
| 352 | + | ||
| 386 | for (ip = inputs; ip != (input_t *)NULL; ip = ip->next) | 353 | for (ip = inputs; ip != (input_t *)NULL; ip = ip->next) |
| 387 | { | 354 | { |
| 388 | if ((unsigned long)ip->condition & InputReadMask) | 355 | if ((unsigned long)ip->condition & InputReadMask) |
| 389 | - ha[events++] = ip->source; | 356 | + { |
| 357 | + FD_SET(ip->source, &rfds); | ||
| 358 | + maxSock = max(ip->source,maxSock); | ||
| 359 | + } | ||
| 360 | + | ||
| 390 | if ((unsigned long)ip->condition & InputWriteMask) | 361 | if ((unsigned long)ip->condition & InputWriteMask) |
| 391 | - ha[events++] = ip->source; | 362 | + { |
| 363 | + FD_SET(ip->source, &wfds); | ||
| 364 | + maxSock = max(ip->source,maxSock); | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + if ((unsigned long)ip->condition & InputExceptMask) | ||
| 368 | + { | ||
| 369 | + FD_SET(ip->source, &xfds); | ||
| 370 | + maxSock = max(ip->source,maxSock); | ||
| 371 | + } | ||
| 392 | } | 372 | } |
| 393 | 373 | ||
| 394 | if (block) | 374 | if (block) |
| @@ -404,19 +384,67 @@ retry: | @@ -404,19 +384,67 @@ retry: | ||
| 404 | else | 384 | else |
| 405 | { | 385 | { |
| 406 | // Block for 1 second (at maximal) | 386 | // Block for 1 second (at maximal) |
| 407 | - tmo = 1; | 387 | + tmo = 1000; |
| 408 | } | 388 | } |
| 409 | } | 389 | } |
| 410 | - else if (!events) | 390 | + else |
| 411 | { | 391 | { |
| 412 | - // No block & no events, return | ||
| 413 | - return processed_any; | 392 | + tmo = 1000; |
| 414 | } | 393 | } |
| 415 | - else | 394 | + |
| 395 | + if(maxSock) | ||
| 416 | { | 396 | { |
| 417 | - tmo = 1; | 397 | + struct timeval tm; |
| 398 | + | ||
| 399 | + tm.tv_sec = 0; | ||
| 400 | + tm.tv_usec = tmo; | ||
| 401 | + | ||
| 402 | + int ns = select(maxSock+1, &rfds, &wfds, &xfds, &tm); | ||
| 403 | + | ||
| 404 | + if (ns < 0 && errno != EINTR) | ||
| 405 | + { | ||
| 406 | + lib3270_popup_dialog( hSession, | ||
| 407 | + LIB3270_NOTIFY_ERROR, | ||
| 408 | + _( "Network error" ), | ||
| 409 | + _( "Select() failed when processing for events." ), | ||
| 410 | + lib3270_win32_strerror(WSAGetLastError())); | ||
| 411 | + } | ||
| 412 | + else | ||
| 413 | + { | ||
| 414 | + for (ip = inputs; ip != (input_t *) NULL; ip = ip->next) | ||
| 415 | + { | ||
| 416 | + if (((unsigned long)ip->condition & InputReadMask) && FD_ISSET(ip->source, &rfds)) | ||
| 417 | + { | ||
| 418 | + (*ip->proc)(ip->session); | ||
| 419 | + processed_any = True; | ||
| 420 | + if (inputs_changed) | ||
| 421 | + goto retry; | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + if (((unsigned long)ip->condition & InputWriteMask) && FD_ISSET(ip->source, &wfds)) | ||
| 425 | + { | ||
| 426 | + (*ip->proc)(ip->session); | ||
| 427 | + processed_any = True; | ||
| 428 | + if (inputs_changed) | ||
| 429 | + goto retry; | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + if (((unsigned long)ip->condition & InputExceptMask) && FD_ISSET(ip->source, &xfds)) | ||
| 433 | + { | ||
| 434 | + (*ip->proc)(ip->session); | ||
| 435 | + processed_any = True; | ||
| 436 | + if (inputs_changed) | ||
| 437 | + goto retry; | ||
| 438 | + } | ||
| 439 | + } | ||
| 440 | + } | ||
| 441 | + } | ||
| 442 | + else if(block) | ||
| 443 | + { | ||
| 444 | + Sleep(tmo); | ||
| 418 | } | 445 | } |
| 419 | 446 | ||
| 447 | +/* | ||
| 420 | if(events) | 448 | if(events) |
| 421 | { | 449 | { |
| 422 | DWORD ret = WaitForMultipleObjects(events, ha, FALSE, tmo); | 450 | DWORD ret = WaitForMultipleObjects(events, ha, FALSE, tmo); |
| @@ -451,9 +479,12 @@ retry: | @@ -451,9 +479,12 @@ retry: | ||
| 451 | { | 479 | { |
| 452 | Sleep(100); | 480 | Sleep(100); |
| 453 | } | 481 | } |
| 482 | +*/ | ||
| 454 | 483 | ||
| 455 | #else | 484 | #else |
| 456 | 485 | ||
| 486 | + events = 0; | ||
| 487 | + | ||
| 457 | FD_ZERO(&rfds); | 488 | FD_ZERO(&rfds); |
| 458 | FD_ZERO(&wfds); | 489 | FD_ZERO(&wfds); |
| 459 | FD_ZERO(&xfds); | 490 | FD_ZERO(&xfds); |
| @@ -558,6 +589,7 @@ retry: | @@ -558,6 +589,7 @@ retry: | ||
| 558 | if (timeouts != TN) | 589 | if (timeouts != TN) |
| 559 | { | 590 | { |
| 560 | #if defined(_WIN32) | 591 | #if defined(_WIN32) |
| 592 | + struct timeout *t; | ||
| 561 | ms_ts(&now); | 593 | ms_ts(&now); |
| 562 | #else | 594 | #else |
| 563 | (void) gettimeofday(&now, (void *)NULL); | 595 | (void) gettimeofday(&now, (void *)NULL); |
| @@ -630,31 +662,19 @@ void RemoveTimeOut(void * timer) | @@ -630,31 +662,19 @@ void RemoveTimeOut(void * timer) | ||
| 630 | return remove_timeout(timer); | 662 | return remove_timeout(timer); |
| 631 | } | 663 | } |
| 632 | 664 | ||
| 633 | -#ifdef WIN32 | ||
| 634 | -void * AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 635 | -#else | ||
| 636 | void * AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) | 665 | void * AddInput(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 637 | -#endif // WIN32 | ||
| 638 | { | 666 | { |
| 639 | CHECK_SESSION_HANDLE(session); | 667 | CHECK_SESSION_HANDLE(session); |
| 640 | return add_input(source,session,fn); | 668 | return add_input(source,session,fn); |
| 641 | } | 669 | } |
| 642 | 670 | ||
| 643 | -#ifdef WIN32 | ||
| 644 | -void * AddOutput(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 645 | -#else | ||
| 646 | void * AddOutput(int source, H3270 *session, void (*fn)(H3270 *session)) | 671 | void * AddOutput(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 647 | -#endif // WIN32 | ||
| 648 | { | 672 | { |
| 649 | CHECK_SESSION_HANDLE(session); | 673 | CHECK_SESSION_HANDLE(session); |
| 650 | return add_output(source,session,fn); | 674 | return add_output(source,session,fn); |
| 651 | } | 675 | } |
| 652 | 676 | ||
| 653 | -#ifdef WIN32 | ||
| 654 | -void * AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session)) | ||
| 655 | -#else | ||
| 656 | void * AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) | 677 | void * AddExcept(int source, H3270 *session, void (*fn)(H3270 *session)) |
| 657 | -#endif // WIN32 | ||
| 658 | { | 678 | { |
| 659 | CHECK_SESSION_HANDLE(session); | 679 | CHECK_SESSION_HANDLE(session); |
| 660 | return add_except(source,session,fn); | 680 | return add_except(source,session,fn); |
| @@ -673,19 +693,11 @@ void x_except_on(H3270 *h) | @@ -673,19 +693,11 @@ void x_except_on(H3270 *h) | ||
| 673 | if(h->reading) | 693 | if(h->reading) |
| 674 | RemoveSource(h->ns_read_id); | 694 | RemoveSource(h->ns_read_id); |
| 675 | 695 | ||
| 676 | -#ifdef WIN32 | ||
| 677 | - h->ns_exception_id = AddExcept(h->sockEvent, h, net_exception); | ||
| 678 | - h->excepting = 1; | ||
| 679 | - | ||
| 680 | - if(h->reading) | ||
| 681 | - h->ns_read_id = AddInput(h->sockEvent, h, net_input); | ||
| 682 | -#else | ||
| 683 | h->ns_exception_id = AddExcept(h->sock, h, net_exception); | 696 | h->ns_exception_id = AddExcept(h->sock, h, net_exception); |
| 684 | h->excepting = 1; | 697 | h->excepting = 1; |
| 685 | 698 | ||
| 686 | if(h->reading) | 699 | if(h->reading) |
| 687 | h->ns_read_id = AddInput(h->sock, h, net_input); | 700 | h->ns_read_id = AddInput(h->sock, h, net_input); |
| 688 | -#endif // WIN32 | ||
| 689 | } | 701 | } |
| 690 | 702 | ||
| 691 | void remove_input_calls(H3270 *session) | 703 | void remove_input_calls(H3270 *session) |
session.c
| @@ -310,11 +310,6 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char | @@ -310,11 +310,6 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char | ||
| 310 | for(f=0;f<4;f++) | 310 | for(f=0;f<4;f++) |
| 311 | hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; | 311 | hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; |
| 312 | 312 | ||
| 313 | -#ifdef _WIN32 | ||
| 314 | - hSession->sockEvent = NULL; | ||
| 315 | -#endif // _WIN32 | ||
| 316 | - | ||
| 317 | - | ||
| 318 | // Initialize toggles | 313 | // Initialize toggles |
| 319 | initialize_toggles(hSession); | 314 | initialize_toggles(hSession); |
| 320 | 315 |
telnet.c
| @@ -1002,10 +1002,6 @@ void net_input(H3270 *hSession) | @@ -1002,10 +1002,6 @@ void net_input(H3270 *hSession) | ||
| 1002 | hSession->ansi_data = 0; | 1002 | hSession->ansi_data = 0; |
| 1003 | #endif | 1003 | #endif |
| 1004 | 1004 | ||
| 1005 | -#if defined(_WIN32) | ||
| 1006 | - ResetEvent(hSession->sockEvent); | ||
| 1007 | -#endif | ||
| 1008 | - | ||
| 1009 | #if defined(HAVE_LIBSSL) | 1005 | #if defined(HAVE_LIBSSL) |
| 1010 | if (hSession->ssl_con != NULL) | 1006 | if (hSession->ssl_con != NULL) |
| 1011 | nr = SSL_read(hSession->ssl_con, (char *) buffer, BUFSZ); | 1007 | nr = SSL_read(hSession->ssl_con, (char *) buffer, BUFSZ); |
testprogram.c
| @@ -36,11 +36,8 @@ int main(int numpar, char *param[]) | @@ -36,11 +36,8 @@ int main(int numpar, char *param[]) | ||
| 36 | // pthread_create(&thread, NULL, mainloop, NULL); | 36 | // pthread_create(&thread, NULL, mainloop, NULL); |
| 37 | // pthread_detach(thread); | 37 | // pthread_detach(thread); |
| 38 | 38 | ||
| 39 | -// rc = lib3270_connect_host(h, "fandezhi.efglobe.com", "telnet", LIB3270_CONNECT_OPTION_WAIT); | ||
| 40 | -// rc = lib3270_connect_host(h, "127.0.0.1", "9090", LIB3270_CONNECT_OPTION_WAIT); | ||
| 41 | - | ||
| 42 | -// lib3270_set_host_url(h,"tn3270://fandezhi.efglobe.com:9090?lu=default"); | ||
| 43 | lib3270_set_url(h,"tn3270://fandezhi.efglobe.com"); | 39 | lib3270_set_url(h,"tn3270://fandezhi.efglobe.com"); |
| 40 | + rc = lib3270_connect(h,1); | ||
| 44 | 41 | ||
| 45 | printf("\nConnect exits with rc=%d\n",rc); | 42 | printf("\nConnect exits with rc=%d\n",rc); |
| 46 | 43 |
utilc.h
| @@ -36,15 +36,10 @@ LIB3270_INTERNAL char *xs_buffer(const char *fmt, ...) printflike(1, 2); | @@ -36,15 +36,10 @@ LIB3270_INTERNAL char *xs_buffer(const char *fmt, ...) printflike(1, 2); | ||
| 36 | LIB3270_INTERNAL void xs_error(const char *fmt, ...) printflike(1, 2); | 36 | LIB3270_INTERNAL void xs_error(const char *fmt, ...) printflike(1, 2); |
| 37 | LIB3270_INTERNAL void xs_warning(const char *fmt, ...) printflike(1, 2); | 37 | LIB3270_INTERNAL void xs_warning(const char *fmt, ...) printflike(1, 2); |
| 38 | 38 | ||
| 39 | -#ifdef WIN32 | ||
| 40 | - LIB3270_INTERNAL void * AddInput(HANDLE, H3270 *session, void (*fn)(H3270 *session)); | ||
| 41 | - LIB3270_INTERNAL void * AddOutput(HANDLE, H3270 *session, void (*fn)(H3270 *session)); | ||
| 42 | - LIB3270_INTERNAL void * AddExcept(HANDLE, H3270 *session, void (*fn)(H3270 *session)); | ||
| 43 | -#else | ||
| 44 | - LIB3270_INTERNAL void * AddInput(int, H3270 *session, void (*fn)(H3270 *session)); | ||
| 45 | - LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *session)); | ||
| 46 | - LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); | ||
| 47 | -#endif // WIN32 | 39 | +LIB3270_INTERNAL void * AddInput(int, H3270 *session, void (*fn)(H3270 *session)); |
| 40 | +LIB3270_INTERNAL void * AddOutput(int, H3270 *session, void (*fn)(H3270 *session)); | ||
| 41 | +LIB3270_INTERNAL void * AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); | ||
| 42 | + | ||
| 48 | LIB3270_INTERNAL void RemoveSource(void *); | 43 | LIB3270_INTERNAL void RemoveSource(void *); |
| 49 | LIB3270_INTERNAL void * AddTimeOut(unsigned long msec, H3270 *session, void (*fn)(H3270 *session)); | 44 | LIB3270_INTERNAL void * AddTimeOut(unsigned long msec, H3270 *session, void (*fn)(H3270 *session)); |
| 50 | LIB3270_INTERNAL void RemoveTimeOut(void *cookie); | 45 | LIB3270_INTERNAL void RemoveTimeOut(void *cookie); |