]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl_sock: implement and use prepare_srv()/destroy_srv()
authorWilly Tarreau <w@1wt.eu>
Thu, 22 Dec 2016 20:16:08 +0000 (21:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Dec 2016 22:26:38 +0000 (23:26 +0100)
Now we can simply check the transport layer at run time and decide
whether or not to initialize or destroy these entries. This removes
other ifdefs and includes from cfgparse.c, haproxy.c and hlua.c.

src/cfgparse.c
src/haproxy.c
src/hlua.c
src/ssl_sock.c

index 97adb9f2fd4c1241822517634796440a350b7e78..2f75c16605ba544b66077e888a1780155ef60471 100644 (file)
 #include <proto/task.h>
 #include <proto/tcp_rules.h>
 
-#ifdef USE_OPENSSL
-#include <types/ssl_sock.h>
-#include <proto/ssl_sock.h>
-#include <proto/shctx.h>
-#endif /*USE_OPENSSL */
 
 /* This is the SSLv3 CLIENT HELLO packet used in conjunction with the
  * ssl-hello-chk option to ensure that the remote server speaks SSL.
@@ -8286,10 +8281,11 @@ out_uri_auth_compat:
                                newsrv->minconn = newsrv->maxconn;
                        }
 
-#ifdef USE_OPENSSL
-                       if (newsrv->use_ssl || newsrv->check.use_ssl)
-                               cfgerr += ssl_sock_prepare_srv_ctx(newsrv);
-#endif /* USE_OPENSSL */
+                       /* this will also properly set the transport layer for prod and checks */
+                       if (newsrv->use_ssl || newsrv->check.use_ssl) {
+                               if (xprt_get(XPRT_SSL) && xprt_get(XPRT_SSL)->prepare_srv)
+                                       cfgerr += xprt_get(XPRT_SSL)->prepare_srv(newsrv);
+                       }
 
                        /* set the check type on the server */
                        newsrv->check.type = curproxy->options2 & PR_O2_CHK_ANY;
index adffda92405e9a6a4d8079ef8a5f7a86f1d1debf..611371ca24af474ccf96a9d4101d80aaddff5933 100644 (file)
@@ -1446,10 +1446,11 @@ static void deinit(void)
                        free(s->agent.bo);
                        free(s->agent.send_string);
                        free((char*)s->conf.file);
-#ifdef USE_OPENSSL
-                       if (s->use_ssl || s->check.use_ssl)
-                               ssl_sock_free_srv_ctx(s);
-#endif
+
+                       if (s->use_ssl || s->check.use_ssl) {
+                               if (xprt_get(XPRT_SSL) && xprt_get(XPRT_SSL)->destroy_srv)
+                                       xprt_get(XPRT_SSL)->destroy_srv(s);
+                       }
                        free(s);
                        s = s_next;
                }/* end while(s) */
index 0ed8ec99f3f105d3d0669fe6799afc30dab40b1c..c343a7b39e696734d0ce27e0219da1db9f79e5c6 100644 (file)
@@ -48,7 +48,6 @@
 #include <proto/server.h>
 #include <proto/session.h>
 #include <proto/stream.h>
-#include <proto/ssl_sock.h>
 #include <proto/stream_interface.h>
 #include <proto/task.h>
 #include <proto/tcp_rules.h>
@@ -7697,7 +7696,8 @@ void hlua_init(void)
        }
 
        /* Initialize SSL server. */
-       ssl_sock_prepare_srv_ctx(&socket_ssl);
+       if (socket_ssl.xprt->prepare_srv)
+               socket_ssl.xprt->prepare_srv(&socket_ssl);
 #endif
 
        RESET_SAFE_LJMP(gL.T);
index f5d4920a9d003d31b011630217ec85b0cab6b8d4..b39f3264e1386ae34589adc977127dac4ca35bbe 100644 (file)
@@ -6660,6 +6660,8 @@ static struct xprt_ops ssl_sock = {
        .init     = ssl_sock_init,
        .prepare_bind_conf = ssl_sock_prepare_bind_conf,
        .destroy_bind_conf = ssl_sock_destroy_bind_conf,
+       .prepare_srv = ssl_sock_prepare_srv_ctx,
+       .destroy_srv = ssl_sock_free_srv_ctx,
        .name     = "SSL",
 };