Commit 4501d9ad by Ian Lance Taylor

runtime: lock M during cgo call

    
    cgo should lock the M.
    
    
    See also https://golang.org/cl/18882 .
    
    Reviewed-on: https://go-review.googlesource.com/18883

From-SVN: r233670
parent f802a424
1c3747d20789c73447ff71cbc739f7423c4bdf67 156f5f0152797ac2afe5f23803aeb3c7b8f8418e
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -41,6 +41,8 @@ syscall_cgocall () ...@@ -41,6 +41,8 @@ syscall_cgocall ()
if (runtime_needextram && runtime_cas (&runtime_needextram, 1, 0)) if (runtime_needextram && runtime_cas (&runtime_needextram, 1, 0))
runtime_newextram (); runtime_newextram ();
runtime_lockOSThread();
m = runtime_m (); m = runtime_m ();
++m->ncgocall; ++m->ncgocall;
g = runtime_g (); g = runtime_g ();
...@@ -70,6 +72,8 @@ syscall_cgocalldone () ...@@ -70,6 +72,8 @@ syscall_cgocalldone ()
_cgo_panic will already have exited syscall mode. */ _cgo_panic will already have exited syscall mode. */
if (g->status == Gsyscall) if (g->status == Gsyscall)
runtime_exitsyscall (); runtime_exitsyscall ();
runtime_unlockOSThread();
} }
/* Call back from C/C++ code to Go code. */ /* Call back from C/C++ code to Go code. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment