Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d2ca9f4b
Commit
d2ca9f4b
authored
Feb 14, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpcrt4: Add ref counting to RPC connections, and grab a reference while processing an RPC packet.
parent
e2b38c3f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
13 deletions
+25
-13
rpc_assoc.c
dlls/rpcrt4/rpc_assoc.c
+3
-3
rpc_binding.c
dlls/rpcrt4/rpc_binding.c
+1
-1
rpc_binding.h
dlls/rpcrt4/rpc_binding.h
+3
-1
rpc_message.c
dlls/rpcrt4/rpc_message.c
+1
-1
rpc_server.c
dlls/rpcrt4/rpc_server.c
+4
-3
rpc_transport.c
dlls/rpcrt4/rpc_transport.c
+13
-4
No files found.
dlls/rpcrt4/rpc_assoc.c
View file @
d2ca9f4b
...
@@ -203,7 +203,7 @@ ULONG RpcAssoc_Release(RpcAssoc *assoc)
...
@@ -203,7 +203,7 @@ ULONG RpcAssoc_Release(RpcAssoc *assoc)
LIST_FOR_EACH_ENTRY_SAFE
(
Connection
,
cursor2
,
&
assoc
->
free_connection_pool
,
RpcConnection
,
conn_pool_entry
)
LIST_FOR_EACH_ENTRY_SAFE
(
Connection
,
cursor2
,
&
assoc
->
free_connection_pool
,
RpcConnection
,
conn_pool_entry
)
{
{
list_remove
(
&
Connection
->
conn_pool_entry
);
list_remove
(
&
Connection
->
conn_pool_entry
);
RPCRT4_
Destroy
Connection
(
Connection
);
RPCRT4_
Release
Connection
(
Connection
);
}
}
LIST_FOR_EACH_ENTRY_SAFE
(
context_handle
,
context_handle_cursor
,
&
assoc
->
context_handle_list
,
RpcContextHandle
,
entry
)
LIST_FOR_EACH_ENTRY_SAFE
(
context_handle
,
context_handle_cursor
,
&
assoc
->
context_handle_list
,
RpcContextHandle
,
entry
)
...
@@ -410,14 +410,14 @@ RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
...
@@ -410,14 +410,14 @@ RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc,
status
=
RPCRT4_OpenClientConnection
(
NewConnection
);
status
=
RPCRT4_OpenClientConnection
(
NewConnection
);
if
(
status
!=
RPC_S_OK
)
if
(
status
!=
RPC_S_OK
)
{
{
RPCRT4_
Destroy
Connection
(
NewConnection
);
RPCRT4_
Release
Connection
(
NewConnection
);
return
status
;
return
status
;
}
}
status
=
RpcAssoc_BindConnection
(
assoc
,
NewConnection
,
InterfaceId
,
TransferSyntax
);
status
=
RpcAssoc_BindConnection
(
assoc
,
NewConnection
,
InterfaceId
,
TransferSyntax
);
if
(
status
!=
RPC_S_OK
)
if
(
status
!=
RPC_S_OK
)
{
{
RPCRT4_
Destroy
Connection
(
NewConnection
);
RPCRT4_
Release
Connection
(
NewConnection
);
return
status
;
return
status
;
}
}
...
...
dlls/rpcrt4/rpc_binding.c
View file @
d2ca9f4b
...
@@ -298,7 +298,7 @@ RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection)
...
@@ -298,7 +298,7 @@ RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection)
/* don't destroy a connection that is cached in the binding */
/* don't destroy a connection that is cached in the binding */
if
(
Binding
->
FromConn
==
Connection
)
if
(
Binding
->
FromConn
==
Connection
)
return
RPC_S_OK
;
return
RPC_S_OK
;
return
RPCRT4_
Destroy
Connection
(
Connection
);
return
RPCRT4_
Release
Connection
(
Connection
);
}
}
else
{
else
{
RpcAssoc_ReleaseIdleConnection
(
Binding
->
Assoc
,
Connection
);
RpcAssoc_ReleaseIdleConnection
(
Binding
->
Assoc
,
Connection
);
...
...
dlls/rpcrt4/rpc_binding.h
View file @
d2ca9f4b
...
@@ -61,6 +61,7 @@ struct connection_ops;
...
@@ -61,6 +61,7 @@ struct connection_ops;
typedef
struct
_RpcConnection
typedef
struct
_RpcConnection
{
{
LONG
ref
;
BOOL
server
;
BOOL
server
;
LPSTR
NetworkAddr
;
LPSTR
NetworkAddr
;
LPSTR
Endpoint
;
LPSTR
Endpoint
;
...
@@ -153,7 +154,8 @@ ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
...
@@ -153,7 +154,8 @@ ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN;
BOOL
RpcQualityOfService_IsEqual
(
const
RpcQualityOfService
*
qos1
,
const
RpcQualityOfService
*
qos2
)
DECLSPEC_HIDDEN
;
BOOL
RpcQualityOfService_IsEqual
(
const
RpcQualityOfService
*
qos1
,
const
RpcQualityOfService
*
qos2
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_CreateConnection
(
RpcConnection
**
Connection
,
BOOL
server
,
LPCSTR
Protseq
,
LPCSTR
NetworkAddr
,
LPCSTR
Endpoint
,
LPCWSTR
NetworkOptions
,
RpcAuthInfo
*
AuthInfo
,
RpcQualityOfService
*
QOS
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_CreateConnection
(
RpcConnection
**
Connection
,
BOOL
server
,
LPCSTR
Protseq
,
LPCSTR
NetworkAddr
,
LPCSTR
Endpoint
,
LPCWSTR
NetworkOptions
,
RpcAuthInfo
*
AuthInfo
,
RpcQualityOfService
*
QOS
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_DestroyConnection
(
RpcConnection
*
Connection
)
DECLSPEC_HIDDEN
;
RpcConnection
*
RPCRT4_GrabConnection
(
RpcConnection
*
conn
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_ReleaseConnection
(
RpcConnection
*
Connection
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_OpenClientConnection
(
RpcConnection
*
Connection
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_OpenClientConnection
(
RpcConnection
*
Connection
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_CloseConnection
(
RpcConnection
*
Connection
)
DECLSPEC_HIDDEN
;
RPC_STATUS
RPCRT4_CloseConnection
(
RpcConnection
*
Connection
)
DECLSPEC_HIDDEN
;
...
...
dlls/rpcrt4/rpc_message.c
View file @
d2ca9f4b
...
@@ -1875,7 +1875,7 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
...
@@ -1875,7 +1875,7 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
fail:
fail:
RPCRT4_FreeHeader
(
hdr
);
RPCRT4_FreeHeader
(
hdr
);
RPCRT4_
Destroy
Connection
(
conn
);
RPCRT4_
Release
Connection
(
conn
);
pMsg
->
ReservedForRuntime
=
NULL
;
pMsg
->
ReservedForRuntime
=
NULL
;
return
status
;
return
status
;
}
}
...
...
dlls/rpcrt4/rpc_server.c
View file @
d2ca9f4b
...
@@ -539,6 +539,7 @@ static DWORD CALLBACK RPCRT4_worker_thread(LPVOID the_arg)
...
@@ -539,6 +539,7 @@ static DWORD CALLBACK RPCRT4_worker_thread(LPVOID the_arg)
RpcPacket
*
pkt
=
the_arg
;
RpcPacket
*
pkt
=
the_arg
;
RPCRT4_process_packet
(
pkt
->
conn
,
pkt
->
hdr
,
pkt
->
msg
,
pkt
->
auth_data
,
RPCRT4_process_packet
(
pkt
->
conn
,
pkt
->
hdr
,
pkt
->
msg
,
pkt
->
auth_data
,
pkt
->
auth_length
);
pkt
->
auth_length
);
RPCRT4_ReleaseConnection
(
pkt
->
conn
);
HeapFree
(
GetProcessHeap
(),
0
,
pkt
);
HeapFree
(
GetProcessHeap
(),
0
,
pkt
);
return
0
;
return
0
;
}
}
...
@@ -585,7 +586,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
...
@@ -585,7 +586,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
HeapFree
(
GetProcessHeap
(),
0
,
auth_data
);
HeapFree
(
GetProcessHeap
(),
0
,
auth_data
);
goto
exit
;
goto
exit
;
}
}
packet
->
conn
=
conn
;
packet
->
conn
=
RPCRT4_GrabConnection
(
conn
)
;
packet
->
hdr
=
hdr
;
packet
->
hdr
=
hdr
;
packet
->
msg
=
msg
;
packet
->
msg
=
msg
;
packet
->
auth_data
=
auth_data
;
packet
->
auth_data
=
auth_data
;
...
@@ -621,7 +622,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
...
@@ -621,7 +622,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
}
}
}
}
exit:
exit:
RPCRT4_
Destroy
Connection
(
conn
);
RPCRT4_
Release
Connection
(
conn
);
return
0
;
return
0
;
}
}
...
@@ -631,7 +632,7 @@ void RPCRT4_new_client(RpcConnection* conn)
...
@@ -631,7 +632,7 @@ void RPCRT4_new_client(RpcConnection* conn)
if
(
!
thread
)
{
if
(
!
thread
)
{
DWORD
err
=
GetLastError
();
DWORD
err
=
GetLastError
();
ERR
(
"failed to create thread, error=%08x
\n
"
,
err
);
ERR
(
"failed to create thread, error=%08x
\n
"
,
err
);
RPCRT4_
Destroy
Connection
(
conn
);
RPCRT4_
Release
Connection
(
conn
);
}
}
/* we could set conn->thread, but then we'd have to make the io_thread wait
/* we could set conn->thread, but then we'd have to make the io_thread wait
* for that, otherwise the thread might finish, destroy the connection, and
* for that, otherwise the thread might finish, destroy the connection, and
...
...
dlls/rpcrt4/rpc_transport.c
View file @
d2ca9f4b
...
@@ -1374,7 +1374,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
...
@@ -1374,7 +1374,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
if
(
ret
<
0
)
if
(
ret
<
0
)
{
{
WARN
(
"listen failed: %s
\n
"
,
strerror
(
errno
));
WARN
(
"listen failed: %s
\n
"
,
strerror
(
errno
));
RPCRT4_
Destroy
Connection
(
&
tcpc
->
common
);
RPCRT4_
Release
Connection
(
&
tcpc
->
common
);
status
=
RPC_S_OUT_OF_RESOURCES
;
status
=
RPC_S_OUT_OF_RESOURCES
;
continue
;
continue
;
}
}
...
@@ -1387,7 +1387,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
...
@@ -1387,7 +1387,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr
if
(
ret
<
0
)
if
(
ret
<
0
)
{
{
WARN
(
"couldn't make socket non-blocking, error %d
\n
"
,
ret
);
WARN
(
"couldn't make socket non-blocking, error %d
\n
"
,
ret
);
RPCRT4_
Destroy
Connection
(
&
tcpc
->
common
);
RPCRT4_
Release
Connection
(
&
tcpc
->
common
);
status
=
RPC_S_OUT_OF_RESOURCES
;
status
=
RPC_S_OUT_OF_RESOURCES
;
continue
;
continue
;
}
}
...
@@ -2946,6 +2946,7 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server,
...
@@ -2946,6 +2946,7 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server,
}
}
NewConnection
=
ops
->
alloc
();
NewConnection
=
ops
->
alloc
();
NewConnection
->
ref
=
1
;
NewConnection
->
Next
=
NULL
;
NewConnection
->
Next
=
NULL
;
NewConnection
->
server_binding
=
NULL
;
NewConnection
->
server_binding
=
NULL
;
NewConnection
->
server
=
server
;
NewConnection
->
server
=
server
;
...
@@ -2991,9 +2992,17 @@ static RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnecti
...
@@ -2991,9 +2992,17 @@ static RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnecti
return
err
;
return
err
;
}
}
R
PC_STATUS
RPCRT4_DestroyConnection
(
RpcConnection
*
Connection
)
R
pcConnection
*
RPCRT4_GrabConnection
(
RpcConnection
*
conn
)
{
{
TRACE
(
"connection: %p
\n
"
,
Connection
);
InterlockedIncrement
(
&
conn
->
ref
);
return
conn
;
}
RPC_STATUS
RPCRT4_ReleaseConnection
(
RpcConnection
*
Connection
)
{
if
(
InterlockedDecrement
(
&
Connection
->
ref
)
>
0
)
return
RPC_S_OK
;
TRACE
(
"destroying connection %p
\n
"
,
Connection
);
RPCRT4_CloseConnection
(
Connection
);
RPCRT4_CloseConnection
(
Connection
);
RPCRT4_strfree
(
Connection
->
Endpoint
);
RPCRT4_strfree
(
Connection
->
Endpoint
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment