Add missing thread locking
This commit is contained in:
parent
0ec2f46659
commit
8c631b0c25
|
@ -235,6 +235,10 @@ func (c *Config) SetInt32(name string, value int32) (err error) {
|
|||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_config_set_int32(c.ptr, cname, C.int32_t(value))
|
||||
if ret < 0 {
|
||||
return MakeGitError(ret)
|
||||
|
@ -350,6 +354,9 @@ type ConfigIterator struct {
|
|||
func (iter *ConfigIterator) Next() (*ConfigEntry, error) {
|
||||
var centry *C.git_config_entry
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_config_next(¢ry, iter.ptr)
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
|
13
diff.go
13
diff.go
|
@ -287,6 +287,9 @@ func (diff *Diff) Patch(deltaIndex int) (*Patch, error) {
|
|||
}
|
||||
var patchPtr *C.git_patch
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ecode := C.git_patch_from_diff(&patchPtr, diff.ptr, C.size_t(deltaIndex))
|
||||
if ecode < 0 {
|
||||
return nil, MakeGitError(ecode)
|
||||
|
@ -348,6 +351,10 @@ type DiffOptions struct {
|
|||
|
||||
func DefaultDiffOptions() (DiffOptions, error) {
|
||||
opts := C.git_diff_options{}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ecode := C.git_diff_init_options(&opts, C.GIT_DIFF_OPTIONS_VERSION)
|
||||
if ecode < 0 {
|
||||
return DiffOptions{}, MakeGitError(ecode)
|
||||
|
@ -487,6 +494,9 @@ func (v *Repository) DiffTreeToTree(oldTree, newTree *Tree, opts *DiffOptions) (
|
|||
}
|
||||
}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ecode := C.git_diff_tree_to_tree(&diffPtr, v.ptr, oldPtr, newPtr, copts)
|
||||
if ecode < 0 {
|
||||
return nil, MakeGitError(ecode)
|
||||
|
@ -536,6 +546,9 @@ func (v *Repository) DiffTreeToWorkdir(oldTree *Tree, opts *DiffOptions) (*Diff,
|
|||
}
|
||||
}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ecode := C.git_diff_tree_to_workdir(&diffPtr, v.ptr, oldPtr, copts)
|
||||
if ecode < 0 {
|
||||
return nil, MakeGitError(ecode)
|
||||
|
|
13
merge.go
13
merge.go
|
@ -39,6 +39,9 @@ func (r *Repository) AnnotatedCommitFromFetchHead(branchName string, remoteURL s
|
|||
cremoteURL := C.CString(remoteURL)
|
||||
defer C.free(unsafe.Pointer(cremoteURL))
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_annotated_commit_from_fetchhead(&mh.ptr, r.ptr, cbranchName, cremoteURL, oid.toC())
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
@ -50,6 +53,9 @@ func (r *Repository) AnnotatedCommitFromFetchHead(branchName string, remoteURL s
|
|||
func (r *Repository) LookupAnnotatedCommit(oid *Oid) (*AnnotatedCommit, error) {
|
||||
mh := &AnnotatedCommit{}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_annotated_commit_lookup(&mh.ptr, r.ptr, oid.toC())
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
@ -61,6 +67,9 @@ func (r *Repository) LookupAnnotatedCommit(oid *Oid) (*AnnotatedCommit, error) {
|
|||
func (r *Repository) AnnotatedCommitFromRef(ref *Reference) (*AnnotatedCommit, error) {
|
||||
mh := &AnnotatedCommit{}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_annotated_commit_from_ref(&mh.ptr, r.ptr, ref.ptr)
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
@ -98,6 +107,10 @@ func mergeOptionsFromC(opts *C.git_merge_options) MergeOptions {
|
|||
|
||||
func DefaultMergeOptions() (MergeOptions, error) {
|
||||
opts := C.git_merge_options{}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ecode := C.git_merge_init_options(&opts, C.GIT_MERGE_OPTIONS_VERSION)
|
||||
if ecode < 0 {
|
||||
return MergeOptions{}, MakeGitError(ecode)
|
||||
|
|
14
odb.go
14
odb.go
|
@ -25,6 +25,9 @@ type OdbBackend struct {
|
|||
func NewOdb() (odb *Odb, err error) {
|
||||
odb = new(Odb)
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_odb_new(&odb.ptr)
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
@ -40,6 +43,10 @@ func NewOdbBackendFromC(ptr *C.git_odb_backend) (backend *OdbBackend) {
|
|||
}
|
||||
|
||||
func (v *Odb) AddBackend(backend *OdbBackend, priority int) (err error) {
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_odb_add_backend(v.ptr, backend.ptr, C.int(priority))
|
||||
if ret < 0 {
|
||||
backend.Free()
|
||||
|
@ -110,6 +117,9 @@ func (v *Odb) ForEach(callback OdbForEachCallback) error {
|
|||
err: nil,
|
||||
}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C._go_git_odb_foreach(v.ptr, unsafe.Pointer(&data))
|
||||
if ret == C.GIT_EUSER {
|
||||
return data.err
|
||||
|
@ -140,6 +150,10 @@ func (v *Odb) Hash(data []byte, otype ObjectType) (oid *Oid, err error) {
|
|||
// contents of the object.
|
||||
func (v *Odb) NewReadStream(id *Oid) (*OdbReadStream, error) {
|
||||
stream := new(OdbReadStream)
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_odb_open_rstream(&stream.ptr, v.ptr, id.toC())
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
|
|
@ -132,6 +132,9 @@ func (pb *Packbuilder) ForEach(callback PackbuilderForeachCallback) error {
|
|||
err: nil,
|
||||
}
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
err := C._go_git_packbuilder_foreach(pb.ptr, unsafe.Pointer(&data))
|
||||
if err == C.GIT_EUSER {
|
||||
return data.err
|
||||
|
|
4
patch.go
4
patch.go
|
@ -40,6 +40,10 @@ func (patch *Patch) String() (string, error) {
|
|||
return "", ErrInvalid
|
||||
}
|
||||
var buf C.git_buf
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ecode := C.git_patch_to_buf(&buf, patch.ptr)
|
||||
if ecode < 0 {
|
||||
return "", MakeGitError(ecode)
|
||||
|
|
6
refdb.go
6
refdb.go
|
@ -23,6 +23,9 @@ type RefdbBackend struct {
|
|||
func (v *Repository) NewRefdb() (refdb *Refdb, err error) {
|
||||
refdb = new(Refdb)
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_refdb_new(&refdb.ptr, v.ptr)
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
@ -38,6 +41,9 @@ func NewRefdbBackendFromC(ptr *C.git_refdb_backend) (backend *RefdbBackend) {
|
|||
}
|
||||
|
||||
func (v *Refdb) SetBackend(backend *RefdbBackend) (err error) {
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_refdb_set_backend(v.ptr, backend.ptr)
|
||||
if ret < 0 {
|
||||
backend.Free()
|
||||
|
|
|
@ -294,6 +294,10 @@ func (v *ReferenceNameIterator) Next() (string, error) {
|
|||
// returned error is git.ErrIterOver
|
||||
func (v *ReferenceIterator) Next() (*Reference, error) {
|
||||
var ptr *C.git_reference
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_reference_next(&ptr, v.ptr)
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
|
|
@ -249,6 +249,10 @@ func (r *Remote) Free() {
|
|||
|
||||
func (repo *Repository) ListRemotes() ([]string, error) {
|
||||
var r C.git_strarray
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ecode := C.git_remote_list(&r, repo.ptr)
|
||||
if ecode < 0 {
|
||||
return nil, MakeGitError(ecode)
|
||||
|
@ -573,6 +577,9 @@ func (o *Remote) Fetch(refspecs []string, sig *Signature, msg string) error {
|
|||
crefspecs.strings = makeCStringsFromStrings(refspecs)
|
||||
defer freeStrarray(&crefspecs)
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_remote_fetch(o.ptr, &crefspecs, csig, cmsg)
|
||||
if ret < 0 {
|
||||
return MakeGitError(ret)
|
||||
|
|
|
@ -72,6 +72,9 @@ func InitRepository(path string, isbare bool) (*Repository, error) {
|
|||
func NewRepositoryWrapOdb(odb *Odb) (repo *Repository, err error) {
|
||||
repo = new(Repository)
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_repository_wrap_odb(&repo.ptr, odb.ptr)
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
@ -386,6 +389,9 @@ func (v *Repository) CreateTag(
|
|||
|
||||
ctarget := commit.gitObject.ptr
|
||||
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_tag_create(oid.toC(), v.ptr, cname, ctarget, taggerSig, cmessage, 0)
|
||||
if ret < 0 {
|
||||
return nil, MakeGitError(ret)
|
||||
|
|
Loading…
Reference in New Issue