Commit 74c47e9e authored by David Vorick's avatar David Vorick

debug statements if a call doesn't return quickly

parent f7bec9b9
......@@ -4,6 +4,7 @@ import (
"encoding/json"
"net/http"
"strings"
"time"
"github.com/NebulousLabs/Sia/build"
"github.com/NebulousLabs/Sia/modules"
......@@ -123,6 +124,8 @@ func RequirePassword(h httprouter.Handle, password string) httprouter.Handle {
// handler finishes.
func cleanCloseHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Close this file handle either when the function completes or when the
// connection is done.
done := make(chan struct{})
go func(w http.ResponseWriter, r *http.Request) {
defer close(done)
......@@ -132,6 +135,13 @@ func cleanCloseHandler(next http.Handler) http.Handler {
case <-done:
case <-r.Context().Done():
}
// Sanity check - thread should not take more than an hour to return.
select {
case <-done:
case <-time.After(time.Minute * 60):
build.Severe("api call is taking more than 20 minutes to return:", r.URL.Path)
}
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment