-
Notifications
You must be signed in to change notification settings - Fork 5
/
api_iouring_process.go
51 lines (40 loc) · 1.07 KB
/
api_iouring_process.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//go:build linux
// +build linux
package greatws
import (
"io"
"github.com/pawelgaczynski/giouring"
)
func (c *Conn) processRead(cqe *giouring.CompletionQueueEvent) error {
// 返回值小于等于0,表示读取完毕,关闭连接
if cqe.Res <= 0 {
go c.closeAndWaitOnMessage(true, io.EOF)
c.getLogger().Debug("read res <= 0", "res", cqe.Res, "fd", c.fd)
return nil
}
c.getLogger().Debug("read res", "res", cqe.Res, "fd", c.fd)
// 处理websocket数据
c.rw += int(cqe.Res)
_, err := c.processWebsocketFrameOnlyIoUring()
if err != nil {
c.getLogger().Error("processWebsocketFrameOnlyIoUring", "err", err)
return err
}
parent := c.getParent()
if parent == nil {
c.processClose(cqe)
c.getLogger().Info("parent is nil", "close", c.closed)
return nil
}
if err := parent.addRead(c); err != nil {
return err
}
return nil
}
func (c *Conn) processWrite(cqe *giouring.CompletionQueueEvent, writeSeq uint32) error {
return nil
}
func (c *Conn) processClose(cqe *giouring.CompletionQueueEvent) error {
go c.closeAndWaitOnMessage(true, io.EOF)
return nil
}