diff options
author | aarzilli <alessandro.arzilli@gmail.com> | 2016-03-01 15:41:38 +0100 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-09-08 16:49:24 +0200 |
commit | becaf43dcb3e9832c3eb951ff9908ed697868152 (patch) | |
tree | f2a45ac253c5ec8265efa78f1d4a2c993153fe18 /nexgb/ge/ge.go | |
parent | baff8c19067489ea26bbb804ef693e966202b511 (diff) | |
download | haven-becaf43dcb3e9832c3eb951ff9908ed697868152.tar.gz haven-becaf43dcb3e9832c3eb951ff9908ed697868152.tar.xz haven-becaf43dcb3e9832c3eb951ff9908ed697868152.zip |
Read/Write mutex for Extensions map
Diffstat (limited to 'nexgb/ge/ge.go')
-rw-r--r-- | nexgb/ge/ge.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/nexgb/ge/ge.go b/nexgb/ge/ge.go index 68213bc..f7e1ce4 100644 --- a/nexgb/ge/ge.go +++ b/nexgb/ge/ge.go @@ -19,16 +19,15 @@ func Init(c *xgb.Conn) error { return xgb.Errorf("No extension named Generic Event Extension could be found on on the server.") } - xgb.ExtLock.Lock() + c.ExtLock.Lock() c.Extensions["Generic Event Extension"] = reply.MajorOpcode + c.ExtLock.Unlock() for evNum, fun := range xgb.NewExtEventFuncs["Generic Event Extension"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["Generic Event Extension"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } - xgb.ExtLock.Unlock() - return nil } @@ -69,6 +68,8 @@ type QueryVersionCookie struct { // QueryVersion sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["Generic Event Extension"]; !ok { panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Generic Event Extension'. ge.Init(connObj) must be called first.") } @@ -80,6 +81,8 @@ func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uin // QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["Generic Event Extension"]; !ok { panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Generic Event Extension'. ge.Init(connObj) must be called first.") } @@ -141,7 +144,9 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVers b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["Generic Event Extension"] + c.ExtLock.RUnlock() b += 1 buf[b] = 0 // request opcode |