Commit c4963841914ed986a8a6c9e297495dd8d72fe9de
1 parent
01bf7444
Exists in
master
and in
3 other branches
Ajustes em funcao dos testes em windows
Showing
1 changed file
with
27 additions
and
22 deletions
Show diff stats
connect.c
@@ -113,7 +113,6 @@ static void net_connected(H3270 *hSession) | @@ -113,7 +113,6 @@ static void net_connected(H3270 *hSession) | ||
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | 115 | ||
116 | - | ||
117 | #ifdef _WIN32 | 116 | #ifdef _WIN32 |
118 | hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); | 117 | hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception); |
119 | hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); | 118 | hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input); |
@@ -381,6 +380,25 @@ static void net_connected(H3270 *hSession) | @@ -381,6 +380,25 @@ static void net_connected(H3270 *hSession) | ||
381 | u_long iMode=1; | 380 | u_long iMode=1; |
382 | trace("sock=%d",hSession->sock); | 381 | trace("sock=%d",hSession->sock); |
383 | 382 | ||
383 | + optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; | ||
384 | + if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) | ||
385 | + { | ||
386 | + char buffer[4096]; | ||
387 | + snprintf(buffer,4095,N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); | ||
388 | + | ||
389 | + lib3270_popup_dialog( hSession, | ||
390 | + LIB3270_NOTIFY_ERROR, | ||
391 | + _( "Connection error" ), | ||
392 | + buffer, | ||
393 | + "%s", lib3270_win32_strerror(WSAGetLastError())); | ||
394 | + SOCK_CLOSE(hSession); | ||
395 | + continue; | ||
396 | + } | ||
397 | + else | ||
398 | + { | ||
399 | + trace_dsn(hSession,"Network keep-alive is %s\n",optval ? "enabled" : "disabled" ); | ||
400 | + } | ||
401 | + | ||
384 | if(ioctlsocket(hSession->sock,FIONBIO,&iMode)) | 402 | if(ioctlsocket(hSession->sock,FIONBIO,&iMode)) |
385 | { | 403 | { |
386 | lib3270_popup_dialog( hSession, | 404 | lib3270_popup_dialog( hSession, |
@@ -389,6 +407,7 @@ static void net_connected(H3270 *hSession) | @@ -389,6 +407,7 @@ static void net_connected(H3270 *hSession) | ||
389 | _( "ioctlsocket(FIONBIO) failed." ), | 407 | _( "ioctlsocket(FIONBIO) failed." ), |
390 | "%s", lib3270_win32_strerror(WSAGetLastError())); | 408 | "%s", lib3270_win32_strerror(WSAGetLastError())); |
391 | SOCK_CLOSE(hSession); | 409 | SOCK_CLOSE(hSession); |
410 | + continue; | ||
392 | } | 411 | } |
393 | else if(connect(hSession->sock, rp->ai_addr, rp->ai_addrlen)) | 412 | else if(connect(hSession->sock, rp->ai_addr, rp->ai_addrlen)) |
394 | { | 413 | { |
@@ -404,6 +423,8 @@ static void net_connected(H3270 *hSession) | @@ -404,6 +423,8 @@ static void net_connected(H3270 *hSession) | ||
404 | buffer, | 423 | buffer, |
405 | "%s", lib3270_win32_strerror(err)); | 424 | "%s", lib3270_win32_strerror(err)); |
406 | SOCK_CLOSE(hSession); | 425 | SOCK_CLOSE(hSession); |
426 | + continue; | ||
427 | + | ||
407 | } | 428 | } |
408 | } | 429 | } |
409 | 430 | ||
@@ -414,28 +435,9 @@ static void net_connected(H3270 *hSession) | @@ -414,28 +435,9 @@ static void net_connected(H3270 *hSession) | ||
414 | LIB3270_NOTIFY_ERROR, | 435 | LIB3270_NOTIFY_ERROR, |
415 | _( "Connection error" ), | 436 | _( "Connection error" ), |
416 | _( "setsockopt(SO_OOBINLINE) has failed" ), | 437 | _( "setsockopt(SO_OOBINLINE) has failed" ), |
417 | - "%s", | ||
418 | - strerror(errno)); | ||
419 | - SOCK_CLOSE(hSession); | ||
420 | - } | ||
421 | - | ||
422 | - optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; | ||
423 | - if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) | ||
424 | - { | ||
425 | - char buffer[4096]; | ||
426 | - snprintf(buffer,4095,N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); | ||
427 | - | ||
428 | - lib3270_popup_dialog( hSession, | ||
429 | - LIB3270_NOTIFY_ERROR, | ||
430 | - _( "Connection error" ), | ||
431 | - buffer, | ||
432 | - "%s", | ||
433 | - strerror(errno)); | 438 | + "%s", lib3270_win32_strerror(WSAGetLastError())); |
434 | SOCK_CLOSE(hSession); | 439 | SOCK_CLOSE(hSession); |
435 | - } | ||
436 | - else | ||
437 | - { | ||
438 | - trace_dsn(hSession,"Network keep-alive is %s\n",optval ? "enabled" : "disabled" ); | 440 | + continue; |
439 | } | 441 | } |
440 | 442 | ||
441 | #else | 443 | #else |
@@ -456,6 +458,7 @@ static void net_connected(H3270 *hSession) | @@ -456,6 +458,7 @@ static void net_connected(H3270 *hSession) | ||
456 | "%s", | 458 | "%s", |
457 | strerror(errno)); | 459 | strerror(errno)); |
458 | SOCK_CLOSE(hSession); | 460 | SOCK_CLOSE(hSession); |
461 | + continue; | ||
459 | } | 462 | } |
460 | } | 463 | } |
461 | 464 | ||
@@ -469,6 +472,7 @@ static void net_connected(H3270 *hSession) | @@ -469,6 +472,7 @@ static void net_connected(H3270 *hSession) | ||
469 | "%s", | 472 | "%s", |
470 | strerror(errno)); | 473 | strerror(errno)); |
471 | SOCK_CLOSE(hSession); | 474 | SOCK_CLOSE(hSession); |
475 | + continue; | ||
472 | } | 476 | } |
473 | 477 | ||
474 | optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; | 478 | optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; |
@@ -484,6 +488,7 @@ static void net_connected(H3270 *hSession) | @@ -484,6 +488,7 @@ static void net_connected(H3270 *hSession) | ||
484 | "%s", | 488 | "%s", |
485 | strerror(errno)); | 489 | strerror(errno)); |
486 | SOCK_CLOSE(hSession); | 490 | SOCK_CLOSE(hSession); |
491 | + continue; | ||
487 | } | 492 | } |
488 | else | 493 | else |
489 | { | 494 | { |