dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 99a6722347a698354b791087f1fa2072608dc49c
parent bb4e5741a722ac816cff51a681d05bed0c2257d8
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 23 May 2023 20:21:39 -0700

Revert "simplify code"

This reverts commit 77a9d9361b2100bb676528f85400e033826eef98.

Diffstat:
Mpkg/web/handlers/handlers.go | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -29,6 +29,7 @@ import ( "net/http" "net/url" "os" + "os/signal" "path/filepath" "regexp" "sort" @@ -4799,16 +4800,28 @@ func ChessGameHandler(c echo.Context) error { } quit := make(chan bool) + quit1 := make(chan bool) // Listen to the closing of HTTP connection via CloseNotifier notify := c.Request().Context().Done() utils.SGo(func() { select { case <-notify: + case <-quit1: } close(quit) }) + notify1 := make(chan os.Signal) + signal.Notify(notify1, os.Interrupt) + utils.SGo(func() { + select { + case <-notify1: + case <-quit: + } + close(quit1) + }) + c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8) c.Response().WriteHeader(http.StatusOK) c.Response().Header().Set("Transfer-Encoding", "chunked") @@ -4836,6 +4849,8 @@ Loop: select { case <-quit: break Loop + case <-quit1: + break Loop default: } @@ -4900,16 +4915,28 @@ func ChatStreamMessagesHandler(c echo.Context) error { } quit := make(chan bool) + quit1 := make(chan bool) // Listen to the closing of HTTP connection via CloseNotifier notify := c.Request().Context().Done() utils.SGo(func() { select { case <-notify: + case <-quit1: } close(quit) }) + notify1 := make(chan os.Signal) + signal.Notify(notify1, os.Interrupt) + utils.SGo(func() { + select { + case <-notify1: + case <-quit: + } + close(quit1) + }) + c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8) c.Response().WriteHeader(http.StatusOK) c.Response().Header().Set("Transfer-Encoding", "chunked") @@ -4960,6 +4987,8 @@ Loop: select { case <-quit: break Loop + case <-quit1: + break Loop default: }