Skip to content

[Test PR] for upload memory leak#786

Draft
Gautham-coder wants to merge 2 commits intov3.x/stagingfrom
test-mem-leak
Draft

[Test PR] for upload memory leak#786
Gautham-coder wants to merge 2 commits intov3.x/stagingfrom
test-mem-leak

Conversation

@Gautham-coder
Copy link
Copy Markdown
Contributor

@Gautham-coder Gautham-coder commented Jul 23, 2025

`************** Code flow for each chunk write **************

  1. httpHandleTCP()
    https://github.com/zowe/zowe-common-c/blob/c6f577921787ec7489341270dfffd5b0878b7e60/c/httpserver.c#L5829
    - ShortLivedHeap slh = makeShortLivedHeap(READ_BUFFER_SIZE=65536, maxBlocks=1024);
    - peerExtension = makeSocketExtension(.., slh,..)
    - httpConversation = makeHttpConversation(peerExtension,(HttpServer)(module->data));
    -> conversation->parser = makeHttpRequestParser(socketExtension->slh); /
    allocates the parser on the SLH */

  2. httpWorkElementHandler
    case START_RESP

  3. handlePeerSocketRead() ->
    - SocketExtension *peerExtension = extension;
    - HttpConversation conversation = (HttpConversation)extension->protocolHandler;

    1. doHttpReadWork() ->
      - socketRead()
      - processHttpFragment(parser,readBuffer,bytesRead);

      1. processHttpFragment(parser,readBuffer,bytesRead)); ->
        - After processing headers
        https://github.com/zowe/zowe-common-c/blob/8104c38753286bb15579cbb810adb78be51ea8c0/c/httpserver.c#L2330
        - parser->content = SLHAlloc(parser->slh,parser->specifiedContentLength);

        ### Loop -> httpHandleTCP  till all the content is read from the chunk and copied into parser->content, then create the create request below.
        
      2. resetParserAndEnqueue(parser) ->
        https://github.com/zowe/zowe-common-c/blob/8104c38753286bb15579cbb810adb78be51ea8c0/c/httpserver.c#L2343

      3. enqueueLastRequest(parser) ->
        - HttpRequest newRequest = (HttpRequest)SLHAlloc(parser->slh,sizeof(HttpRequest));
        - newRequest->contentBody = copyString(parser->slh, parser->content, parser->specifiedContentLength);

      4. httpWorkElementHandler() ->

        1. doHttpResponseWork() ->
          HttpRequest *firstRequest = dequeueHttpRequest(parser);
          response = makeHttpResponse(firstRequest,parser->slh,conversation->socketExtension->socket);
          - ShortLivedHeap *responseSLH = makeShortLivedHeap(65536,100);
          handleHttpService()

        2. serveRequest() ->

        3. serveUnixFileContents(HttpService *service, HttpResponse *response) ->
          response->request->contentBody

        4. doChunking() -> (if 1st chunk assignSessionID->respondWithSessionID->handlePeerSocketRead)

        5. writeAsciiDataFromBase64() ->

        6. finishResponse() ->

          • SLHFree(response->slh);
    2. doHttpReadWork (BACK HERE)

  4. handlePeerSocketRead() (BACK HERE)
    https://github.com/zowe/zowe-common-c/blob/8104c38753286bb15579cbb810adb78be51ea8c0/c/httpserver.c#L5723

  5. httpWorkElementHandler()
    HTTP_CLOSE_CONVERSATION - SLHFree(sext->slh) This is the SLH allocated in '1'
    https://github.com/zowe/zowe-common-c/blob/c6f577921787ec7489341270dfffd5b0878b7e60/c/httpserver.c#L6215

  6. httpHandleTCP() (BACK HERE)

************** END OF PROCESSING CHUNK **************`

zowe-common-c: zowe/zowe-common-c#540

Signed-off-by: Gautham Kuppuswamy <gkuppuswamy@rocketsoftware.com>
Signed-off-by: Gautham Kuppuswamy <gkuppuswamy@rocketsoftware.com>
@github-actions github-actions Bot added the stale-reopen-if-needed An issue closed due to inactivity. No indication of completion or validity. label Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale-reopen-if-needed An issue closed due to inactivity. No indication of completion or validity.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant