Skip to content

Commit

Permalink
modify code
Browse files Browse the repository at this point in the history
Signed-off-by: joccau <[email protected]>
  • Loading branch information
joccau committed Jan 24, 2025
1 parent fdcdc2a commit bad08f0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
14 changes: 0 additions & 14 deletions pkg/privilege/privileges/privileges.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,20 +334,6 @@ func (p *UserPrivileges) GetUserResources(user, host string) (int64, error) {
return 0, errors.New("Failed to get max user connections")
}

// GetEncodedPassword implements the Manager interface.
func (p *UserPrivileges) GetEncodedPassword(user, host string) string {
mysqlPriv := p.Handle.Get()
record := mysqlPriv.connectionVerification(user, host)
if record == nil {
logutil.BgLogger().Error("get user privilege record fail",
zap.String("user", user), zap.String("host", host))
return ""
}
if p.isValidHash(record) {
return record.AuthenticationString
}
return ""
}

// GetAuthPluginForConnection gets the authentication plugin used in connection establishment.
func (p *UserPrivileges) GetAuthPluginForConnection(ctx context.Context, user, host string) (string, error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ func (cc *clientConn) Close() error {
//
// TODO: avoid calling this function multiple times. It's not intuitive that a connection can be closed multiple
// times.
cc.decrementUserConnectionsCounter()


cc.server.rwlock.Lock()
delete(cc.server.clients, cc.connectionID)
cc.server.rwlock.Unlock()
Expand Down
1 change: 1 addition & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ func (s *Server) onConn(conn *clientConn) {
logutil.Logger(ctx).Debug("new connection", zap.String("remoteAddr", conn.bufReadConn.RemoteAddr().String()))

defer func() {
conn.decrementUserConnectionsCounter()
terror.Log(conn.Close())
logutil.Logger(ctx).Debug("connection closed")
}()
Expand Down

0 comments on commit bad08f0

Please sign in to comment.