Commit e5ae34e0d2981f87c5b973bac827ada76871cdf9

Authored by perry.werneck@gmail.com
1 parent a8187e9a

Removendo variavel duplicada

Showing 3 changed files with 21 additions and 22 deletions   Show diff stats
@@ -546,9 +546,8 @@ static int do_connect(H3270 *hSession, const char *n) @@ -546,9 +546,8 @@ static int do_connect(H3270 *hSession, const char *n)
546 546
547 /* Attempt contact. */ 547 /* Attempt contact. */
548 hSession->ever_3270 = False; 548 hSession->ever_3270 = False;
549 - hSession->net_sock = net_connect(hSession, chost, port, 0, &resolving,&pending);  
550 549
551 - if (hSession->net_sock < 0 && !resolving) 550 + if(net_connect(hSession, chost, port, 0, &resolving,&pending) < 0 && !resolving)
552 { 551 {
553 /* Redundantly signal a disconnect. */ 552 /* Redundantly signal a disconnect. */
554 host_disconnected(hSession); 553 host_disconnected(hSession);
@@ -573,7 +572,7 @@ static int do_connect(H3270 *hSession, const char *n) @@ -573,7 +572,7 @@ static int do_connect(H3270 *hSession, const char *n)
573 // login_macro(ps); 572 // login_macro(ps);
574 573
575 /* Prepare Xt for I/O. */ 574 /* Prepare Xt for I/O. */
576 - x_add_input(hSession,hSession->net_sock); 575 + x_add_input(hSession,hSession->sock);
577 576
578 /* Set state and tell the world. */ 577 /* Set state and tell the world. */
579 if (pending) 578 if (pending)
@@ -662,8 +661,7 @@ void host_disconnect(H3270 *h, int failed) @@ -662,8 +661,7 @@ void host_disconnect(H3270 *h, int failed)
662 if (CONNECTED || HALF_CONNECTED) 661 if (CONNECTED || HALF_CONNECTED)
663 { 662 {
664 x_remove_input(h); 663 x_remove_input(h);
665 - net_disconnect();  
666 - h->net_sock = -1; 664 + net_disconnect(h);
667 665
668 Trace("Disconnected (Failed: %d Reconnect: %d in_progress: %d)",failed,toggled(RECONNECT),h->auto_reconnect_inprogress); 666 Trace("Disconnected (Failed: %d Reconnect: %d in_progress: %d)",failed,toggled(RECONNECT),h->auto_reconnect_inprogress);
669 if (toggled(RECONNECT) && !h->auto_reconnect_inprogress) 667 if (toggled(RECONNECT) && !h->auto_reconnect_inprogress)
@@ -913,33 +913,34 @@ static void output_possible(H3270 *session) @@ -913,33 +913,34 @@ static void output_possible(H3270 *session)
913 * net_disconnect 913 * net_disconnect
914 * Shut down the socket. 914 * Shut down the socket.
915 */ 915 */
916 -void net_disconnect(void) 916 +void net_disconnect(H3270 *session)
917 { 917 {
918 #if defined(HAVE_LIBSSL) 918 #if defined(HAVE_LIBSSL)
919 - if (h3270.ssl_con != NULL) 919 + if(session->ssl_con != NULL)
920 { 920 {
921 - SSL_shutdown(h3270.ssl_con);  
922 - SSL_free(h3270.ssl_con);  
923 - h3270.ssl_con = NULL; 921 + SSL_shutdown(session->ssl_con);
  922 + SSL_free(session->ssl_con);
  923 + session->ssl_con = NULL;
924 } 924 }
925 #endif 925 #endif
926 926
927 - set_ssl_state(&h3270,LIB3270_SSL_UNSECURE);  
928 -  
929 - if (CONNECTED)  
930 - (void) shutdown(h3270.sock, 2); 927 + set_ssl_state(session,LIB3270_SSL_UNSECURE);
931 928
932 - (void) SOCK_CLOSE(h3270.sock); 929 + if(session->sock >= 0)
  930 + {
  931 + shutdown(session->sock, 2);
  932 + SOCK_CLOSE(session->sock);
  933 + session->sock = -1;
  934 + }
933 935
934 - h3270.sock = -1;  
935 trace_dsn("SENT disconnect\n"); 936 trace_dsn("SENT disconnect\n");
936 937
937 /* Restore terminal type to its default. */ 938 /* Restore terminal type to its default. */
938 if (appres.termname == CN) 939 if (appres.termname == CN)
939 - h3270.termtype = h3270.full_model_name; 940 + session->termtype = session->full_model_name;
940 941
941 /* We're not connected to an LU any more. */ 942 /* We're not connected to an LU any more. */
942 - h3270.connected_lu = CN; 943 + session->connected_lu = CN;
943 status_lu(&h3270,CN); 944 status_lu(&h3270,CN);
944 945
945 #if !defined(_WIN32) /*[*/ 946 #if !defined(_WIN32) /*[*/
@@ -3400,7 +3401,7 @@ static void continue_tls(unsigned char *sbbuf, int len) @@ -3400,7 +3401,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3400 /* Trace the junk. */ 3401 /* Trace the junk. */
3401 trace_dsn("%s ? %s\n", opt(TELOPT_STARTTLS), cmd(SE)); 3402 trace_dsn("%s ? %s\n", opt(TELOPT_STARTTLS), cmd(SE));
3402 popup_an_error(NULL,"TLS negotiation failure"); 3403 popup_an_error(NULL,"TLS negotiation failure");
3403 - net_disconnect(); 3404 + net_disconnect(&h3270);
3404 return; 3405 return;
3405 } 3406 }
3406 3407
@@ -3412,7 +3413,7 @@ static void continue_tls(unsigned char *sbbuf, int len) @@ -3412,7 +3413,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3412 if(h3270.ssl_con == NULL) 3413 if(h3270.ssl_con == NULL)
3413 { 3414 {
3414 /* Failed. */ 3415 /* Failed. */
3415 - net_disconnect(); 3416 + net_disconnect(&h3270);
3416 return; 3417 return;
3417 } 3418 }
3418 3419
@@ -3438,7 +3439,7 @@ static void continue_tls(unsigned char *sbbuf, int len) @@ -3438,7 +3439,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3438 if (rv != 1) 3439 if (rv != 1)
3439 { 3440 {
3440 trace_dsn("continue_tls: SSL_connect failed\n"); 3441 trace_dsn("continue_tls: SSL_connect failed\n");
3441 - net_disconnect(); 3442 + net_disconnect(&h3270);
3442 return; 3443 return;
3443 } 3444 }
3444 3445
@@ -35,7 +35,7 @@ LIB3270_INTERNAL void net_add_eor(unsigned char *buf, int len); @@ -35,7 +35,7 @@ LIB3270_INTERNAL void net_add_eor(unsigned char *buf, int len);
35 LIB3270_INTERNAL void net_break(void); 35 LIB3270_INTERNAL void net_break(void);
36 LIB3270_INTERNAL void net_charmode(void); 36 LIB3270_INTERNAL void net_charmode(void);
37 LIB3270_INTERNAL int net_connect(H3270 *session, const char *, char *, Boolean, Boolean *, Boolean *); 37 LIB3270_INTERNAL int net_connect(H3270 *session, const char *, char *, Boolean, Boolean *, Boolean *);
38 -LIB3270_INTERNAL void net_disconnect(void); 38 +LIB3270_INTERNAL void net_disconnect(H3270 *session);
39 LIB3270_INTERNAL void net_exception(H3270 *session); 39 LIB3270_INTERNAL void net_exception(H3270 *session);
40 LIB3270_INTERNAL void net_hexansi_out(unsigned char *buf, int len); 40 LIB3270_INTERNAL void net_hexansi_out(unsigned char *buf, int len);
41 LIB3270_INTERNAL void net_input(H3270 *session); 41 LIB3270_INTERNAL void net_input(H3270 *session);