This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit fca5b186b172cca83b1059fd1d56088ae1b80170 Author: YAMAMOTO Takashi <yamam...@midokura.com> AuthorDate: Fri Jun 17 15:03:46 2022 +0900 webclient: Make webclient_get_tunnel returns void As it does never fail. --- include/netutils/webclient.h | 4 +- netutils/webclient/webclient.c | 83 ++++++++++++++++++++---------------------- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/include/netutils/webclient.h b/include/netutils/webclient.h index 33aa4ac93..8bd78efce 100644 --- a/include/netutils/webclient.h +++ b/include/netutils/webclient.h @@ -561,8 +561,8 @@ void webclient_set_static_body(FAR struct webclient_context *ctx, size_t bodylen); int webclient_get_poll_info(FAR struct webclient_context *ctx, FAR struct webclient_poll_info *info); -int webclient_get_tunnel(FAR struct webclient_context *ctx, - FAR struct webclient_conn_s **connp); +void webclient_get_tunnel(FAR struct webclient_context *ctx, + FAR struct webclient_conn_s **connp); #undef EXTERN #ifdef __cplusplus diff --git a/netutils/webclient/webclient.c b/netutils/webclient/webclient.c index 1bcdd3817..d2d7ef261 100644 --- a/netutils/webclient/webclient.c +++ b/netutils/webclient/webclient.c @@ -1445,54 +1445,51 @@ int webclient_perform(FAR struct webclient_context *ctx) { FAR struct webclient_conn_s *tunnel_conn; - ret = webclient_get_tunnel(ws->tunnel, &tunnel_conn); - if (ret == 0) + webclient_get_tunnel(ws->tunnel, &tunnel_conn); + DEBUGASSERT(tunnel_conn != NULL); + DEBUGASSERT(!tunnel_conn->tls); + free(ws->tunnel); + ws->tunnel = NULL; + + if (conn->tls) { - DEBUGASSERT(tunnel_conn != NULL); - DEBUGASSERT(!tunnel_conn->tls); - free(ws->tunnel); - ws->tunnel = NULL; + /* Revisit: tunnel_conn here should have + * timeout configured already. + * Configuring it again here is redundant. + */ - if (conn->tls) + ret = tls_ops->init_connection(tls_ctx, + tunnel_conn, + ws->target.hostname, + ctx->timeout_sec, + &conn->tls_conn); + if (ret == 0) { - /* Revisit: tunnel_conn here should have - * timeout configured already. - * Configuring it again here is redundant. + /* Note: tunnel_conn has been consumed by + * tls_ops->init_connection */ - ret = tls_ops->init_connection(tls_ctx, - tunnel_conn, - ws->target.hostname, - ctx->timeout_sec, - &conn->tls_conn); - if (ret == 0) - { - /* Note: tunnel_conn has been consumed by - * tls_ops->init_connection - */ - - ws->need_conn_close = true; - } - else - { - /* Note: restarting tls_ops->init_connection - * is not implemented - */ - - DEBUGASSERT(ret != -EAGAIN && - ret != -EINPROGRESS && - ret != -EALREADY); - conn_close(ctx, tunnel_conn); - free(tunnel_conn); - } + ws->need_conn_close = true; } else { - conn->sockfd = tunnel_conn->sockfd; - ws->need_conn_close = true; + /* Note: restarting tls_ops->init_connection + * is not implemented + */ + + DEBUGASSERT(ret != -EAGAIN && + ret != -EINPROGRESS && + ret != -EALREADY); + conn_close(ctx, tunnel_conn); free(tunnel_conn); } } + else + { + conn->sockfd = tunnel_conn->sockfd; + ws->need_conn_close = true; + free(tunnel_conn); + } } } else if (conn->tls) @@ -2486,16 +2483,16 @@ int webclient_get_poll_info(FAR struct webclient_context *ctx, * the tunneled connection. * * This function should be used exactly once after a successful - * call of webclient_perform with WEBCLIENT_FLAG_TUNNEL. + * call of webclient_perform with WEBCLIENT_FLAG_TUNNEL, with + * http_status 2xx. * * This function also disposes the given webclient_context. - * The context will be invalid after the successful call of this - * function. + * The context will be invalid after a call of this function. * ****************************************************************************/ -int webclient_get_tunnel(FAR struct webclient_context *ctx, - FAR struct webclient_conn_s **connp) +void webclient_get_tunnel(FAR struct webclient_context *ctx, + FAR struct webclient_conn_s **connp) { struct wget_s *ws; struct webclient_conn_s *conn; @@ -2510,6 +2507,4 @@ int webclient_get_tunnel(FAR struct webclient_context *ctx, ws->conn = NULL; free_ws(ws); _SET_STATE(ctx, WEBCLIENT_CONTEXT_STATE_DONE); - - return 0; }