diff --git a/README.md b/README.md index ed472a74..c1aad248 100644 --- a/README.md +++ b/README.md @@ -151,11 +151,11 @@ func main() { ### Different IOMod -| IOMod | Remarks | -| ---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -| IOModNonBlocking | There's no difference between this IOMod and the old version with no IOMod. All the connections will be handled by poller. | -| IOModBlocking | All the connections will be handled by at least one goroutine, for websocket, we can set Upgrader.BlockingModAsyncWrite=true to handle writting with a separated goroutine and then avoid Head-of-line blocking on broadcasting scenarios. | -| IOModMixed | We set the Engine.MaxBlockingOnline, if the online num is smaller than it, the new connection will be handled by single goroutine as IOModBlocking, else the new connection will be handled by poller. | +| IOMod | Remarks | +| ---------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | +| IOModNonBlocking | There's no difference between this IOMod and the old version with no IOMod. All the connections will be handled by poller. | +| IOModBlocking | All the connections will be handled by at least one goroutine, for websocket, we can set Upgrader.BlockingModAsyncWrite=true to handle writing with a separated goroutine and then avoid Head-of-line blocking on broadcasting scenarios. | +| IOModMixed | We set the Engine.MaxBlockingOnline, if the online num is smaller than it, the new connection will be handled by single goroutine as IOModBlocking, else the new connection will be handled by poller. | The `IOModBlocking` aims to improve the performance for low online service, it runs faster than std. The `IOModMixed` aims to keep a balance between performance and cpu/mem cost in different scenarios: when there are not too many online connections, it performs better than std, or else it can serve lots of online connections and keep healthy. diff --git a/conn_std.go b/conn_std.go index 12db6bd2..44c63c44 100644 --- a/conn_std.go +++ b/conn_std.go @@ -234,7 +234,7 @@ func (c *Conn) Writev(in [][]byte) (int, error) { c.Close() } if c.p.g.onWrittenSize != nil && nwrite > 0 { - total := nwrite + total := int(nwrite) for i := 0; total > 0; i++ { if total <= len(in[i]) { c.p.g.onWrittenSize(c, in[i][:total], total) diff --git a/engine.go b/engine.go index 21f1bd39..e1e05c83 100644 --- a/engine.go +++ b/engine.go @@ -255,7 +255,7 @@ func (g *Engine) OnData(h func(c *Conn, data []byte)) { } // OnWrittenSize registers callback for written size. -// If len(b) is bigger than 0, it represents that it's writting a buffer, +// If len(b) is bigger than 0, it represents that it's writing a buffer, // else it's operating by Sendfile. func (g *Engine) OnWrittenSize(h func(c *Conn, b []byte, n int)) { if h == nil {