MCPcopy
hub / github.com/google/gvisor / SendMsg

Method SendMsg

pkg/sentry/socket/plugin/stack/socket.go:756–795  ·  view source on GitHub ↗

SendMsg implements socket.Socket.SendMsg.

(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, haveDeadline bool, deadline ktime.Time, controlMessages socket.ControlMessages)

Source from the content-addressed store, hash-verified

754
755// SendMsg implements socket.Socket.SendMsg.
756func (s *socketOperations) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, haveDeadline bool, deadline ktime.Time, controlMessages socket.ControlMessages) (int, *syserr.Error) {
757 total := src.NumBytes()
758 nonblock := flags & syscall.MSG_DONTWAIT
759 sysflags := flags | syscall.MSG_DONTWAIT
760
761 n, err := s.send(t, src, to, sysflags)
762
763 if nonblock != 0 {
764 return int(n), syserr.FromError(err)
765 }
766
767 var sent int64
768 for err == nil || err == linuxerr.ErrWouldBlock {
769 if n > 0 {
770 src = src.DropFirst64(n)
771 sent += n
772 }
773
774 if sent == total {
775 return int(total), nil
776 }
777
778 if haveDeadline {
779 err = s.waitEventT(t, waiter.EventOut, deadline)
780 } else {
781 err = s.waitEvent(t, waiter.EventOut)
782 }
783
784 if err != nil {
785 if err == linuxerr.ETIMEDOUT {
786 err = linuxerr.ErrWouldBlock
787 }
788 return int(sent), syserr.FromError(err)
789 }
790
791 n, err = s.send(t, src, to, sysflags)
792 }
793
794 return int(sent), syserr.FromError(err)
795}
796
797// Write implements socket.Socket.Write.
798func (s *socketOperations) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error) {

Callers

nothing calls this directly

Calls 6

sendMethod · 0.95
waitEventTMethod · 0.95
waitEventMethod · 0.95
FromErrorFunction · 0.92
NumBytesMethod · 0.45
DropFirst64Method · 0.45

Tested by

no test coverage detected