aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/go_request_reply.go
diff options
context:
space:
mode:
authoraarzilli <alessandro.arzilli@gmail.com>2016-03-01 15:41:38 +0100
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:24 +0200
commitbecaf43dcb3e9832c3eb951ff9908ed697868152 (patch)
treef2a45ac253c5ec8265efa78f1d4a2c993153fe18 /nexgb/xgbgen/go_request_reply.go
parentbaff8c19067489ea26bbb804ef693e966202b511 (diff)
downloadhaven-becaf43dcb3e9832c3eb951ff9908ed697868152.tar.gz
haven-becaf43dcb3e9832c3eb951ff9908ed697868152.tar.xz
haven-becaf43dcb3e9832c3eb951ff9908ed697868152.zip
Read/Write mutex for Extensions map
Diffstat (limited to 'nexgb/xgbgen/go_request_reply.go')
-rw-r--r--nexgb/xgbgen/go_request_reply.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go
index c1b9ee9..396305e 100644
--- a/nexgb/xgbgen/go_request_reply.go
+++ b/nexgb/xgbgen/go_request_reply.go
@@ -79,6 +79,8 @@ func (r *Request) CheckExt(c *Context) {
if !c.protocol.isExt() {
return
}
+ c.Putln("c.ExtLock.RLock()")
+ c.Putln("defer c.ExtLock.RUnlock()")
c.Putln("if _, ok := c.Extensions[\"%s\"]; !ok {", c.protocol.ExtXName)
c.Putln("panic(\"Cannot issue request '%s' using the uninitialized "+
"extension '%s'. %s.Init(connObj) must be called first.\")",
@@ -169,7 +171,9 @@ func (r *Request) WriteRequest(c *Context) {
c.Putln("buf := make([]byte, size)")
c.Putln("")
if c.protocol.isExt() {
+ c.Putln("c.ExtLock.RLock()")
c.Putln("buf[b] = c.Extensions[\"%s\"]", c.protocol.ExtXName)
+ c.Putln("c.ExtLock.RUnlock()")
c.Putln("b += 1")
c.Putln("")
}