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. --- walk.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'walk.go') diff --git a/walk.go b/walk.go index 9fc4094..6979b6b 100644 --- a/walk.go +++ b/walk.go @@ -8,6 +8,7 @@ import "C" import ( "io" + "runtime" ) // RevWalk @@ -34,6 +35,9 @@ func (v *RevWalk) Push(id *Oid) { } func (v *RevWalk) PushHead() (err error) { + runtime.LockOSThread() + defer runtime.UnlockOSThread() + ecode := C.git_revwalk_push_head(v.ptr) if ecode < 0 { err = LastError() @@ -43,6 +47,9 @@ func (v *RevWalk) PushHead() (err error) { } func (v *RevWalk) Next(oid *Oid) (err error) { + runtime.LockOSThread() + defer runtime.UnlockOSThread() + ret := C.git_revwalk_next(oid.toC(), v.ptr) switch { case ret == ITEROVER: -- cgit v1.2.3