From 559f2814d1a2fd56a2679991ff6209ad4c23f9e7 Mon Sep 17 00:00:00 2001 From: Gautham Kuppuswamy Date: Tue, 27 Aug 2024 15:27:16 -0400 Subject: [PATCH] Adding an extra argument to httpClientSessionInit to return rc and changing api version Signed-off-by: Gautham Kuppuswamy --- CHANGELOG.md | 3 +++ c/httpclient.c | 16 +++++++++------- c/qjsnet.c | 3 ++- h/httpclient.h | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0fe357cf..224e2bbec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Zowe Common C Changelog +## `2.19.0` +- Adding more arguments to httpClientSessionInit to allow passing back rc (#467). + ## `2.18.1` - Bugfix: IARV64 results must be checked for 0x7FFFF000 (#474) - Bugfix: SLH should not ABEND when MEMLIMIT is reached (additional NULL check) diff --git a/c/httpclient.c b/c/httpclient.c index 3d2c40f3c..172154897 100644 --- a/c/httpclient.c +++ b/c/httpclient.c @@ -647,12 +647,14 @@ void httpClientSessionDestroy(HttpClientSession *session) { /** * After this call, an stcbase'd caller should 'register' the socket */ -int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession) { +int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSession, int *rc) { int sts = 0; - int bpxrc = 0, bpxrsn = 0; + int bpxrsn = 0; + int *bpxrc = rc; HttpClientSession *session = NULL; ShortLivedHeap *slh = NULL; + *bpxrc = 0; do { if ((NULL == ctx) || (NULL == outSession)) { @@ -660,13 +662,13 @@ int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession break; } - Socket *socket = tcpClient2(ctx->serverAddress, 1000 * ctx->recvTimeoutSeconds, &bpxrc, &bpxrsn); - if ((bpxrc != 0) || (NULL == socket)) { + Socket *socket = tcpClient2(ctx->serverAddress, 1000 * ctx->recvTimeoutSeconds, bpxrc, &bpxrsn); + if ((*bpxrc != 0) || (NULL == socket)) { #ifdef __ZOWE_OS_ZOS - HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, bpxrc, + HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, *bpxrc, bpxrsn, ctx->serverAddress->v4Address, ctx->serverAddress->port); #else - HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, bpxrc, + HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, *bpxrc, bpxrsn, ctx->serverAddress->internalAddress.v4Address, ctx->serverAddress->port); #endif sts = HTTP_CLIENT_CONNECT_FAILED; @@ -684,7 +686,7 @@ int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession int rc = tlsSocketInit(ctx->tlsEnvironment, &socket->tlsSocket, socket->sd, false); if (rc != 0) { HTTP_CLIENT_TRACE_VERBOSE("failed to init tls socket, rc=%d, (%s)", rc, tlsStrError(rc)); - socketClose(socket, &bpxrc, &bpxrsn); + socketClose(socket, bpxrc, &bpxrsn); sts = HTTP_CLIENT_TLS_ERROR; break; } diff --git a/c/qjsnet.c b/c/qjsnet.c index ac2fcfbc0..3235801be 100644 --- a/c/qjsnet.c +++ b/c/qjsnet.c @@ -189,6 +189,7 @@ static int httpGet(bool isTLS, int status = 0; char buffer[2048]; LoggingContext *loggingContext = getLoggingContext(); + int rc = 0; do{ clientSettings.host = host; @@ -216,7 +217,7 @@ static int httpGet(bool isTLS, if (httpTrace){ printf("successfully initialized http client\n"); } - status = httpClientSessionInit(httpClientContext, &session); + status = httpClientSessionInit2(httpClientContext, &session, &rc); if (status){ if (httpTrace){ printf("error initing session: %d\n", status); diff --git a/h/httpclient.h b/h/httpclient.h index 937caa261..61c76c759 100644 --- a/h/httpclient.h +++ b/h/httpclient.h @@ -121,7 +121,7 @@ int httpClientContextInitSecure(HttpClientSettings *settings, void httpClientSessionDestroy(HttpClientSession *session); -int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession); +int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSession, int rc); int httpClientSessionStageRequest(HttpClientContext *ctx, HttpClientSession *session,