From 05c62c3ce51c0d6abdac0a47577546149f692b4f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 30 Apr 2019 11:14:38 +0200 Subject: multi: provide Curl_multiuse_state to update information Primarily to be used by the TLS backends when getting ALPN confirmation about the protocol. --- lib/multi.c | 16 ++++++++++++++++ lib/multiif.h | 3 +++ lib/vtls/cyassl.c | 3 +++ lib/vtls/gtls.c | 4 ++++ lib/vtls/mbedtls.c | 3 +++ lib/vtls/nss.c | 5 ++++- lib/vtls/openssl.c | 4 ++++ lib/vtls/polarssl.c | 5 ++++- lib/vtls/schannel.c | 3 +++ lib/vtls/sectransp.c | 4 ++++ 10 files changed, 48 insertions(+), 2 deletions(-) diff --git a/lib/multi.c b/lib/multi.c index 2d83e734e..41774337f 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -2981,6 +2981,22 @@ size_t Curl_multi_max_total_connections(struct Curl_multi *multi) return multi ? multi->max_total_connections : 0; } +/* + * When information about a connection has appeared, call this! + */ + +void Curl_multiuse_state(struct connectdata *conn, + int bundlestate) /* use BUNDLE_* defines */ +{ + DEBUGASSERT(conn); + DEBUGASSERT(conn->bundle); + DEBUGASSERT(conn->data); + DEBUGASSERT(conn->data->multi); + + conn->bundle->multiuse = bundlestate; + process_pending_handles(conn->data->multi); +} + static void process_pending_handles(struct Curl_multi *multi) { struct curl_llist_element *e = multi->pending.head; diff --git a/lib/multiif.h b/lib/multiif.h index 704145ae0..97f707757 100644 --- a/lib/multiif.h +++ b/lib/multiif.h @@ -82,6 +82,9 @@ size_t Curl_multi_max_total_connections(struct Curl_multi *multi); void Curl_multi_connchanged(struct Curl_multi *multi); +void Curl_multiuse_state(struct connectdata *conn, + int bundlestate); /* use BUNDLE_* defines */ + /* * Curl_multi_closed() * diff --git a/lib/vtls/cyassl.c b/lib/vtls/cyassl.c index c7a3268ef..2fd8f486c 100644 --- a/lib/vtls/cyassl.c +++ b/lib/vtls/cyassl.c @@ -79,6 +79,7 @@ and that's a problem since options.h hasn't been included yet. */ #include "strcase.h" #include "x509asn1.h" #include "curl_printf.h" +#include "multiif.h" #include #include @@ -599,6 +600,8 @@ cyassl_connect_step2(struct connectdata *conn, else infof(data, "ALPN, unrecognized protocol %.*s\n", protocol_len, protocol); + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); } else if(rc == SSL_ALPN_NOT_FOUND) infof(data, "ALPN, server did not agree to a protocol\n"); diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index e224861c4..40e61c701 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -55,6 +55,7 @@ #include "strcase.h" #include "warnless.h" #include "x509asn1.h" +#include "multiif.h" #include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -1449,6 +1450,9 @@ gtls_connect_step3(struct connectdata *conn, } else infof(data, "ALPN, server did not agree to a protocol\n"); + + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); } #endif diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index 27a9402cb..22c22fa78 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -54,6 +54,7 @@ #include "parsedate.h" #include "connect.h" /* for the connect timeout */ #include "select.h" +#include "multiif.h" #include "polarssl_threadlock.h" /* The last 3 #include files should be in this order */ @@ -684,6 +685,8 @@ mbed_connect_step2(struct connectdata *conn, else { infof(data, "ALPN, server did not agree to a protocol\n"); } + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); } #endif diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index 8cb783ada..65e975c91 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2018, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -38,6 +38,7 @@ #include "select.h" #include "vtls.h" #include "llist.h" +#include "multiif.h" #include "curl_printf.h" #include "nssg.h" #include @@ -843,6 +844,8 @@ static void HandshakeCallback(PRFileDesc *sock, void *arg) !memcmp(ALPN_HTTP_1_1, buf, ALPN_HTTP_1_1_LENGTH)) { conn->negnpn = CURL_HTTP_VERSION_1_1; } + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); } } diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 5d2aac7d3..e50f929ef 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -48,6 +48,7 @@ #include "vtls.h" #include "strcase.h" #include "hostcheck.h" +#include "multiif.h" #include "curl_printf.h" #include #include @@ -2917,6 +2918,9 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex) } else infof(data, "ALPN, server did not agree to a protocol\n"); + + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); } #endif diff --git a/lib/vtls/polarssl.c b/lib/vtls/polarssl.c index 6ecabe94b..a059e50ee 100644 --- a/lib/vtls/polarssl.c +++ b/lib/vtls/polarssl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012 - 2018, Daniel Stenberg, , et al. + * Copyright (C) 2012 - 2019, Daniel Stenberg, , et al. * Copyright (C) 2010 - 2011, Hoi-Ho Chan, * * This software is licensed as described in the file COPYING, which @@ -55,6 +55,7 @@ #include "select.h" #include "strcase.h" #include "polarssl_threadlock.h" +#include "multiif.h" #include "curl_printf.h" #include "curl_memory.h" /* The last #include file should be: */ @@ -593,6 +594,8 @@ polarssl_connect_step2(struct connectdata *conn, } else infof(data, "ALPN, server did not agree to a protocol\n"); + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); } #endif diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 39ac080e8..1f036249b 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -58,6 +58,7 @@ #include "warnless.h" #include "x509asn1.h" #include "curl_printf.h" +#include "multiif.h" #include "system_win32.h" /* The last #include file should be: */ @@ -1269,6 +1270,8 @@ schannel_connect_step3(struct connectdata *conn, int sockindex) } else infof(data, "ALPN, server did not agree to a protocol\n"); + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); } #endif diff --git a/lib/vtls/sectransp.c b/lib/vtls/sectransp.c index 971dd78e6..80f38692f 100644 --- a/lib/vtls/sectransp.c +++ b/lib/vtls/sectransp.c @@ -31,6 +31,7 @@ #include "urldata.h" /* for the Curl_easy definition */ #include "curl_base64.h" #include "strtok.h" +#include "multiif.h" #ifdef USE_SECTRANSP @@ -2651,6 +2652,9 @@ sectransp_connect_step2(struct connectdata *conn, int sockindex) else infof(data, "ALPN, server did not agree to a protocol\n"); + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); + /* chosenProtocol is a reference to the string within alpnArr and doesn't need to be freed separately */ if(alpnArr) -- cgit v1.2.1