fix: memory leak in influx parser (#9787)
This commit is contained in:
parent
15753a6f7f
commit
128ed8849b
|
|
@ -3747,13 +3747,6 @@ func (m *streamMachine) Next() error {
|
||||||
m.machine.finishMetric = false
|
m.machine.finishMetric = false
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// Expand the buffer if it is full
|
|
||||||
if m.machine.pe == len(m.machine.data) {
|
|
||||||
expanded := make([]byte, 2*len(m.machine.data))
|
|
||||||
copy(expanded, m.machine.data)
|
|
||||||
m.machine.data = expanded
|
|
||||||
}
|
|
||||||
|
|
||||||
err := m.machine.exec()
|
err := m.machine.exec()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -3764,6 +3757,13 @@ func (m *streamMachine) Next() error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expand the buffer if it is full
|
||||||
|
if m.machine.pe == len(m.machine.data) {
|
||||||
|
expanded := make([]byte, 2*len(m.machine.data))
|
||||||
|
copy(expanded, m.machine.data)
|
||||||
|
m.machine.data = expanded
|
||||||
|
}
|
||||||
|
|
||||||
n, err := m.reader.Read(m.machine.data[m.machine.pe:])
|
n, err := m.reader.Read(m.machine.data[m.machine.pe:])
|
||||||
if n == 0 && err == io.EOF {
|
if n == 0 && err == io.EOF {
|
||||||
m.machine.eof = m.machine.pe
|
m.machine.eof = m.machine.pe
|
||||||
|
|
|
||||||
|
|
@ -499,13 +499,6 @@ func (m *streamMachine) Next() error {
|
||||||
m.machine.finishMetric = false
|
m.machine.finishMetric = false
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// Expand the buffer if it is full
|
|
||||||
if m.machine.pe == len(m.machine.data) {
|
|
||||||
expanded := make([]byte, 2 * len(m.machine.data))
|
|
||||||
copy(expanded, m.machine.data)
|
|
||||||
m.machine.data = expanded
|
|
||||||
}
|
|
||||||
|
|
||||||
err := m.machine.exec()
|
err := m.machine.exec()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -516,6 +509,13 @@ func (m *streamMachine) Next() error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expand the buffer if it is full
|
||||||
|
if m.machine.pe == len(m.machine.data) {
|
||||||
|
expanded := make([]byte, 2 * len(m.machine.data))
|
||||||
|
copy(expanded, m.machine.data)
|
||||||
|
m.machine.data = expanded
|
||||||
|
}
|
||||||
|
|
||||||
n, err := m.reader.Read(m.machine.data[m.machine.pe:])
|
n, err := m.reader.Read(m.machine.data[m.machine.pe:])
|
||||||
if n == 0 && err == io.EOF {
|
if n == 0 && err == io.EOF {
|
||||||
m.machine.eof = m.machine.pe
|
m.machine.eof = m.machine.pe
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue