princeoffoods / csharptest-net

Automatically exported from code.google.com/p/csharptest-net
0 stars 0 forks source link

Concurency issue in RpcHandle #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Got for _pinnedAddresses in concurent scenatio:
System.InvalidOperationException occurred
  Message=Collection was modified; enumeration operation may not execute.
  Source=mscorlib
  StackTrace:
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       at System.Collections.Generic.List`1.Enumerator.MoveNext()
       at CSharpTest.Net.RpcLibrary.Interop.RpcHandle.GetPtr[T](T& value) in c:\ci\co\CommonOffice\src\csharptest-net\src\RpcLibrary\Interop\RpcHandle.cs:line 42
  InnerException: 

   internal bool GetPtr<T>(out T value)
        {
            foreach (object o in _pinnedAddresses)
            {
                if (o is T)
                {
                    value = (T) o;
                    return true;
                }
            }
            value = default(T);
            return false;
        }

Also got:
RpcInterop: ServerRegisterAuthInfo - unable to register authentication type 
RPC_C_AUTHN_NONE

System.NullReferenceException : Object reference not set to an instance of an 
object.
   at CSharpTest.Net.RpcLibrary.Interop.RpcHandle.Dispose(Boolean disposing) in RpcHandle.cs: line 84
   at CSharpTest.Net.RpcLibrary.Interop.RpcHandle.Dispose() in RpcHandle.cs: line 68
   at CSharpTest.Net.RpcLibrary.RpcClientApi.Dispose() in RpcClientApi.cs: line 56

Original issue reported on code.google.com by asd.and....@gmail.com on 26 Feb 2013 at 4:42

GoogleCodeExporter commented 8 years ago
Did   lock (_pinnedAddresses) and not issues. Tests revealing issues and fix 
are in my branch.

Original comment by asd.and....@gmail.com on 26 Feb 2013 at 4:42

GoogleCodeExporter commented 8 years ago
The usage of RpcHandle/_handle are private members of either the RpcServerApi 
or RpcClientApi.  Neither of these classes are thread-safe, nor are they 
intended to be.  

Each thread should have it's own client if needed, or use a connection-pool to 
borrow connections.  RpcServerApi should not be shared across threads, and 
there really isn't a need to as this should be a one-time setup (start 
listening) and destruction (dispose).

Original comment by Grig...@gmail.com on 26 Jan 2014 at 6:32