From a40bdfd4202db244bfc5da348a0f0c528ef122cd Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Wed, 18 Sep 2013 09:23:47 +0200 Subject: Lock the OS thread when acessing errors The library stores error information in thread-local storage, which means we need to make sure that the Go runtime doesn't switch OS threads between the time we call a function and th time we attempt to retrieve the error information. --- commit.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'commit.go') diff --git a/commit.go b/commit.go index c633e2d..498669e 100644 --- a/commit.go +++ b/commit.go @@ -9,6 +9,7 @@ extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr); import "C" import ( + "runtime" "time" "unsafe" ) @@ -25,6 +26,9 @@ func (c Commit) Message() string { func (c Commit) Tree() (*Tree, error) { var ptr *C.git_object + runtime.LockOSThread() + defer runtime.UnlockOSThread() + err := C.git_commit_tree(&ptr, c.ptr) if err < 0 { return nil, LastError() -- cgit v1.2.3