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:
@@ -97,10 +97,10 @@ namespace k8s
|
||||
/// A <see cref="Stream"/> which allows you to read/write to the requested channels.
|
||||
/// </returns>
|
||||
public Stream GetStream(byte? inputIndex, byte? outputIndex)
|
||||
{
|
||||
if (inputIndex != null && !this.buffers.ContainsKey(inputIndex.Value))
|
||||
{
|
||||
lock (this.buffers)
|
||||
{
|
||||
if (inputIndex != null && !this.buffers.ContainsKey(inputIndex.Value))
|
||||
{
|
||||
var buffer = new ByteBuffer();
|
||||
this.buffers.Add(inputIndex.Value, buffer);
|
||||
|
||||
Reference in New Issue
Block a user