"net/http"
"os"
"regexp"
- "runtime"
"strconv"
"strings"
"syscall"
}
func PutBlockHandler(resp http.ResponseWriter, req *http.Request) {
- // Garbage collect after each PUT. Fixes #2865.
- // See also GetBlockHandler.
- defer runtime.GC()
-
hash := mux.Vars(req)["hash"]
// Detect as many error conditions as possible before reading
log.Printf("%s: checksum mismatch for request %s (actual %s)\n",
vol, hash, filehash)
error_to_caller = DiskHashError
+ bufs.Put(buf)
continue
}
if error_to_caller == DiskHashError {
error_to_caller = GenericError
log.Printf("%s: Touch %s failed: %s",
vol, hash, error_to_caller)
+ bufs.Put(buf)
continue
}
}
// so there is nothing special to do if err != nil.
//
if oldblock, err := GetBlock(hash, true); err == nil {
+ defer bufs.Put(oldblock)
if bytes.Compare(block, oldblock) == 0 {
// The block already exists; return success.
return nil