1 Star 0 Fork 6

冲击 / netpoll

forked from CloudWeGo / netpoll 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sys_sendmsg_linux.go 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
Joway 提交于 2022-06-02 15:49 . fix: barrier memory leak (#158)
// Copyright 2021 CloudWeGo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package netpoll
import (
"syscall"
"unsafe"
)
//func init() {
// err := syscall.Setrlimit(8, &syscall.Rlimit{
// Cur: 0xffffffff,
// Max: 0xffffffff,
// })
// if err != nil {
// panic(err)
// }
//}
// sendmsg wraps the sendmsg system call.
// Must len(iovs) >= len(vs)
func sendmsg(fd int, bs [][]byte, ivs []syscall.Iovec, zerocopy bool) (n int, err error) {
iovLen := iovecs(bs, ivs)
if iovLen == 0 {
return 0, nil
}
var msghdr = syscall.Msghdr{
Iov: &ivs[0],
Iovlen: uint64(iovLen),
}
var flags uintptr
if zerocopy {
flags = MSG_ZEROCOPY
}
r, _, e := syscall.RawSyscall(syscall.SYS_SENDMSG, uintptr(fd), uintptr(unsafe.Pointer(&msghdr)), flags)
resetIovecs(bs, ivs[:iovLen])
if e != 0 {
return int(r), syscall.Errno(e)
}
return int(r), nil
}
1
https://gitee.com/1273640670/netpoll.git
git@gitee.com:1273640670/netpoll.git
1273640670
netpoll
netpoll
develop

搜索帮助