mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
exit early and panic for non slice on buffer.Put
This commit is contained in:
parent
f2c5913416
commit
9878d66484
|
@ -71,16 +71,16 @@ func (p *Pool) Get(sz int) interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put adds a slice to the right bucket in the pool.
|
// Put adds a slice to the right bucket in the pool.
|
||||||
func (p *Pool) Put(s interface{}) error {
|
func (p *Pool) Put(s interface{}) {
|
||||||
slice := reflect.ValueOf(s)
|
slice := reflect.ValueOf(s)
|
||||||
if slice.Kind() == reflect.Slice {
|
|
||||||
for i, size := range p.sizes {
|
if slice.Kind() != reflect.Slice {
|
||||||
if slice.Cap() > size {
|
panic(fmt.Sprintf("%+v is not a slice", slice))
|
||||||
continue
|
}
|
||||||
}
|
for i, size := range p.sizes {
|
||||||
p.buckets[i].Put(slice.Slice(0, 0).Interface())
|
if slice.Cap() > size {
|
||||||
return nil
|
continue
|
||||||
}
|
}
|
||||||
|
p.buckets[i].Put(slice.Slice(0, 0).Interface())
|
||||||
}
|
}
|
||||||
return fmt.Errorf("%+v is not a slice", slice)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -699,9 +699,7 @@ mainLoop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := sl.buffers.Put(b); err != nil {
|
sl.buffers.Put(b)
|
||||||
level.Error(sl.l).Log("msg", "buffer pool error", "err", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if scrapeErr == nil {
|
if scrapeErr == nil {
|
||||||
scrapeErr = appErr
|
scrapeErr = appErr
|
||||||
|
|
Loading…
Reference in a new issue