Skip to content

Commit 0eb280f

Browse files
committed
Sync http handler
1 parent e05e363 commit 0eb280f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

std/http/http_native.go

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"os"
99
"strings"
10+
"sync"
1011

1112
. "github.com/candid82/joker/core"
1213
)
@@ -144,8 +145,11 @@ func startServer(addr string, handler Callable) Object {
144145
host = MakeString(addr[:i])
145146
port = MakeString(addr[i+1:])
146147
}
148+
var mutex sync.Mutex
147149
err := http.ListenAndServe(addr, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
150+
mutex.Lock()
148151
defer func() {
152+
mutex.Unlock()
149153
if r := recover(); r != nil {
150154
w.WriteHeader(500)
151155
io.WriteString(w, "Internal server error")

0 commit comments

Comments
 (0)