s->base.recvPos,
needed);
}
- TCPSOCKLOG(3, s, ("need\t%d\trecv\t%d\tremain\t%d\n", needed, recvd,
- needed - recvd));
-
+ /*
+ * Do NOT make any system call directly or indirectly here
+ * unless you can preserve the system error number
+ */
if (recvd > 0) {
+ TCPSOCKLOG(3, s, ("need\t%d\trecv\t%d\tremain\t%d\n", needed, recvd,
+ needed - recvd));
s->sslConnected = TRUE;
s->base.recvPos += recvd;
if (AsyncSocketCheckAndDispatchRecv(&s->base, &result)) {
sent = SSL_Write(s->sslSock,
(uint8 *) head->buf + s->sendPos, left);
-
- TCPSOCKLOG(3, s, ("left\t%d\tsent\t%d\tremain\t%d\n",
- left, sent, left - sent));
+ /*
+ * Do NOT make any system call directly or indirectly here
+ * unless you can preserve the system error number
+ */
if (sent > 0) {
+ TCPSOCKLOG(3, s, ("left\t%d\tsent\t%d\tremain\t%d\n",
+ left, sent, left - sent));
s->sendBufFull = FALSE;
s->sslConnected = TRUE;
if ((s->sendPos += sent) == sizeToSend) {
#include <openssl/rand.h>
#include <openssl/engine.h>
-#define SSL_LOG(x) Debug x
+#define SSL_LOG(x) WITH_ERRNO(_e, Debug x)
struct SSLSockStruct {
SSL *sslCnx;
}
if (ssl->encrypted) {
- int result = SSL_read(ssl->sslCnx, buf, (int)num);
+ int result;
+
+ /*
+ * Need to clear the thread error queue before calling SSL_xxx function
+ * See bug 1982292 and man SSL_get_error(3) for details.
+ */
+ ERR_clear_error();
+ result = SSL_read(ssl->sslCnx, buf, (int)num);
ssl->sslIOError = SSLSetErrorState(ssl->sslCnx, result);
if (ssl->sslIOError != SSL_ERROR_NONE) {
return SSL_Read(ssl, buf, num);
#else
if (ssl->encrypted) {
- int result = SSL_read(ssl->sslCnx, buf, (int)num);
+ int result;
+
+ ERR_clear_error();
+ result = SSL_read(ssl->sslCnx, buf, (int)num);
ssl->sslIOError = SSLSetErrorState(ssl->sslCnx, result);
if (ssl->sslIOError != SSL_ERROR_NONE) {
goto end;
}
if (ssl->encrypted) {
- int result = SSL_write(ssl->sslCnx, buf, (int)num);
+ int result;
+
+ ERR_clear_error();
+ result = SSL_write(ssl->sslCnx, buf, (int)num);
ssl->sslIOError = SSLSetErrorState(ssl->sslCnx, result);
if (ssl->sslIOError != SSL_ERROR_NONE) {