Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning internal return code through function argument for 'httpClientSessionInit' #469

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
16 changes: 9 additions & 7 deletions c/httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,26 +647,28 @@ 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)) {
sts = HTTP_CLIENT_INVALID_ARGUMENT;
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;
Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion c/qjsnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion h/httpclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading