From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from integral2.. (unknown [125.160.108.65]) by gnuweeb.org (Postfix) with ESMTPSA id 3A3FE7F912; Sun, 26 Jun 2022 05:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656223004; bh=xThYFCeiN7swvOv74etLokWSsJ9nmqGysFBvbbfb92w=; h=From:To:Cc:Subject:Date:From; b=hZIjBa6xxpjBRZ2xudCTTHIaaM5BXfnTmO+Ln1Wo6AjN6EdMoR1IR+i5Gu4H4ykjw bw7GS367AnjPE5kSnaJzbaTGjn5FZMeVcxZvAMFMydxBexaobgUBkW0+F0jHo+jdAl UnidlwIH52LlohKbam1YTd752yBI5E64pzVJJ7Pwj1FfwJ0wbt+ZtpSj2UELxxq5a7 44UtTrsoop6jxgmynYLLdgft564yvKHG91YiicFpO6vQk2GryV2JK1EU8U6Ir29FCL H457l0qHT2gINusqHpuTVMRTIoyHuzHgFoS27ddv7gksyJhTj+96QNAgDUXEAQiB+8 E5RQdx67x8PSg== From: Ammar Faizi To: GNU/Weeb Mailing List Cc: Ammar Faizi , Arthur Lapz , Sprite , Yonle Subject: [PATCH gwhttpd 0/7] gwhttpd updates Date: Sun, 26 Jun 2022 12:56:27 +0700 Message-Id: <20220626055634.676175-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Hi, This series contains gwhttpd refactoring and updates. I am going to add directory traversing support feature, but before that, several cleanups need to get done. And here it is... Summary below... ## Patch 1 Don't continue executing the next line if we fail to parse the HTTP header, that's the wrong path, we should stop the client early. ## Patch 2 This mlock is just optional, don't bother showing error. ## Patch 3 Let the caller close the connection, we need to have more decisions in the caller rather than closing it directly. ## Patch 4 Print a log message that we are interrupted, this makes the app user friendly because the user can explicitly see from the output that the app is interrupted. ## Patch 5 The HTTP header parser was prone and doesn't handle many edge cases. This is a full refactor of HTTP header parser. While in there, add more HTTP method supports. ## Patch 6 When we fail to send() due to EAGAIN, we retry the send(). However, if we are spinning on this retry for so long, this will eat CPU cycle and slow down the entire application. We should stop retrying at some point. Add a loop counter and return -ENETDOWN if we are failing too many times in the send() retry loop cycle. ## Patch 7 A patch for Makefile. Add a command to clean the binary file. Signed-off-by: Ammar Faizi --- Ammar Faizi (7): gwhttpd: Do an early return when parse_http_header fails gwhttpd: Don't print any error when mlock fails gwhttpd: Replace `send_error_and_close` with `send_http_error()` gwhttpd: Add log in the interrupt handler gwhttpd: Refactor HTTP header parser gwhttpd: Avoid endless busy spinning on `send()` Makefile: Add "make clean" command Makefile | 3 + gwhttpd.cpp | 220 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 161 insertions(+), 62 deletions(-) base-commit: 944b77d9aaac4a88729da6ec2f76447a9c3562ab -- Ammar Faizi