diff options
| author | Shulhan <ms@kilabit.info> | 2023-12-22 03:07:29 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-12-22 03:09:46 +0700 |
| commit | eb5868459b9053df3499417653e4ca432907afb4 (patch) | |
| tree | d0cafbdeef9da157f2e39c02f7ebb08f3792ccc5 /http_server.go | |
| parent | 65c66728904a8a26fa8593cfe6a7d39e45c0ef1f (diff) | |
| download | awwan-eb5868459b9053df3499417653e4ca432907afb4.tar.xz | |
all: delete the execution response and context cancellation on finished
Once the ExecResponse EndAt is not empty or event queue has been closed,
clear the map that store the execution response and context cancellation
to minimize resources usage.
Diffstat (limited to 'http_server.go')
| -rw-r--r-- | http_server.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/http_server.go b/http_server.go index 2a01332..8a61ce8 100644 --- a/http_server.go +++ b/http_server.go @@ -845,20 +845,21 @@ func (httpd *httpServer) ExecuteTail(sseconn *libhttp.SSEConn) { } execRes.mtxOutput.Unlock() + var ( + ok = true + + ev sseclient.Event + evid int64 + ) + if len(execRes.EndAt) != 0 { // The execution has been completed. sseconn.WriteEvent(`end`, execRes.EndAt, nil) - return + goto out } // And wait for the rest... - var ( - ok = true - - ev sseclient.Event - evid int64 - ) for { ev, ok = <-execRes.eventq if !ok { @@ -877,4 +878,7 @@ func (httpd *httpServer) ExecuteTail(sseconn *libhttp.SSEConn) { } sseconn.WriteEvent(ev.Type, ev.Data, &ev.ID) } +out: + delete(httpd.idExecRes, execID) + delete(httpd.idContextCancel, execID) } |
