From 1dbe04519c13e27f6efc3d0787942f4d91832e0a Mon Sep 17 00:00:00 2001 From: Marcel Poul Date: Tue, 6 Dec 2011 10:33:23 +0000 Subject: [PATCH] #ifdef DEBUG; set_error() instead of update_error() where necessary; --- emi.canl.canl-c/src/canl.c | 17 +++++++++-------- emi.canl.canl-c/src/canl_ssl.c | 11 ++++++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/emi.canl.canl-c/src/canl.c b/emi.canl.canl-c/src/canl.c index 5af587f..a943e31 100644 --- a/emi.canl.canl-c/src/canl.c +++ b/emi.canl.canl-c/src/canl.c @@ -211,7 +211,7 @@ end: return err; } -/*TODO select + timeout, EINTR!!!, remember peer IP and other info */ +/*TODO select + timeout, EINTR!!! */ int canl_io_accept(canl_ctx cc, canl_io_handler io, int port, int flags, cred_handler ch, struct timeval *timeout, canl_io_handler *new_io) @@ -277,29 +277,32 @@ int canl_io_accept(canl_ctx cc, canl_io_handler io, int port, } if (p == NULL) { - update_error(glb_cc, "failed to bind (canl_io_accept)"); //TODO is it there????? + set_error(glb_cc, 0, unknown_error, "failed to bind (canl_io_accept)"); //TODO error_type freeaddrinfo(servinfo); // all done with this structure - goto end; + return -1; } freeaddrinfo(servinfo); // all done with this structure if ((err = listen(sockfd, BACKLOG))) { err = errno; - goto end; + set_error(glb_cc, err, posix_error, "listen() failed (canl_io_accept)"); + return err; } /*wait for client*/ +#ifdef DEBUG printf("server: waiting for connections...\n"); +#endif sin_size = sizeof((*io_new_cc)->s_addr); new_fd = accept(sockfd, (*io_new_cc)->s_addr, &sin_size); if (new_fd == -1){ err = errno; - goto end; + set_error(glb_cc, err, posix_error, "accept() failed (canl_io_accept)"); + return err; } else (*io_new_cc)->sock = new_fd; - /* TODO everything fine - set new_io_cc according to their_addr*/ /*call openssl */ err = ssl_server_init(glb_cc, *io_new_cc); @@ -343,8 +346,6 @@ static void io_destroy(glb_ctx *cc, io_handler *io) io_handler *io_cc = (io_handler*) io; glb_ctx *glb_cc = (glb_ctx*) cc; int err = 0; - unsigned long ssl_err; - CANL_ERROR_ORIGIN e_orig = unknown_error; // delete io_handler content if (io_cc->ar) { diff --git a/emi.canl.canl-c/src/canl_ssl.c b/emi.canl.canl-c/src/canl_ssl.c index e7dac2c..3052d4b 100644 --- a/emi.canl.canl-c/src/canl_ssl.c +++ b/emi.canl.canl-c/src/canl_ssl.c @@ -6,9 +6,9 @@ static int do_ssl_connect( glb_ctx *cc, io_handler *io, struct timeval *timeout); static int do_ssl_accept( glb_ctx *cc, io_handler *io, struct timeval *timeout); - +#ifdef DEBUG static void dbg_print_ssl_error(int errorcode); - +#endif int ssl_server_init(glb_ctx *cc, io_handler *io) { int err = 0; @@ -415,7 +415,9 @@ static int do_ssl_accept( glb_ctx *cc, io_handler *io, struct timeval *timeout) expected = errorcode = SSL_get_error(io->s_ctx->ssl_io, ret2); } curtime = time(NULL); +#ifdef DEBUG dbg_print_ssl_error(errorcode); +#endif } while (ret > 0 && (ret2 <= 0 && ((locl_timeout == -1) || ((locl_timeout != -1) && (curtime - starttime) < locl_timeout)) && @@ -659,7 +661,7 @@ int ssl_close(glb_ctx *cc, io_handler *io) return -1; } } - +#ifdef DEBUG static void dbg_print_ssl_error(int errorcode) { printf("[DBG CANL] "); @@ -696,5 +698,4 @@ static void dbg_print_ssl_error(int errorcode) break; } } - - +#endif -- 1.8.2.3