Beispiel #1
0
func (c *Client) SetAuth(dbId uint8) {
	if c != nil && c.authEnabled {
		c.mtx.Lock()
		if c.authBM == nil {
			c.authBM = util.NewBitMap(256 / 8)
		}

		c.authBM.Set(uint(dbId))
		c.mtx.Unlock()
	}
}
Beispiel #2
0
// Cache authorize result. When authorizing again, return directly.
func (c *Client) cachAuth(pkg []byte) {
	var one proto.PkgOneOp
	_, err := one.Decode(pkg)
	if err == nil && one.ErrCode == 0 {
		c.mtx.Lock()
		if c.authBM == nil {
			c.authBM = util.NewBitMap(256 / 8)
		}
		c.authBM.Set(uint(one.DbId))
		c.mtx.Unlock()
	}
}