Skip to content

Commit 46366b5

Browse files
committed
set port and max conns when server is created
1 parent 90a2cef commit 46366b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/server.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"errors"
1919
"fmt"
2020
"net"
21+
"strconv"
2122
"time"
2223

2324
"github.com/dolthub/vitess/go/mysql"
@@ -118,6 +119,15 @@ func portInUse(hostPort string) bool {
118119
return false
119120
}
120121

122+
func updateSystemVariables(cfg mysql.ListenerConfig) {
123+
_, port, _ := net.SplitHostPort(cfg.Listener.Addr().String())
124+
portInt, _ := strconv.ParseInt(port, 10, 64)
125+
sql.SystemVariables.AssignValues(map[string]interface{}{
126+
"max_connections": cfg.MaxConns,
127+
"port": portInt,
128+
})
129+
}
130+
121131
func newServerFromHandler(cfg Config, e *sqle.Engine, sm *SessionManager, handler mysql.Handler, sel ServerEventListener) (*Server, error) {
122132
if cfg.ConnReadTimeout < 0 {
123133
cfg.ConnReadTimeout = 0
@@ -172,6 +182,8 @@ func newServerFromHandler(cfg Config, e *sqle.Engine, sm *SessionManager, handle
172182
return nil, err
173183
}
174184

185+
updateSystemVariables(listenerCfg)
186+
175187
return &Server{
176188
Listener: protocolListener,
177189
handler: handler,

0 commit comments

Comments
 (0)