Commit c4963841914ed986a8a6c9e297495dd8d72fe9de

Authored by perry.werneck@gmail.com
1 parent 01bf7444

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 113 return;
114 114 }
115 115  
116   -
117 116 #ifdef _WIN32
118 117 hSession->ns_exception_id = AddExcept(hSession->sockEvent, hSession, net_exception);
119 118 hSession->ns_read_id = AddInput(hSession->sockEvent, hSession, net_input);
... ... @@ -381,6 +380,25 @@ static void net_connected(H3270 *hSession)
381 380 u_long iMode=1;
382 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 402 if(ioctlsocket(hSession->sock,FIONBIO,&iMode))
385 403 {
386 404 lib3270_popup_dialog( hSession,
... ... @@ -389,6 +407,7 @@ static void net_connected(H3270 *hSession)
389 407 _( "ioctlsocket(FIONBIO) failed." ),
390 408 "%s", lib3270_win32_strerror(WSAGetLastError()));
391 409 SOCK_CLOSE(hSession);
  410 + continue;
392 411 }
393 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 423 buffer,
405 424 "%s", lib3270_win32_strerror(err));
406 425 SOCK_CLOSE(hSession);
  426 + continue;
  427 +
407 428 }
408 429 }
409 430  
... ... @@ -414,28 +435,9 @@ static void net_connected(H3270 *hSession)
414 435 LIB3270_NOTIFY_ERROR,
415 436 _( "Connection error" ),
416 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 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 443 #else
... ... @@ -456,6 +458,7 @@ static void net_connected(H3270 *hSession)
456 458 "%s",
457 459 strerror(errno));
458 460 SOCK_CLOSE(hSession);
  461 + continue;
459 462 }
460 463 }
461 464  
... ... @@ -469,6 +472,7 @@ static void net_connected(H3270 *hSession)
469 472 "%s",
470 473 strerror(errno));
471 474 SOCK_CLOSE(hSession);
  475 + continue;
472 476 }
473 477  
474 478 optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0;
... ... @@ -484,6 +488,7 @@ static void net_connected(H3270 *hSession)
484 488 "%s",
485 489 strerror(errno));
486 490 SOCK_CLOSE(hSession);
  491 + continue;
487 492 }
488 493 else
489 494 {
... ...