Commit d63c57f8d98942d458a2068cc3c11c16303941a8
1 parent
a8c8c9cc
Exists in
master
and in
5 other branches
Controle de block/unblock de socket passa a receber estrutura de controle de sessão
Showing
1 changed file
with
12 additions
and
26 deletions
Show diff stats
src/lib3270/telnet.c
... | ... | @@ -203,7 +203,7 @@ static void net_rawout(unsigned const char *buf, int len); |
203 | 203 | static void check_in3270(void); |
204 | 204 | static void store3270in(unsigned char c); |
205 | 205 | static void check_linemode(Boolean init); |
206 | -static int non_blocking(Boolean on); | |
206 | +static int non_blocking(H3270 *session, Boolean on); | |
207 | 207 | static void net_connected(H3270 *session); |
208 | 208 | #if defined(X3270_TN3270E) /*[*/ |
209 | 209 | static int tn3270e_negotiate(void); |
... | ... | @@ -624,7 +624,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
624 | 624 | #endif |
625 | 625 | |
626 | 626 | /* set the socket to be non-delaying */ |
627 | - if (non_blocking(True) < 0) | |
627 | + if (non_blocking(session,True) < 0) | |
628 | 628 | close_fail; |
629 | 629 | |
630 | 630 | #if !defined(_WIN32) |
... | ... | @@ -647,7 +647,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo |
647 | 647 | case 0: // Connected |
648 | 648 | trace_dsn("Connected.\n"); |
649 | 649 | |
650 | - if(non_blocking(False) < 0) | |
650 | + if(non_blocking(session,False) < 0) | |
651 | 651 | close_fail; |
652 | 652 | net_connected(session); |
653 | 653 | break; |
... | ... | @@ -801,7 +801,7 @@ static void net_connected(H3270 *session) |
801 | 801 | } |
802 | 802 | else |
803 | 803 | { |
804 | - non_blocking(False); | |
804 | + non_blocking(session,False); | |
805 | 805 | rc = SSL_connect(session->ssl_con); |
806 | 806 | |
807 | 807 | if(rc != 1) |
... | ... | @@ -825,7 +825,7 @@ static void net_connected(H3270 *session) |
825 | 825 | return; |
826 | 826 | |
827 | 827 | } |
828 | - non_blocking(True); | |
828 | + non_blocking(session,True); | |
829 | 829 | } |
830 | 830 | |
831 | 831 | // session->secure_connection = True; |
... | ... | @@ -889,7 +889,7 @@ static void net_connected(H3270 *session) |
889 | 889 | */ |
890 | 890 | static void connection_complete(void) |
891 | 891 | { |
892 | - if (non_blocking(False) < 0) | |
892 | + if (non_blocking(&h3270,False) < 0) | |
893 | 893 | { |
894 | 894 | host_disconnect(&h3270,True); |
895 | 895 | return; |
... | ... | @@ -1100,7 +1100,7 @@ void net_input(H3270 *session) |
1100 | 1100 | |
1101 | 1101 | if (HALF_CONNECTED) |
1102 | 1102 | { |
1103 | - if (non_blocking(False) < 0) | |
1103 | + if (non_blocking(session,False) < 0) | |
1104 | 1104 | { |
1105 | 1105 | host_disconnect(session,True); |
1106 | 1106 | return; |
... | ... | @@ -3223,40 +3223,26 @@ net_snap_options(void) |
3223 | 3223 | * Set blocking/non-blocking mode on the socket. On error, pops up an error |
3224 | 3224 | * message, but does not close the socket. |
3225 | 3225 | */ |
3226 | -static int non_blocking(Boolean on) | |
3226 | +static int non_blocking(H3270 *session, Boolean on) | |
3227 | 3227 | { |
3228 | -#if !defined(BLOCKING_CONNECT_ONLY) | |
3229 | - | |
3230 | -# if defined(FIONBIO) | |
3231 | - int i = on ? 1 : 0; | |
3232 | - | |
3233 | - if (SOCK_IOCTL(h3270.sock, FIONBIO, (int *) &i) < 0) | |
3234 | - { | |
3235 | - popup_a_sockerr(NULL, N_( "ioctl(%s)" ), "FIONBIO"); | |
3236 | - return -1; | |
3237 | - } | |
3238 | - | |
3239 | -# else | |
3240 | - | |
3241 | 3228 | int f; |
3242 | 3229 | |
3243 | - if ((f = fcntl(sock, F_GETFL, 0)) == -1) | |
3230 | + if ((f = fcntl(session->sock, F_GETFL, 0)) == -1) | |
3244 | 3231 | { |
3245 | 3232 | popup_an_errno(NULL,errno, N_( "fcntl(%s)" ), "F_GETFL" ); |
3246 | 3233 | return -1; |
3247 | 3234 | } |
3235 | + | |
3248 | 3236 | if (on) |
3249 | 3237 | f |= O_NDELAY; |
3250 | 3238 | else |
3251 | 3239 | f &= ~O_NDELAY; |
3252 | - if (fcntl(sock, F_SETFL, f) < 0) | |
3240 | + | |
3241 | + if (fcntl(session->sock, F_SETFL, f) < 0) | |
3253 | 3242 | { |
3254 | 3243 | popup_an_errno(NULL,errno, N_( "fcntl(%s)" ), "F_GETFL"); |
3255 | 3244 | return -1; |
3256 | 3245 | } |
3257 | -#endif // FIONBIO | |
3258 | - | |
3259 | -#endif // !BLOCKING_CONNECT_ONLY | |
3260 | 3246 | |
3261 | 3247 | return 0; |
3262 | 3248 | } | ... | ... |