Fixed hanging of OpenSSL due to nested xioclose()

This commit is contained in:
Gerhard Rieger 2024-06-23 20:47:12 +02:00
parent d16f1fe125
commit fdddba24b8
2 changed files with 12 additions and 2 deletions

View file

@ -4,6 +4,9 @@ Corrections:
Thanks to Kush Upadhyay from Amazon Bottlerocket team for providing the
patch.
In some situations xioclose() was called nested what could cause hanging
of OpenSSL in pthread_rwlock_wrlock()
Features:
Total inactivity timeout option -T 0 now means 0.0 seconds; up to
version 1.8.0.0 it meant no total inactivity timeout.

View file

@ -23,6 +23,11 @@ int xioclose1(struct single *pipe) {
return -1;
}
if (pipe->tag == XIO_TAG_CLOSED) {
return 0;
}
pipe->tag |= XIO_TAG_CLOSED;
#if WITH_READLINE
if ((pipe->dtype & XIODATA_MASK) == XIODATA_READLINE) {
Write_history(pipe->para.readline.history_file);
@ -112,7 +117,6 @@ int xioclose1(struct single *pipe) {
free(pipe->unlink_close);
}
pipe->tag |= XIO_TAG_CLOSED;
return 0; /*! */
}
@ -126,11 +130,14 @@ int xioclose(xiofile_t *file) {
errno = EINVAL;
return -1;
}
if (file->tag == XIO_TAG_CLOSED) {
return 0;
}
if (file->tag == XIO_TAG_DUAL) {
file->tag |= XIO_TAG_CLOSED;
result = xioclose1(file->dual.stream[0]);
result |= xioclose1(file->dual.stream[1]);
file->tag |= XIO_TAG_CLOSED;
} else {
result = xioclose1(&file->stream);
}