[lxc-devel] [lxd/master] Bump Go on travis and fix devlxd locking
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Dec 5 21:11:18 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171205/0d4ac313/attachment.bin>
-------------- next part --------------
From c7222499e4537ea633ebfd241b7c7ab5d4737331 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 5 Dec 2017 02:12:09 -0500
Subject: [PATCH 1/2] travis: Bump Go versions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index da615e2d8..643ebffc7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,8 +4,8 @@ os:
- osx
go:
- - 1.6
- - 1.7
+ - 1.8
+ - 1.9
- tip
matrix:
From d3429336fa1a75dadf4ade1b62ed34a4e8a88506 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 5 Dec 2017 02:41:06 -0500
Subject: [PATCH 2/2] devlxd: Properly lock the internal struct
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/devlxd.go | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lxd/devlxd.go b/lxd/devlxd.go
index 90a2b29d2..6b0b543dc 100644
--- a/lxd/devlxd.go
+++ b/lxd/devlxd.go
@@ -10,6 +10,7 @@ import (
"regexp"
"strconv"
"strings"
+ "sync"
"unsafe"
"github.com/gorilla/mux"
@@ -181,6 +182,7 @@ type ucred struct {
type ConnPidMapper struct {
m map[*net.UnixConn]*ucred
+ mLock sync.Mutex
}
func (m *ConnPidMapper) ConnStateHandler(conn net.Conn, state http.ConnState) {
@@ -191,7 +193,9 @@ func (m *ConnPidMapper) ConnStateHandler(conn net.Conn, state http.ConnState) {
if err != nil {
logger.Debugf("Error getting ucred for conn %s", err)
} else {
+ m.mLock.Lock()
m.m[unixConn] = cred
+ m.mLock.Unlock()
}
case http.StateActive:
return
@@ -206,9 +210,13 @@ func (m *ConnPidMapper) ConnStateHandler(conn net.Conn, state http.ConnState) {
* more. Whatever the case, we want to forget about it since we
* won't see it either.
*/
+ m.mLock.Lock()
delete(m.m, unixConn)
+ m.mLock.Unlock()
case http.StateClosed:
+ m.mLock.Lock()
delete(m.m, unixConn)
+ m.mLock.Unlock()
default:
logger.Debugf("Unknown state for connection %s", state)
}
More information about the lxc-devel
mailing list