|
|
@ -95,7 +95,7 @@ static int __conn_read(sxlink_t *co, void *buf, size_t buf_len)
|
|
|
|
ofcmode = fcntl(rfd, F_GETFL,0);
|
|
|
|
ofcmode = fcntl(rfd, F_GETFL,0);
|
|
|
|
ofcmode |= O_NDELAY;
|
|
|
|
ofcmode |= O_NDELAY;
|
|
|
|
if(fcntl(rfd, F_SETFL, ofcmode))
|
|
|
|
if(fcntl(rfd, F_SETFL, ofcmode))
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)Couldn't make socket nonblocking");
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)Couldn't make socket nonblocking");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
__retry:
|
|
|
|
__retry:
|
|
|
@ -120,26 +120,26 @@ static int __conn_read(sxlink_t *co, void *buf, size_t buf_len)
|
|
|
|
case SSL_ERROR_SYSCALL:
|
|
|
|
case SSL_ERROR_SYSCALL:
|
|
|
|
if(errno == EAGAIN || errno == EINTR) goto __try_again;
|
|
|
|
if(errno == EAGAIN || errno == EINTR) goto __try_again;
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)SSL syscall error.\n");
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)SSL syscall error.\n");
|
|
|
|
goto __close_conn;
|
|
|
|
goto __close_conn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SSL_ERROR_WANT_CONNECT:
|
|
|
|
case SSL_ERROR_WANT_CONNECT:
|
|
|
|
case SSL_ERROR_WANT_ACCEPT:
|
|
|
|
case SSL_ERROR_WANT_ACCEPT:
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)SSL negotiation required. Trying again.\n");
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)SSL negotiation required. Trying again.\n");
|
|
|
|
goto __try_again;
|
|
|
|
goto __try_again;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SSL_ERROR_SSL:
|
|
|
|
case SSL_ERROR_SSL:
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)SSL error occured. Connection will be closed.\n");
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)SSL error occured. Connection will be closed.\n");
|
|
|
|
goto __close_conn;
|
|
|
|
goto __close_conn;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SSL_ERROR_ZERO_RETURN:
|
|
|
|
case SSL_ERROR_ZERO_RETURN:
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)SSL connection is cleary closed.\n");
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)SSL connection is cleary closed.\n");
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
__close_conn:
|
|
|
|
__close_conn:
|
|
|
|
ERR_free_strings();
|
|
|
|
ERR_free_strings();
|
|
|
|
co->flags |= SXMP_CLOSED;
|
|
|
|
co->flags |= SXMP_CLOSED;
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)Unknown error on %s (errno = %d)\n", co->uuid, errno);
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)Unknown error on %s (errno = %d)\n", co->uuid, errno);
|
|
|
|
ERR_remove_state(0);
|
|
|
|
ERR_remove_state(0);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -154,12 +154,12 @@ static int __conn_read(sxlink_t *co, void *buf, size_t buf_len)
|
|
|
|
r = select(rfd + 1, &readset, NULL, NULL, NULL);
|
|
|
|
r = select(rfd + 1, &readset, NULL, NULL, NULL);
|
|
|
|
if(r < 0) {
|
|
|
|
if(r < 0) {
|
|
|
|
if(errno == EINTR || errno == EAGAIN) goto __select_retry;
|
|
|
|
if(errno == EINTR || errno == EAGAIN) goto __select_retry;
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)Select (%d) on %s\n", errno, co->uuid);
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)Select (%d) on %s\n", errno, co->uuid);
|
|
|
|
ERR_remove_state(0);
|
|
|
|
ERR_remove_state(0);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!r) {
|
|
|
|
if(!r) {
|
|
|
|
fprintf(stderr, "[sxmplv2] (RD)Nothing to wait for\n");
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (RD)Nothing to wait for\n");
|
|
|
|
ERR_remove_state(0);
|
|
|
|
ERR_remove_state(0);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -209,7 +209,7 @@ static int __conn_write(sxlink_t *co, void *buf, size_t buf_len)
|
|
|
|
/* set closed flag */
|
|
|
|
/* set closed flag */
|
|
|
|
ERR_free_strings();
|
|
|
|
ERR_free_strings();
|
|
|
|
co->flags |= SXMP_CLOSED;
|
|
|
|
co->flags |= SXMP_CLOSED;
|
|
|
|
fprintf(stderr, "[sxmplv2] (WR)Unknown error on %s (%d)\n", co->uuid, r);
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] (WR)Unknown error on %s (%d)\n", co->uuid, r);
|
|
|
|
ERR_remove_state(0);
|
|
|
|
ERR_remove_state(0);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
} else return r;
|
|
|
|
} else return r;
|
|
|
@ -811,7 +811,7 @@ static void *__sxmpl_thread(void *b)
|
|
|
|
/* reply came ... */
|
|
|
|
/* reply came ... */
|
|
|
|
if(mid > (MAX_MSGINPROCESS - 1)) {
|
|
|
|
if(mid > (MAX_MSGINPROCESS - 1)) {
|
|
|
|
__inval_idx_nor:
|
|
|
|
__inval_idx_nor:
|
|
|
|
fprintf(stderr, "[sxmplv2] Invalid index of the message (%lu).\n", mid);
|
|
|
|
sxlink_log(co, SXERROR_LOG, "[sxmplv2] Invalid index of the message (%lu).\n", mid);
|
|
|
|
goto __again;
|
|
|
|
goto __again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|