Commit 1dced1cac1886994c109b4c7fc837d8c131c5414
1 parent
ae844c8e
Exists in
master
and in
3 other branches
Fixing bug in "auto-reconnect".
Showing
3 changed files
with
13 additions
and
8 deletions
Show diff stats
src/include/lib3270.h
| ... | ... | @@ -308,12 +308,11 @@ |
| 308 | 308 | { |
| 309 | 309 | LIB3270_SSL_UNSECURE, /**< @brief No secure connection */ |
| 310 | 310 | LIB3270_SSL_SECURE, /**< @brief Connection secure with CA check */ |
| 311 | - LIB3270_SSL_NEGOTIATED, /**< @brief Connection secure, no CA or self-signed */ | |
| 311 | + LIB3270_SSL_NEGOTIATED, /**< @brief Connection secure, no CA, self-signed or expired CRL */ | |
| 312 | 312 | LIB3270_SSL_NEGOTIATING, /**< @brief Negotiating SSL */ |
| 313 | 313 | LIB3270_SSL_UNDEFINED /**< @brief Undefined */ |
| 314 | 314 | } LIB3270_SSL_STATE; |
| 315 | 315 | |
| 316 | - | |
| 317 | 316 | /** |
| 318 | 317 | * @brief Field information. |
| 319 | 318 | * | ... | ... |
src/lib3270/host.c
| ... | ... | @@ -69,8 +69,9 @@ int lib3270_check_for_auto_reconnect(H3270 *hSession) |
| 69 | 69 | if(hSession->auto_reconnect_inprogress) |
| 70 | 70 | { |
| 71 | 71 | lib3270_write_log(hSession,"3270","Starting auto-reconnect on %s",lib3270_get_url(hSession)); |
| 72 | - lib3270_reconnect(hSession,0); | |
| 73 | - hSession->auto_reconnect_inprogress = 0; | |
| 72 | + hSession->auto_reconnect_inprogress = 0; // Reset "in-progress" to allow reconnection. | |
| 73 | + if(lib3270_reconnect(hSession,0)) | |
| 74 | + lib3270_write_log(hSession,"3270","Auto-reconnect fails: %s",strerror(errno)); | |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | 77 | return 0; | ... | ... |
src/lib3270/linux/connect.c
| ... | ... | @@ -297,19 +297,22 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
| 297 | 297 | optval = 1; |
| 298 | 298 | if (setsockopt(hSession->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0) |
| 299 | 299 | { |
| 300 | + int rc = errno; | |
| 300 | 301 | lib3270_popup_dialog( hSession, |
| 301 | 302 | LIB3270_NOTIFY_ERROR, |
| 302 | 303 | _( "Connection error" ), |
| 303 | 304 | _( "setsockopt(SO_OOBINLINE) has failed" ), |
| 304 | 305 | "%s", |
| 305 | - strerror(errno)); | |
| 306 | + strerror(rc)); | |
| 306 | 307 | SOCK_CLOSE(hSession); |
| 307 | - return errno = ENOTCONN; | |
| 308 | + return rc; | |
| 308 | 309 | } |
| 309 | 310 | |
| 310 | 311 | optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; |
| 311 | 312 | if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) |
| 312 | 313 | { |
| 314 | + int rc = errno; | |
| 315 | + | |
| 313 | 316 | char buffer[4096]; |
| 314 | 317 | snprintf(buffer,4095,N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); |
| 315 | 318 | |
| ... | ... | @@ -318,9 +321,9 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
| 318 | 321 | _( "Connection error" ), |
| 319 | 322 | buffer, |
| 320 | 323 | "%s", |
| 321 | - strerror(errno)); | |
| 324 | + strerror(rc)); | |
| 322 | 325 | SOCK_CLOSE(hSession); |
| 323 | - return errno = ENOTCONN; | |
| 326 | + return rc; | |
| 324 | 327 | } |
| 325 | 328 | else |
| 326 | 329 | { |
| ... | ... | @@ -375,6 +378,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
| 375 | 378 | |
| 376 | 379 | default: |
| 377 | 380 | lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->cstate); |
| 381 | + errno = EINVAL; | |
| 378 | 382 | return -1; |
| 379 | 383 | } |
| 380 | 384 | |
| ... | ... | @@ -382,6 +386,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
| 382 | 386 | |
| 383 | 387 | lib3270_disconnect(hSession); |
| 384 | 388 | lib3270_write_log(hSession,"connect", "%s: %s",__FUNCTION__,strerror(ETIMEDOUT)); |
| 389 | + | |
| 385 | 390 | return errno = ETIMEDOUT; |
| 386 | 391 | } |
| 387 | 392 | ... | ... |