MCPcopy Create free account
hub / github.com/encodeous/nylon / Send

Method Send

polyamide/conn/bind_std.go:348–417  ·  view source on GitHub ↗
(bufs [][]byte, endpoint Endpoint)

Source from the content-addressed store, hash-verified

346}
347
348func (s *StdNetBind) Send(bufs [][]byte, endpoint Endpoint) error {
349 s.mu.Lock()
350 blackhole := s.blackhole4
351 conn := s.ipv4
352 offload := s.ipv4TxOffload
353 br := batchWriter(s.ipv4PC)
354 is6 := false
355 if endpoint.DstIP().Is6() {
356 blackhole = s.blackhole6
357 conn = s.ipv6
358 br = s.ipv6PC
359 is6 = true
360 offload = s.ipv6TxOffload
361 }
362 s.mu.Unlock()
363
364 if blackhole {
365 return nil
366 }
367 if conn == nil {
368 return syscall.EAFNOSUPPORT
369 }
370
371 msgs := s.getMessages()
372 defer s.putMessages(msgs)
373 ua := s.udpAddrPool.Get().(*net.UDPAddr)
374 defer s.udpAddrPool.Put(ua)
375 if is6 {
376 as16 := endpoint.DstIP().As16()
377 copy(ua.IP, as16[:])
378 ua.IP = ua.IP[:16]
379 } else {
380 as4 := endpoint.DstIP().As4()
381 copy(ua.IP, as4[:])
382 ua.IP = ua.IP[:4]
383 }
384 ua.Port = int(endpoint.(*StdNetEndpoint).Port())
385 var (
386 retried bool
387 err error
388 )
389retry:
390 if offload {
391 n := coalesceMessages(ua, endpoint.(*StdNetEndpoint), bufs, *msgs, setGSOSize)
392 err = s.send(conn, br, (*msgs)[:n])
393 if err != nil && offload && errShouldDisableUDPGSO(err) {
394 offload = false
395 s.mu.Lock()
396 if is6 {
397 s.ipv6TxOffload = false
398 } else {
399 s.ipv4TxOffload = false
400 }
401 s.mu.Unlock()
402 retried = true
403 goto retry
404 }
405 } else {

Callers

nothing calls this directly

Calls 12

getMessagesMethod · 0.95
putMessagesMethod · 0.95
sendMethod · 0.95
batchWriterInterface · 0.85
coalesceMessagesFunction · 0.85
PutMethod · 0.80
errShouldDisableUDPGSOFunction · 0.70
setSrcControlFunction · 0.70
DstIPMethod · 0.65
GetMethod · 0.45
StringMethod · 0.45
LocalAddrMethod · 0.45

Tested by

no test coverage detected