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
if len(client.out) > 0 {
if atomic.LoadInt32(&server.aofdirty) != 0 {
func() {
// prewrite
server.mu.Lock()
defer server.mu.Unlock()
server.flushAOF()
}()
atomic.StoreInt32(&server.aofdirty, 0)
}
conn.Write(client.out)
client.out = nil
}
if close {
break