From 9bd63666541a2fb6d571c5bd322d68eb249b80fb Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Fri, 10 May 2024 16:42:33 +0000 Subject: [PATCH 1/6] v2.17.0 Signed-off-by: MarkAckert --- build/configmgr.proj.env | 2 +- build/getesm.proj.env | 2 +- manifest.template.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/configmgr.proj.env b/build/configmgr.proj.env index bbbf917c8..7e741350e 100644 --- a/build/configmgr.proj.env +++ b/build/configmgr.proj.env @@ -1,5 +1,5 @@ PROJECT="configmgr" -VERSION=2.16.0 +VERSION=2.17.0 DEPS="QUICKJS LIBYAML" QUICKJS="quickjs" diff --git a/build/getesm.proj.env b/build/getesm.proj.env index 0f7d7f54d..a47c9045c 100644 --- a/build/getesm.proj.env +++ b/build/getesm.proj.env @@ -1,3 +1,3 @@ PROJECT="getesm" -VERSION=2.16.0 +VERSION=2.17.0 DEPS="" diff --git a/manifest.template.yaml b/manifest.template.yaml index 56a21f1f9..8796bb058 100644 --- a/manifest.template.yaml +++ b/manifest.template.yaml @@ -1,7 +1,7 @@ --- name: zowe-common-c -version: 2.16.0 +version: 2.17.0 homepage: https://zowe.org keywords: From d2d63086b2a43bb93a6edabcc2aa0e9b082bb260 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Fri, 17 May 2024 15:06:36 +0200 Subject: [PATCH 2/6] Return error for wrong file Signed-off-by: Martin Zeithaml --- c/embeddedjs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/c/embeddedjs.c b/c/embeddedjs.c index aad75a32d..bbbb6fac7 100644 --- a/c/embeddedjs.c +++ b/c/embeddedjs.c @@ -626,7 +626,14 @@ static JSValue xplatformLoadFileUTF8(JSContext *ctx, JSValueConst this_val, JS_ToInt32(ctx, &sourceCCSID, argv[1]); buf = (char*)js_load_file(ctx, &length, filename); - + if (!buf) { + size_t filenameNativeLen = strlen(filename); + char filenameNative[filenameNativeLen + 1]; + snprintf(filenameNative, filenameNativeLen + 1, "%.*s", (int)filenameNativeLen, filename); + convertToNative(filenameNative, (int)filenameNativeLen); + perror(filenameNative); + return JS_EXCEPTION; + } if (sourceCCSID < 0){ char *nativeBuffer = safeMalloc(length+1,"xplatformStringFromBytes"); memcpy(nativeBuffer,buf,length); From 37677a60ea4976262390a05b00a62ed2369e1165 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Mon, 20 May 2024 09:42:49 +0200 Subject: [PATCH 3/6] Remove unused vars and error consistent Signed-off-by: Martin Zeithaml --- c/embeddedjs.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/c/embeddedjs.c b/c/embeddedjs.c index bbbb6fac7..e2697fc0d 100644 --- a/c/embeddedjs.c +++ b/c/embeddedjs.c @@ -612,7 +612,6 @@ uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename); /* (filename, ccsid) ccsid -1 implies guess best for platform, 0 implies don't translate */ static JSValue xplatformLoadFileUTF8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv){ - size_t size; size_t length; char *buf; @@ -627,11 +626,6 @@ static JSValue xplatformLoadFileUTF8(JSContext *ctx, JSValueConst this_val, buf = (char*)js_load_file(ctx, &length, filename); if (!buf) { - size_t filenameNativeLen = strlen(filename); - char filenameNative[filenameNativeLen + 1]; - snprintf(filenameNative, filenameNativeLen + 1, "%.*s", (int)filenameNativeLen, filename); - convertToNative(filenameNative, (int)filenameNativeLen); - perror(filenameNative); return JS_EXCEPTION; } if (sourceCCSID < 0){ @@ -685,7 +679,6 @@ static int appendToFile(char *filename, const char *data, int length) { /* (filename, ccsid) ccsid -1 implies guess best for platform, 0 implies don't translate */ static JSValue xplatformAppendFileUTF8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv){ - size_t size; size_t length; NATIVE_STR(filename,nativeFilename,0); @@ -725,7 +718,6 @@ static JSValue xplatformAppendFileUTF8(JSContext *ctx, JSValueConst this_val, /* (filename, ccsid) ccsid -1 implies guess best for platform, 0 implies don't translate */ static JSValue xplatformStoreFileUTF8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv){ - size_t size; size_t length; NATIVE_STR(filename,nativeFilename,0); From 8b37e0536934d0f18dcb281595e815bdef560199 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Mon, 20 May 2024 09:50:42 +0200 Subject: [PATCH 4/6] Changelog note Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d7aa2223..47c6c5f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Zowe Common C Changelog +## `2.17.0` +- Fixed `xplatform.loadFileUTF8` when trying to open nonexistent file (#454) + ## `2.16.0` - No yaml value converted to null (#442) - Added `zos.getZosVersion()` and `zos.getEsm()` calls for configmgr QJS (#429) From 1ecbdb4b3fd0bd28f5a8cf0b78d0f29536a41bfb Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Tue, 7 May 2024 16:48:16 +0200 Subject: [PATCH 5/6] Fix an incorrect check in the recovery router The recovery facility might erroneously free the state cell-pool if an ABEND occurs right after the ESTAEX has been set but before any recovery states with the retry option have been pushed; this issued is caused by an incorrectly coded check in the recovery router code (the check is inverted). The commit fixes the incorrect instruction and adds some code to leave "bread crumbs" when the state cell-pool is deleted. Fixes: #446 Signed-off-by: Irek Fakhrutdinov --- CHANGELOG.md | 2 ++ c/recovery.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c6c5f13..6ac745a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## `2.17.0` - Fixed `xplatform.loadFileUTF8` when trying to open nonexistent file (#454) +- Bugfix: fix an incorrect check in the recovery router code which might lead to + the state cell-pool being released prematurely (#446) ## `2.16.0` - No yaml value converted to null (#442) diff --git a/c/recovery.c b/c/recovery.c index fd1ff5611..2c5da2a0a 100644 --- a/c/recovery.c +++ b/c/recovery.c @@ -497,7 +497,7 @@ static void * __ptr32 getRecoveryRouterAddress() { " LA 1,RCVXINF LOAD ROUTER SERVICE INFO \n" " BRAS 14,RCVSIFLB RECORD IT, REMOVE CONTEXT, PERCOLATE \n" " TM RCXFLAG1,R@CF1USP USER STATE POOL? \n" - " BZ RCVFRL04 NO, DO NOT FREE IT \n" + " BNZ RCVFRL04 NO, DO NOT FREE IT \n" " LT 2,RCXSCPID CELL POOL ZERO? \n" " BZ RCVFRL04 YES, DO NOT FREE IT \n" #ifdef _LP64 @@ -505,6 +505,8 @@ static void * __ptr32 getRecoveryRouterAddress() { " SYSSTATE AMODE64=NO \n" #endif " CPOOL DELETE,CPID=(2) FREE THE STATE CELL POOL \n" + " LGFI 2,X'7FFFFBA3' MAKE AN OBVIOUSLY BAD ADDRESS \n" + " ST 2,RCXSCPID MARK THE CPID FOR DEBUGGING PURPOSES \n" #ifdef _LP64 " SAM64 \n" " SYSSTATE AMODE64=YES \n" @@ -1291,6 +1293,8 @@ RecoveryStatePool *recoveryMakeStatePool(unsigned int stateCount) { void recoveryRemoveStatePool(RecoveryStatePool *statePool) { removeRecoveryStatePool(statePool->cellPool); + // put a bad address for debugging (in case the statePool storage survives) + statePool->cellPool = 0x7FFFFBA1; storageRelease(statePool, sizeof(RecoveryStatePool)); } From 7c0d765ae25e12421839b15cb89736f2c04afbf9 Mon Sep 17 00:00:00 2001 From: Gautham Kuppuswamy Date: Thu, 30 May 2024 04:12:55 -0400 Subject: [PATCH 6/6] Allocate SLH blocks for httpserver with configure value, else default value. Signed-off-by: Gautham Kuppuswamy --- CHANGELOG.md | 1 + c/httpserver.c | 7 ++++++- h/httpserver.h | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ac745a0c..48b28cf58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed `xplatform.loadFileUTF8` when trying to open nonexistent file (#454) - Bugfix: fix an incorrect check in the recovery router code which might lead to the state cell-pool being released prematurely (#446) +- Allocating SLH for http server with configurable value 'httpRequestHeapMaxBlocks' in yaml (#447). ## `2.16.0` - No yaml value converted to null (#442) diff --git a/c/httpserver.c b/c/httpserver.c index d94875de0..c3cf7d9c5 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -1564,6 +1564,7 @@ HttpServer *makeHttpServerInner(STCBase *base, memcpy(&server->config->sessionTokenKey[0], &sessionTokenKey, sizeof (sessionTokenKey)); server->config->authTokenType = SERVICE_AUTH_TOKEN_TYPE_LEGACY; + server->config->httpRequestHeapMaxBlocks = HTTP_REQUEST_HEAP_DEFAULT_BLOCKS; return server; } @@ -1656,6 +1657,8 @@ static HttpServer *makeSecureHttpServerInner(STCBase *base, int port, int64 now = getFineGrainedTime(); server->config->sessionTokenKeySize = sizeof (now); memcpy(&server->config->sessionTokenKey[0], &now, sizeof (now)); + server->config->httpRequestHeapMaxBlocks = HTTP_REQUEST_HEAP_DEFAULT_BLOCKS; + return server; } #endif @@ -5821,7 +5824,9 @@ static int httpHandleTCP(STCBase *base, } } #endif // USE_ZOWE_TLS - ShortLivedHeap *slh = makeShortLivedHeap(READ_BUFFER_SIZE,100); + HttpServer *server = (HttpServer*) module->data; + unsigned int maxBlocks = server->config->httpRequestHeapMaxBlocks; + ShortLivedHeap *slh = makeShortLivedHeap(READ_BUFFER_SIZE, maxBlocks); #ifndef __ZOWE_OS_WINDOWS int writeBufferSize = 0x40000; setSocketWriteBufferSize(peerSocket,0x40000, &returnCode, &reasonCode); diff --git a/h/httpserver.h b/h/httpserver.h index 09f0d2de0..2cbbd6610 100644 --- a/h/httpserver.h +++ b/h/httpserver.h @@ -64,6 +64,10 @@ #define HTTP_SERVER_PRIVILEGED_SERVER_PROPERTY "zisServerName" +#define HTTP_REQUEST_HEAP_DEFAULT_BLOCKS 1024 +#define HTTP_REQUEST_HEAP_MIN_BLOCKS 100 +#define HTTP_REQUEST_HEAP_MAX_BLOCKS 4096 + typedef struct BigBuffer_tag{ ShortLivedHeap *slh; /* can be null */ char *data; @@ -220,6 +224,7 @@ typedef struct HTTPServerConfig_tag { hashtable *userTimeouts; hashtable *groupTimeouts; int defaultTimeout; + unsigned int httpRequestHeapMaxBlocks; /* The config manager is optional, but zss and other servers need a near-global way to get configuration data. */