Author: ekohl
Date: Wed Sep  7 20:11:19 2011
New Revision: 53630

URL: http://svn.reactos.org/svn/reactos?rev=53630&view=rev
Log:
[RPCTR4]
- Take NetworkAddr into account when a named pipe client is opened.
- Return RPC_S_SERVER_UNAVAILABLE when an attempt to create a named pipe client 
fails with an ERROR_BAD_NETPATH error.
This fixes the first test failure in the advapi32 service winetest.

Modified:
    trunk/reactos/dll/win32/rpcrt4/rpc_transport.c

Modified: trunk/reactos/dll/win32/rpcrt4/rpc_transport.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rpcrt4/rpc_transport.c?rev=53630&r1=53629&r2=53630&view=diff
==============================================================================
--- trunk/reactos/dll/win32/rpcrt4/rpc_transport.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/rpcrt4/rpc_transport.c [iso-8859-1] Wed Sep  7 
20:11:19 2011
@@ -224,6 +224,9 @@
     if (err == ERROR_PIPE_BUSY) {
       TRACE("connection failed, error=%x\n", err);
       return RPC_S_SERVER_TOO_BUSY;
+    } else if (err == ERROR_BAD_NETPATH) {
+      TRACE("connection failed, error=%x\n", err);
+      return RPC_S_SERVER_UNAVAILABLE;
     }
     if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
       err = GetLastError();
@@ -305,17 +308,31 @@
 static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
 {
   RpcConnection_np *npc = (RpcConnection_np *) Connection;
-  static const char prefix[] = "\\\\.";
+  static const char prefix[] = "\\\\";
+  static const char local[] =".";
   RPC_STATUS r;
   LPSTR pname;
+  INT size;
 
   /* already connected? */
   if (npc->pipe)
     return RPC_S_OK;
 
   /* protseq=ncacn_np: named pipes */
-  pname = I_RpcAllocate(strlen(prefix) + strlen(Connection->Endpoint) + 1);
-  strcat(strcpy(pname, prefix), Connection->Endpoint);
+  size = strlen(prefix);
+  if (Connection->NetworkAddr == NULL || strlen(Connection->NetworkAddr) == 0)
+    size += strlen(local);
+  else
+    size += strlen(Connection->NetworkAddr);
+  size += strlen(Connection->Endpoint) + 1;
+
+  pname = I_RpcAllocate(size);
+  strcpy(pname, prefix);
+  if (Connection->NetworkAddr == NULL || strlen(Connection->NetworkAddr) == 0)
+    strcat(pname, local);
+  else
+    strcat(pname, Connection->NetworkAddr);
+  strcat(pname, Connection->Endpoint);
   r = rpcrt4_conn_open_pipe(Connection, pname, TRUE);
   I_RpcFree(pname);
 


Reply via email to