fix a race condition. (#212)
when multiple call to GetStream happens around the same time, on the same inputIndex, a race condition will cause this.buffers.Add() to throw exception.
This commit is contained in:
@@ -98,9 +98,9 @@ namespace k8s
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public Stream GetStream(byte? inputIndex, byte? outputIndex)
|
public Stream GetStream(byte? inputIndex, byte? outputIndex)
|
||||||
{
|
{
|
||||||
if (inputIndex != null && !this.buffers.ContainsKey(inputIndex.Value))
|
lock (this.buffers)
|
||||||
{
|
{
|
||||||
lock (this.buffers)
|
if (inputIndex != null && !this.buffers.ContainsKey(inputIndex.Value))
|
||||||
{
|
{
|
||||||
var buffer = new ByteBuffer();
|
var buffer = new ByteBuffer();
|
||||||
this.buffers.Add(inputIndex.Value, buffer);
|
this.buffers.Add(inputIndex.Value, buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user