From 350499b78cf579c57726b37b27cb5020a5b8d151 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 23 Jun 2015 13:42:45 -0700 Subject: [PATCH] Bring iodine changes into mc --- Godeps/Godeps.json | 4 +- .../minio/minio/pkg/iodine/iodine.go | 42 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 0b3d9b58..63b77c64 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -32,11 +32,13 @@ }, { "ImportPath": "github.com/minio/minio-go", + "Comment": "v0.1.0", "Rev": "115db4940219a4cb142281d0ee216d85599bd4b9" }, { "ImportPath": "github.com/minio/minio/pkg/iodine", - "Rev": "0f58045480309d4b13fe45878f05736c3ff20e7e" + "Comment": "release-1434511043-18-g792e6c2", + "Rev": "792e6c2d3a0bee392abd049e70f0cad52a5f8320" }, { "ImportPath": "github.com/olekukonko/ts", diff --git a/Godeps/_workspace/src/github.com/minio/minio/pkg/iodine/iodine.go b/Godeps/_workspace/src/github.com/minio/minio/pkg/iodine/iodine.go index b8ffd17b..96903052 100644 --- a/Godeps/_workspace/src/github.com/minio/minio/pkg/iodine/iodine.go +++ b/Godeps/_workspace/src/github.com/minio/minio/pkg/iodine/iodine.go @@ -22,7 +22,7 @@ import ( "errors" "fmt" "os" - "path" + "path/filepath" "reflect" "runtime" "strconv" @@ -51,7 +51,7 @@ type StackEntry struct { Data map[string]string } -var gopath string +var gopathSource string var globalState = struct { sync.RWMutex @@ -87,10 +87,9 @@ func GetGlobalState() map[string]string { // GetGlobalStateKey - get value for key from globalState struct func GetGlobalStateKey(k string) string { - result, ok := globalState.m[k] - if !ok { - return "" - } + globalState.RLock() + result, _ := globalState.m[k] + globalState.RUnlock() return result } @@ -152,8 +151,8 @@ func createStackEntry() StackEntry { host, _ := os.Hostname() pc, file, line, _ := runtime.Caller(2) function := runtime.FuncForPC(pc).Name() - _, function = path.Split(function) - file = strings.TrimPrefix(file, gopath) // trim gopath from file + _, function = filepath.Split(function) + file = strings.TrimPrefix(file, gopathSource) // trim gopathSource from file data := GetGlobalState() for k, v := range getSystemData() { @@ -191,14 +190,15 @@ func getSystemData() map[string]string { } // Annotate an error with a stack entry and returns itself -//func (err *WrappedError) Annotate(info map[string]string) *WrappedError { -// entry := createStackEntry() -// for k, v := range info { -// entry.Data[k] = v -// } -// err.Stack = append(err.Stack, entry) -// return err -//} +// +// func (err *WrappedError) Annotate(info map[string]string) *WrappedError { +// entry := createStackEntry() +// for k, v := range info { +// entry.Data[k] = v +// } +// err.Stack = append(err.Stack, entry) +// return err +// } // EmitJSON writes JSON output for the error func (err Error) EmitJSON() ([]byte, error) { @@ -223,8 +223,10 @@ func (err Error) Error() string { func init() { _, iodineFile, _, _ := runtime.Caller(0) - iodineFile = path.Dir(iodineFile) // trim iodine.go - iodineFile = path.Dir(iodineFile) // trim iodine - iodineFile = path.Dir(iodineFile) // trim minio - gopath = path.Dir(iodineFile) + "/" // trim github.com + iodineFile = filepath.Dir(iodineFile) // trim iodine.go + iodineFile = filepath.Dir(iodineFile) // trim iodine + iodineFile = filepath.Dir(iodineFile) // trim pkg + iodineFile = filepath.Dir(iodineFile) // trim minio + iodineFile = filepath.Dir(iodineFile) // trim minio + gopathSource = filepath.Dir(iodineFile) + "/" // trim github.com }