add judgement for ob_read_regard_ssl/ob_write_regard_ssl because when observer is stopping, fd_ could be -1
This commit is contained in:
12
deps/oblib/src/lib/ssl/ob_ssl_config.cpp
vendored
12
deps/oblib/src/lib/ssl/ob_ssl_config.cpp
vendored
@ -485,7 +485,11 @@ ssize_t ob_read_regard_ssl(int fd, void *buf, size_t nbytes)
|
|||||||
{
|
{
|
||||||
ssize_t rbytes = 0;
|
ssize_t rbytes = 0;
|
||||||
SSL* ssl = NULL;
|
SSL* ssl = NULL;
|
||||||
if (OB_LIKELY(NULL == (ssl = gs_ssl_array[fd].ssl))) {
|
if (OB_UNLIKELY(fd < 0 || fd > FD_MAX)) {
|
||||||
|
COMMON_LOG(ERROR, "fd is beyond limit", K(fd));
|
||||||
|
rbytes = -1;
|
||||||
|
errno = EINVAL;
|
||||||
|
} else if (OB_LIKELY(NULL == (ssl = gs_ssl_array[fd].ssl))) {
|
||||||
rbytes = read(fd, buf, nbytes);
|
rbytes = read(fd, buf, nbytes);
|
||||||
} else {
|
} else {
|
||||||
if (OB_UNLIKELY(0 == gs_ssl_array[fd].hand_shake_done)) {
|
if (OB_UNLIKELY(0 == gs_ssl_array[fd].hand_shake_done)) {
|
||||||
@ -544,7 +548,11 @@ ssize_t ob_write_regard_ssl(int fd, const void *buf, size_t nbytes)
|
|||||||
{
|
{
|
||||||
ssize_t wbytes = 0;
|
ssize_t wbytes = 0;
|
||||||
SSL* ssl = NULL;
|
SSL* ssl = NULL;
|
||||||
if (OB_LIKELY(NULL == (ssl = gs_ssl_array[fd].ssl))) {
|
if (OB_UNLIKELY(fd < 0 || fd > FD_MAX)) {
|
||||||
|
COMMON_LOG(ERROR, "fd is beyond limit", K(fd));
|
||||||
|
wbytes = -1;
|
||||||
|
errno = EINVAL;
|
||||||
|
} else if (OB_LIKELY(NULL == (ssl = gs_ssl_array[fd].ssl))) {
|
||||||
wbytes = write(fd, buf, nbytes);
|
wbytes = write(fd, buf, nbytes);
|
||||||
} else {
|
} else {
|
||||||
if (OB_UNLIKELY(0 == gs_ssl_array[fd].hand_shake_done)) {
|
if (OB_UNLIKELY(0 == gs_ssl_array[fd].hand_shake_done)) {
|
||||||
|
Reference in New Issue
Block a user