Changeset 783


Ignore:
Timestamp:
12/11/08 06:51:50 (6 years ago)
Author:
lowjoel
Message:

Copy how pipe servers asynchronously wait for connections from Program.cs, since during my debugging the latter's implementation produced more reliable connections. Hopefully this really fixes the problem of intermittent connections.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Manager/RemoteExecutor.cs

    r753 r783  
    2222 
    2323using System; 
     24using System.Text; 
    2425using System.IO; 
    25 using System.Text; 
    2626using System.IO.Pipes; 
    2727using System.Threading; 
     
    2929 
    3030using System.Runtime.Serialization; 
    31 using System.Runtime.Remoting.Messaging; 
    3231using System.Runtime.Serialization.Formatters.Binary; 
    3332 
     
    128127                    EndWaitForConnection, server); 
    129128 
    130                 //Execute the handler if the server was connected. 
    131                 if (asyncWait.AsyncWaitHandle.WaitOne()) 
    132                     ThreadPool.QueueUserWorkItem(ProcessConnection, server); 
     129                //Wait for a connection before moving on to create another listening server 
     130                asyncWait.AsyncWaitHandle.WaitOne(); 
    133131            } 
    134132        } 
     
    141139        private void EndWaitForConnection(IAsyncResult result) 
    142140        { 
    143             NamedPipeServerStream server = (NamedPipeServerStream)result.AsyncState; 
    144             server.WaitForConnection(); 
    145             server.EndWaitForConnection(result); 
    146         } 
    147  
    148         /// <summary> 
    149         /// Handles a new connection from the client. 
    150         /// </summary> 
    151         /// <param name="param">The connected NamedPipeServerStream instance.</param> 
    152         private void ProcessConnection(object param) 
    153         { 
    154             //Get the Server instance. 
    155             using (NamedPipeServerStream server = (NamedPipeServerStream)param) 
     141            using (NamedPipeServerStream server = (NamedPipeServerStream)result.AsyncState) 
    156142            { 
     143                //We're done waiting for the connection 
     144                server.EndWaitForConnection(result); 
     145 
    157146                //Read the request into the buffer. 
    158147                RemoteRequest request = null; 
     
    291280                    default: 
    292281                        throw new FatalException("Unknown RemoteExecutorClient.Function"); 
     282                } 
    293283                #endregion 
    294                 } 
    295284 
    296285                //Return the result of the invoked function, if any. 
Note: See TracChangeset for help on using the changeset viewer.