fix bug of read to many bytes
This commit is contained in:
parent
f60f43046d
commit
f5b8337638
|
@ -100,7 +100,7 @@ func (ms *MysqlSession) resetBeginTime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *MysqlSession) readFromServer(bytes []byte) {
|
func (ms *MysqlSession) readFromServer(bytes []byte) {
|
||||||
if ms.expectSendSize < 1 {
|
if ms.expectSendSize < 1 && len(bytes) > 4 {
|
||||||
ms.expectSendSize = extractMysqlPayloadSize(bytes[:4])
|
ms.expectSendSize = extractMysqlPayloadSize(bytes[:4])
|
||||||
contents := bytes[4:]
|
contents := bytes[4:]
|
||||||
if ms.prepareInfo != nil && contents[0] == 0 {
|
if ms.prepareInfo != nil && contents[0] == 0 {
|
||||||
|
@ -115,7 +115,7 @@ func (ms *MysqlSession) checkFinish() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNode := ms.coverRanges.head.next
|
checkNode := ms.coverRanges.head.next
|
||||||
if checkNode.end - checkNode.begin == int64(len(ms.cachedStmtBytes)) {
|
if checkNode.end-checkNode.begin == int64(len(ms.cachedStmtBytes)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,6 @@ func (ms *MysqlSession) readFromClient(seqID int64, bytes []byte) {
|
||||||
ms.beginSeqID = seqID
|
ms.beginSeqID = seqID
|
||||||
ms.endSeqID = seqID
|
ms.endSeqID = seqID
|
||||||
|
|
||||||
|
|
||||||
if int64(ms.expectReceiveSize) < int64(len(contents)) {
|
if int64(ms.expectReceiveSize) < int64(len(contents)) {
|
||||||
log.Warnf("receive invalid mysql packet")
|
log.Warnf("receive invalid mysql packet")
|
||||||
return
|
return
|
||||||
|
@ -204,7 +203,6 @@ func (ms *MysqlSession) readFromClient(seqID int64, bytes []byte) {
|
||||||
// ms.expectReceiveSize = ms.expectReceiveSize - int(contentSize)
|
// ms.expectReceiveSize = ms.expectReceiveSize - int(contentSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (ms *MysqlSession) GenerateQueryPiece() (qp model.QueryPiece) {
|
func (ms *MysqlSession) GenerateQueryPiece() (qp model.QueryPiece) {
|
||||||
defer ms.clear()
|
defer ms.clear()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue