MCPcopy Create free account
hub / github.com/cloudwego/netpoll / flush

Method flush

connection_impl.go:526–552  ·  view source on GitHub ↗

flush writes data directly.

()

Source from the content-addressed store, hash-verified

524
525// flush writes data directly.
526func (c *connection) flush() error {
527 if c.outputBuffer.IsEmpty() {
528 return nil
529 }
530 bs := c.outputBuffer.GetBytes(c.outputBarrier.bs)
531 n, err := sendmsg(c.fd, bs, c.outputBarrier.ivs, false)
532 if err != nil && err != syscall.EAGAIN {
533 return Exception(err, "when flush")
534 }
535 if n > 0 {
536 err = c.outputBuffer.Skip(n)
537 c.outputBuffer.Release()
538 if err != nil {
539 return Exception(err, "when flush")
540 }
541 }
542 // return if write all buffer.
543 if c.outputBuffer.IsEmpty() {
544 return nil
545 }
546 err = c.operator.Control(PollR2RW)
547 if err != nil {
548 return Exception(err, "when flush")
549 }
550
551 return c.waitFlush()
552}
553
554func (c *connection) waitFlush() (err error) {
555 timeout := c.writeTimeout

Callers 2

FlushMethod · 0.95
WriteMethod · 0.95

Calls 8

waitFlushMethod · 0.95
ExceptionFunction · 0.85
sendmsgFunction · 0.70
SkipMethod · 0.65
ReleaseMethod · 0.65
ControlMethod · 0.65
IsEmptyMethod · 0.45
GetBytesMethod · 0.45

Tested by

no test coverage detected