readFrom() now logs a warning if it is reading a large packet (which I suspect never happens).

This commit is contained in:
scruzin 2019-01-20 08:09:49 +10:30
parent 828cc3780a
commit ddd1e4ab17
1 changed files with 3 additions and 4 deletions

View File

@ -203,12 +203,11 @@ func (pkt *packet) readFrom(c *Conn) error {
pkt.resize(pkt.bodySize, (hbuf[0]&0xc0)>>6) pkt.resize(pkt.bodySize, (hbuf[0]&0xc0)>>6)
} }
sz := c.inChunkSize if pkt.bodySize > c.inChunkSize {
if pkt.bodySize < sz { c.log(WarnLevel, pkg+"reading large packet", "size", int(pkt.bodySize))
sz = pkt.bodySize
} }
_, err = c.read(pkt.body[:sz]) _, err = c.read(pkt.body[:pkt.bodySize])
if err != nil { if err != nil {
c.log(DebugLevel, pkg+"failed to read packet body", "error", err.Error()) c.log(DebugLevel, pkg+"failed to read packet body", "error", err.Error())
return err return err