From aece0e33c240dda8d359293b40727c00230f4a89 Mon Sep 17 00:00:00 2001 From: tsauerbeck Date: Mon, 12 Apr 2004 19:29:37 +0000 Subject: [PATCH] only call SSL_get_error() if the previous SSL call failed SVN revision: 9712 --- legacy/ecore/src/lib/ecore_con/ecore_con.c | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c index 5366a1f138..4499777ea7 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c @@ -717,12 +717,12 @@ static int svr_try_connect_ssl(Ecore_Con_Server *svr) assert(svr->connecting); assert(svr->ssl); - res = SSL_connect(svr->ssl); - ssl_err = SSL_get_error(svr->ssl, res); - - if (ssl_err == SSL_ERROR_NONE) + if ((res = SSL_connect(svr->ssl)) == 1) return 1; + ssl_err = SSL_get_error(svr->ssl, res); + assert (ssl_err != SSL_ERROR_NONE); + if (ssl_err == SSL_ERROR_WANT_READ) flag = ECORE_FD_READ; else if (ssl_err == SSL_ERROR_WANT_WRITE) @@ -782,7 +782,7 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler) { Ecore_Con_Server *svr; #if USE_OPENSSL - int ssl_err = 0; + int ssl_err = SSL_ERROR_NONE; #endif svr = data; @@ -812,8 +812,12 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler) #if USE_OPENSSL } else { num = SSL_read(svr->ssl, svr->read_buf, READBUFSIZ); - ssl_err = SSL_get_error(svr->ssl, num); - lost_server = (ssl_err == SSL_ERROR_ZERO_RETURN); + + if (num < 1) { + ssl_err = SSL_get_error(svr->ssl, num); + lost_server = (ssl_err == SSL_ERROR_ZERO_RETURN); + } else + ssl_err = SSL_ERROR_NONE; } #endif if (num < 1) @@ -958,7 +962,7 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) { int count, num, lost_server = 0; #if USE_OPENSSL - int ssl_err; + int ssl_err = SSL_ERROR_NONE; #endif if (!svr->write_buf) return; @@ -984,8 +988,11 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) #if USE_OPENSSL } else { count = SSL_write(svr->ssl, svr->write_buf + svr->write_buf_offset, num); - ssl_err = SSL_get_error(svr->ssl, count); - lost_server = (ssl_err == SSL_ERROR_ZERO_RETURN); + + if (count < 1) { + ssl_err = SSL_get_error(svr->ssl, count); + lost_server = (ssl_err == SSL_ERROR_ZERO_RETURN); + } } #endif -- 2.34.1