|
@@ -1724,7 +1724,7 @@ func (client *Client) wakeWriter() {
|
1724
|
1724
|
|
1725
|
1725
|
func (client *Client) writeLoop() {
|
1726
|
1726
|
for {
|
1727
|
|
- client.performWrite()
|
|
1727
|
+ client.performWrite(0)
|
1728
|
1728
|
client.writerSemaphore.Release()
|
1729
|
1729
|
|
1730
|
1730
|
client.stateMutex.RLock()
|
|
@@ -1737,9 +1737,9 @@ func (client *Client) writeLoop() {
|
1737
|
1737
|
}
|
1738
|
1738
|
}
|
1739
|
1739
|
|
1740
|
|
-func (client *Client) performWrite() {
|
|
1740
|
+func (client *Client) performWrite(additionalDirtyBits uint) {
|
1741
|
1741
|
client.stateMutex.Lock()
|
1742
|
|
- dirtyBits := client.dirtyBits
|
|
1742
|
+ dirtyBits := client.dirtyBits | additionalDirtyBits
|
1743
|
1743
|
client.dirtyBits = 0
|
1744
|
1744
|
account := client.account
|
1745
|
1745
|
client.stateMutex.Unlock()
|
|
@@ -1775,3 +1775,21 @@ func (client *Client) performWrite() {
|
1775
|
1775
|
client.server.accounts.saveModes(account, uModes)
|
1776
|
1776
|
}
|
1777
|
1777
|
}
|
|
1778
|
+
|
|
1779
|
+// Blocking store; see Channel.Store and Socket.BlockingWrite
|
|
1780
|
+func (client *Client) Store(dirtyBits uint) (err error) {
|
|
1781
|
+ defer func() {
|
|
1782
|
+ client.stateMutex.Lock()
|
|
1783
|
+ isDirty := client.dirtyBits != 0
|
|
1784
|
+ client.stateMutex.Unlock()
|
|
1785
|
+
|
|
1786
|
+ if isDirty {
|
|
1787
|
+ client.wakeWriter()
|
|
1788
|
+ }
|
|
1789
|
+ }()
|
|
1790
|
+
|
|
1791
|
+ client.writerSemaphore.Acquire()
|
|
1792
|
+ defer client.writerSemaphore.Release()
|
|
1793
|
+ client.performWrite(dirtyBits)
|
|
1794
|
+ return nil
|
|
1795
|
+}
|