net prewrite optimization

This commit is contained in:
tidwall 2018-11-10 16:21:07 -07:00
parent 464c193d73
commit d065b979da
1 changed files with 10 additions and 6 deletions

View File

@ -653,14 +653,18 @@ func (server *Server) netServe() error {
// write to client // write to client
if len(client.out) > 0 { if len(client.out) > 0 {
func() { if atomic.LoadInt32(&server.aofdirty) != 0 {
// prewrite func() {
server.mu.Lock() // prewrite
defer server.mu.Unlock() server.mu.Lock()
server.flushAOF() defer server.mu.Unlock()
}() server.flushAOF()
}()
atomic.StoreInt32(&server.aofdirty, 0)
}
conn.Write(client.out) conn.Write(client.out)
client.out = nil client.out = nil
} }
if close { if close {
break break