Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit e3e8b91

Browse files
authored
Merge pull request #806 from juanjux/deadsocket-check
Check for dead sockets before timeout and enforce timeouts
2 parents 9966832 + 6aa453e commit e3e8b91

File tree

116 files changed

+1001
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1001
-235
lines changed

auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package auth
33
import (
44
"strings"
55

6-
"gopkg.in/src-d/go-errors.v1"
76
"github.com/src-d/go-mysql-server/sql"
7+
"gopkg.in/src-d/go-errors.v1"
88
"vitess.io/vitess/go/mysql"
99
)
1010

auth/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88
"os"
99
"testing"
1010

11-
"github.com/stretchr/testify/require"
1211
sqle "github.com/src-d/go-mysql-server"
1312
"github.com/src-d/go-mysql-server/auth"
1413
"github.com/src-d/go-mysql-server/memory"
1514
"github.com/src-d/go-mysql-server/server"
1615
"github.com/src-d/go-mysql-server/sql"
1716
"github.com/src-d/go-mysql-server/sql/analyzer"
1817
"github.com/src-d/go-mysql-server/sql/index/pilosa"
18+
"github.com/stretchr/testify/require"
1919
)
2020

2121
const port = 3336

go.mod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
module github.com/src-d/go-mysql-server
22

33
require (
4-
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
4+
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
55
github.com/VividCortex/gohistogram v1.0.0 // indirect
66
github.com/go-kit/kit v0.8.0
77
github.com/go-ole/go-ole v1.2.4 // indirect
88
github.com/go-sql-driver/mysql v1.4.1
99
github.com/gogo/protobuf v1.2.1 // indirect
1010
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
1111
github.com/golang/protobuf v1.3.0 // indirect
12-
github.com/gorilla/handlers v1.4.0 // indirect
1312
github.com/hashicorp/golang-lru v0.5.3
1413
github.com/mitchellh/hashstructure v1.0.0
1514
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852
1615
github.com/opentracing/opentracing-go v1.0.2
17-
github.com/pbnjay/memory v0.0.0-20190104145345-974d429e7ae4
1816
github.com/pilosa/pilosa v1.3.0
1917
github.com/sanity-io/litter v1.1.0
2018
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
2119
github.com/sirupsen/logrus v1.3.0
2220
github.com/spf13/cast v1.3.0
2321
github.com/src-d/go-oniguruma v1.0.0
24-
github.com/stretchr/testify v1.2.2
22+
github.com/stretchr/testify v1.3.0
2523
go.etcd.io/bbolt v1.3.2
26-
golang.org/x/net v0.0.0-20190227022144-312bce6e941f // indirect
2724
google.golang.org/grpc v1.19.0 // indirect
2825
gopkg.in/src-d/go-errors.v1 v1.0.0
2926
gopkg.in/yaml.v2 v2.2.2

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ github.com/DataDog/datadog-go v0.0.0-20180822151419-281ae9f2d895 h1:dmc/C8bpE5Vk
77
github.com/DataDog/datadog-go v0.0.0-20180822151419-281ae9f2d895/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
88
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
99
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
10-
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 h1:UUppSQnhf4Yc6xGxSkoQpPhb7RVzuv5Nb1mwJ5VId9s=
11-
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
10+
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
11+
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
1212
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
1313
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
1414
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
@@ -24,6 +24,7 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE
2424
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
2525
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
2626
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
27+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2728
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2829
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2930
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -46,9 +47,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCy
4647
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
4748
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
4849
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
50+
github.com/gorilla/handlers v1.3.0 h1:tsg9qP3mjt1h4Roxp+M1paRjrVBfPSOpBuVclh6YluI=
4951
github.com/gorilla/handlers v1.3.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
50-
github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA=
51-
github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
5252
github.com/gorilla/mux v1.7.0 h1:tOSd0UKHQd6urX6ApfOn4XdBMY6Sh1MfxV3kmaazO+U=
5353
github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
5454
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
@@ -86,8 +86,6 @@ github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg
8686
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
8787
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs=
8888
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
89-
github.com/pbnjay/memory v0.0.0-20190104145345-974d429e7ae4 h1:MfIUBZ1bz7TgvQLVa/yPJZOGeKEgs6eTKUjz3zB4B+U=
90-
github.com/pbnjay/memory v0.0.0-20190104145345-974d429e7ae4/go.mod h1:RMU2gJXhratVxBDTFeOdNhd540tG57lt9FIUV0YLvIQ=
9189
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
9290
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
9391
github.com/pilosa/pilosa v1.3.0 h1:P27JB4tIqAN4Yc2Fw7wS5neD7JNkFKRUmwfyV87JMwQ=
@@ -121,9 +119,12 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
121119
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
122120
github.com/src-d/go-oniguruma v1.0.0 h1:JDk5PUAjreGsGAKLsoDLNmrsaryjJ5RqT3h+Si6aw/E=
123121
github.com/src-d/go-oniguruma v1.0.0/go.mod h1:chVbff8kcVtmrhxtZ3yBVLLquXbzCS6DrxQaAK/CeqM=
122+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
124123
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
125124
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
126125
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
126+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
127+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
127128
github.com/uber/jaeger-client-go v2.15.0+incompatible h1:NP3qsSqNxh8VYr956ur1N/1C1PjvOJnJykCzcD5QHbk=
128129
github.com/uber/jaeger-client-go v2.15.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
129130
github.com/uber/jaeger-lib v1.5.0 h1:OHbgr8l656Ub3Fw5k9SWnBfIEwvoHQ+W2y+Aa9D1Uyo=
@@ -140,9 +141,8 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf
140141
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
141142
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
142143
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
144+
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519 h1:x6rhz8Y9CjbgQkccRGmELH6K+LJj7tOoh3XWeC1yaQM=
143145
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
144-
golang.org/x/net v0.0.0-20190227022144-312bce6e941f h1:tbtX/qtlxzhZjgQue/7u7ygFwDEckd+DmS5+t8FgeKE=
145-
golang.org/x/net v0.0.0-20190227022144-312bce6e941f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
146146
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
147147
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
148148
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=

internal/similartext/similartext_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestFindFromMap(t *testing.T) {
3737
res := FindFromMap(names, "")
3838
require.Empty(res)
3939

40-
names = map[string]int {
40+
names = map[string]int{
4141
"foo": 1,
4242
"bar": 2,
4343
}

internal/sockstate/netstat.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package sockstate
2+
3+
import (
4+
"fmt"
5+
"net"
6+
)
7+
8+
// OS independent part of the netstat_[OS].go modules
9+
// Taken (simplified, privatized and with utility functions added) from:
10+
// https://github.com/cakturk/go-netstat
11+
12+
// skState type represents socket connection state
13+
type skState uint8
14+
15+
func (s skState) String() string {
16+
return skStates[s]
17+
}
18+
19+
// Socket states
20+
const (
21+
Established skState = 0x01
22+
SynSent skState = 0x02
23+
SynRecv skState = 0x03
24+
FinWait1 skState = 0x04
25+
FinWait2 skState = 0x05
26+
TimeWait skState = 0x06
27+
Close skState = 0x07
28+
CloseWait skState = 0x08
29+
LastAck skState = 0x09
30+
Listen skState = 0x0a
31+
Closing skState = 0x0b
32+
)
33+
34+
var skStates = [...]string{
35+
"UNKNOWN",
36+
"ESTABLISHED",
37+
"SYN_SENT",
38+
"SYN_RECV",
39+
"FIN_WAIT1",
40+
"FIN_WAIT2",
41+
"TIME_WAIT",
42+
"", // CLOSE
43+
"CLOSE_WAIT",
44+
"LAST_ACK",
45+
"LISTEN",
46+
"CLOSING",
47+
}
48+
49+
// sockAddr represents an ip:port pair
50+
type sockAddr struct {
51+
IP net.IP
52+
Port uint16
53+
}
54+
55+
func (s *sockAddr) String() string {
56+
return fmt.Sprintf("%v:%d", s.IP, s.Port)
57+
}
58+
59+
// sockTabEntry type represents each line of the /proc/net/tcp
60+
type sockTabEntry struct {
61+
Ino string
62+
LocalAddr *sockAddr
63+
RemoteAddr *sockAddr
64+
State skState
65+
UID uint32
66+
Process *process
67+
}
68+
69+
// process holds the PID and process name to which each socket belongs
70+
type process struct {
71+
pid int
72+
name string
73+
}
74+
75+
func (p *process) String() string {
76+
return fmt.Sprintf("%d/%s", p.pid, p.name)
77+
}
78+
79+
// AcceptFn is used to filter socket entries. The value returned indicates
80+
// whether the element is to be appended to the socket list.
81+
type AcceptFn func(*sockTabEntry) bool

internal/sockstate/netstat_darwin.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// +build darwin
2+
3+
package sockstate
4+
5+
import "github.com/sirupsen/logrus"
6+
7+
// tcpSocks returns a slice of active TCP sockets containing only those
8+
// elements that satisfy the accept function
9+
func tcpSocks(accept AcceptFn) ([]sockTabEntry, error) {
10+
// (juanjux) TODO: not implemented
11+
logrus.Info("Connection checking not implemented for Darwin")
12+
return []sockTabEntry{}, nil
13+
}

0 commit comments

Comments
 (0)