Jacek Caban : rpcrt4: Store all active connections in RpcServerProtseq.

Alexandre Julliard julliard at winehq.org
Tue May 23 18:01:27 CDT 2017


Module: wine
Branch: master
Commit: ef267f115f76a3041e0da4a0f0dbd7ffb4a022e1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ef267f115f76a3041e0da4a0f0dbd7ffb4a022e1

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May 23 17:39:39 2017 +0200

rpcrt4: Store all active connections in RpcServerProtseq.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/rpcrt4/rpc_server.c    |  1 +
 dlls/rpcrt4/rpc_server.h    |  1 +
 dlls/rpcrt4/rpc_transport.c | 32 +++++++++++++++++++++-----------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
index 1327171..b76185b 100644
--- a/dlls/rpcrt4/rpc_server.c
+++ b/dlls/rpcrt4/rpc_server.c
@@ -946,6 +946,7 @@ static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcSe
   (*ps)->ops = ops;
   (*ps)->MaxCalls = 0;
   list_init(&(*ps)->listeners);
+  list_init(&(*ps)->connections);
   InitializeCriticalSection(&(*ps)->cs);
   (*ps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcServerProtseq.cs");
   (*ps)->is_listening = FALSE;
diff --git a/dlls/rpcrt4/rpc_server.h b/dlls/rpcrt4/rpc_server.h
index a3c476e..130dde7 100644
--- a/dlls/rpcrt4/rpc_server.h
+++ b/dlls/rpcrt4/rpc_server.h
@@ -34,6 +34,7 @@ typedef struct _RpcServerProtseq
   UINT MaxCalls; /* RO */
   /* list of listening connections */
   struct list listeners; /* CS cs */
+  struct list connections; /* CS cs */
   CRITICAL_SECTION cs;
 
   /* is the server currently listening? */
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index 6b308c8..b88eeb7 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -58,7 +58,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
 
-static RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection);
+static RpcConnection *rpcrt4_spawn_connection(RpcConnection *old_connection);
 
 /**** ncacn_np support ****/
 
@@ -744,7 +744,7 @@ static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq,
                 release_np_event(conn, conn->listen_event);
                 conn->listen_event = NULL;
                 if (conn->io_status.Status == STATUS_SUCCESS || conn->io_status.Status == STATUS_PIPE_CONNECTED)
-                    RPCRT4_SpawnConnection(&cconn, &conn->common);
+                    cconn = rpcrt4_spawn_connection(&conn->common);
                 else
                     ERR("listen failed %x\n", conn->io_status.Status);
                 break;
@@ -1595,7 +1595,7 @@ static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq
     {
         if (b_handle == conn->sock_event)
         {
-            RPCRT4_SpawnConnection(&cconn, &conn->common);
+            cconn = rpcrt4_spawn_connection(&conn->common);
             break;
         }
     }
@@ -3311,16 +3311,26 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server,
   return RPC_S_OK;
 }
 
-static RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection)
+static RpcConnection *rpcrt4_spawn_connection(RpcConnection *old_connection)
 {
-  RPC_STATUS err;
+    RpcConnection *connection;
+    RPC_STATUS err;
 
-  err = RPCRT4_CreateConnection(Connection, OldConnection->server, rpcrt4_conn_get_name(OldConnection),
-                                OldConnection->NetworkAddr, OldConnection->Endpoint, NULL,
-                                OldConnection->AuthInfo, OldConnection->QOS, OldConnection->CookieAuth);
-  if (err == RPC_S_OK)
-    rpcrt4_conn_handoff(OldConnection, *Connection);
-  return err;
+    err = RPCRT4_CreateConnection(&connection, old_connection->server, rpcrt4_conn_get_name(old_connection),
+                                  old_connection->NetworkAddr, old_connection->Endpoint, NULL,
+                                  old_connection->AuthInfo, old_connection->QOS, old_connection->CookieAuth);
+    if (err != RPC_S_OK)
+        return NULL;
+
+    rpcrt4_conn_handoff(old_connection, connection);
+    if (old_connection->protseq)
+    {
+        EnterCriticalSection(&old_connection->protseq->cs);
+        connection->protseq = old_connection->protseq;
+        list_add_tail(&old_connection->protseq->connections, &connection->protseq_entry);
+        LeaveCriticalSection(&old_connection->protseq->cs);
+    }
+    return connection;
 }
 
 RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn )




More information about the wine-cvs mailing list