forked from External/ergo
parent
531a1d6864
commit
746309e386
3 changed files with 39 additions and 46 deletions
|
|
@ -113,7 +113,7 @@ type Client struct {
|
|||
vhost string
|
||||
history history.Buffer
|
||||
dirtyBits uint
|
||||
writerSemaphore utils.Semaphore // tier 1.5
|
||||
writebackLock sync.Mutex // tier 1.5
|
||||
}
|
||||
|
||||
type saslStatus struct {
|
||||
|
|
@ -335,16 +335,15 @@ func (server *Server) RunClient(conn IRCConn) {
|
|||
Duration: config.Accounts.LoginThrottling.Duration,
|
||||
Limit: config.Accounts.LoginThrottling.MaxAttempts,
|
||||
},
|
||||
server: server,
|
||||
accountName: "*",
|
||||
nick: "*", // * is used until actual nick is given
|
||||
nickCasefolded: "*",
|
||||
nickMaskString: "*", // * is used until actual nick is given
|
||||
realIP: realIP,
|
||||
proxiedIP: proxiedIP,
|
||||
requireSASL: requireSASL,
|
||||
nextSessionID: 1,
|
||||
writerSemaphore: utils.NewSemaphore(1),
|
||||
server: server,
|
||||
accountName: "*",
|
||||
nick: "*", // * is used until actual nick is given
|
||||
nickCasefolded: "*",
|
||||
nickMaskString: "*", // * is used until actual nick is given
|
||||
realIP: realIP,
|
||||
proxiedIP: proxiedIP,
|
||||
requireSASL: requireSASL,
|
||||
nextSessionID: 1,
|
||||
}
|
||||
if requireSASL {
|
||||
client.requireSASLMessage = banMsg
|
||||
|
|
@ -424,8 +423,6 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, channelToStatus m
|
|||
realname: realname,
|
||||
|
||||
nextSessionID: 1,
|
||||
|
||||
writerSemaphore: utils.NewSemaphore(1),
|
||||
}
|
||||
|
||||
if client.checkAlwaysOnExpirationNoMutex(config, true) {
|
||||
|
|
@ -1772,7 +1769,7 @@ func (client *Client) markDirty(dirtyBits uint) {
|
|||
}
|
||||
|
||||
func (client *Client) wakeWriter() {
|
||||
if client.writerSemaphore.TryAcquire() {
|
||||
if client.writebackLock.TryLock() {
|
||||
go client.writeLoop()
|
||||
}
|
||||
}
|
||||
|
|
@ -1780,13 +1777,13 @@ func (client *Client) wakeWriter() {
|
|||
func (client *Client) writeLoop() {
|
||||
for {
|
||||
client.performWrite(0)
|
||||
client.writerSemaphore.Release()
|
||||
client.writebackLock.Unlock()
|
||||
|
||||
client.stateMutex.RLock()
|
||||
isDirty := client.dirtyBits != 0
|
||||
client.stateMutex.RUnlock()
|
||||
|
||||
if !isDirty || !client.writerSemaphore.TryAcquire() {
|
||||
if !isDirty || !client.writebackLock.TryLock() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -1844,8 +1841,8 @@ func (client *Client) Store(dirtyBits uint) (err error) {
|
|||
}
|
||||
}()
|
||||
|
||||
client.writerSemaphore.Acquire()
|
||||
defer client.writerSemaphore.Release()
|
||||
client.writebackLock.Lock()
|
||||
defer client.writebackLock.Unlock()
|
||||
client.performWrite(dirtyBits)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue