no need to use BIO; seg. fault avoided.
authorMarcel Poul <marcel.poul@cern.ch>
Wed, 11 Jan 2012 16:41:25 +0000 (16:41 +0000)
committerMarcel Poul <marcel.poul@cern.ch>
Wed, 11 Jan 2012 16:41:25 +0000 (16:41 +0000)
emi.canl.canl-c/src/canl.c
emi.canl.canl-c/src/canl_locl.h
emi.canl.canl-c/src/canl_ssl.c

index 010641a..451583b 100644 (file)
@@ -285,17 +285,12 @@ int canl_io_close(canl_ctx cc, canl_io_handler io)
 static void io_destroy(glb_ctx *cc, io_handler *io)
 {
     io_handler *io_cc = (io_handler*) io;
-    int err = 0;
 
     if (io_cc->s_ctx) {
         if (io_cc->s_ctx->ssl_io) {
             SSL_free(io_cc->s_ctx->ssl_io);
             io_cc->s_ctx->ssl_io = NULL;
         }
-        if (io_cc->s_ctx->bio_conn) {
-            err = BIO_free(io_cc->s_ctx->bio_conn);
-            io_cc->s_ctx->bio_conn = NULL;
-        }
     }
     free (io_cc->s_ctx);
     io_cc->s_ctx = NULL;
index e9a0c02..c39642b 100644 (file)
@@ -66,7 +66,6 @@ typedef struct _glb_ctx
 typedef struct _ossl_ctx
 {
     SSL *ssl_io;
-    BIO *bio_conn;
 } ossl_ctx;
 
 typedef struct _asyn_result {
index 5801cf0..22267ab 100644 (file)
@@ -237,14 +237,9 @@ int ssl_connect(glb_ctx *cc, io_handler *io, struct timeval *timeout)
     flags = fcntl(io->sock, F_GETFL, 0);
     (void)fcntl(io->sock, F_SETFL, flags | O_NONBLOCK);
 
-    io->s_ctx->bio_conn = BIO_new_socket(io->sock, BIO_NOCLOSE);
-    (void)BIO_set_nbio(io->s_ctx->bio_conn,1);
-
     io->s_ctx->ssl_io = SSL_new(cc->ssl_ctx);
     //setup_SSL_proxy_handler(cc->ssl_ctx, cacertdir);
-    SSL_set_bio(io->s_ctx->ssl_io, io->s_ctx->bio_conn, io->s_ctx->bio_conn);
-
-    io->s_ctx->bio_conn = NULL;
+    SSL_set_fd(io->s_ctx->ssl_io, io->sock);
 
     err = do_ssl_connect(cc, io, timeout); 
     if (err) {
@@ -278,13 +273,9 @@ int ssl_accept(glb_ctx *cc, io_handler *io,
     flags = fcntl(io->sock, F_GETFL, 0);
     (void)fcntl(io->sock, F_SETFL, flags | O_NONBLOCK);
 
-    io->s_ctx->bio_conn = BIO_new_socket(io->sock, BIO_NOCLOSE);
-    (void)BIO_set_nbio(io->s_ctx->bio_conn,1);
-
     io->s_ctx->ssl_io = SSL_new(cc->ssl_ctx);
     //setup_SSL_proxy_handler(cc->ssl_ctx, cacertdir);
-    SSL_set_bio(io->s_ctx->ssl_io, io->s_ctx->bio_conn, 
-            io->s_ctx->bio_conn);
+    SSL_set_fd(io->s_ctx->ssl_io, io->sock);
 
     err = do_ssl_accept(cc, io, timeout);
         if (err) {