Browse Source

fix error handling on SSL handles

release0.1.5
Georg Hopp 12 years ago
parent
commit
6003df221e
  1. 5
      src/stream/read.c
  2. 28
      src/stream/write.c

5
src/stream/read.c

@ -20,12 +20,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <unistd.h>
#include <errno.h>
#include <openssl/err.h>
#include "stream.h"
#include "logger.h"
@ -67,7 +66,7 @@ streamRead(Stream this, void * buf, size_t count)
case STREAM_SSL:
done = SSL_read((this->handle).ssl, buf, count);
if (0 > done) {
if (0 >= done) {
switch (SSL_get_error((this->handle).ssl, done)) {
case SSL_ERROR_SSL:
case SSL_ERROR_SYSCALL:

28
src/stream/write.c

@ -20,11 +20,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <unistd.h>
#include <errno.h>
#include "stream.h"
#include "logger.h"
extern Logger logger;
ssize_t
streamWrite(Stream this, void * buf, size_t count)
@ -59,6 +64,29 @@ streamWrite(Stream this, void * buf, size_t count)
case STREAM_SSL:
done = SSL_write((this->handle).ssl, buf, count);
if (0 >= done) {
switch (SSL_get_error((this->handle).ssl, done)) {
case SSL_ERROR_SSL:
case SSL_ERROR_SYSCALL:
{
unsigned long err;
while (0 != (err = ERR_get_error())) {
loggerLog(
logger,
LOGGER_DEBUG,
ERR_error_string(err, NULL));
}
}
// DROP THROUGH
case SSL_ERROR_ZERO_RETURN:
done = -2;
break;
}
}
break;
default:

Loading…
Cancel
Save