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
1437f8bd
Commit
1437f8bd
authored
Jun 17, 2006
by
Robert Shearman
Committed by
Alexandre Julliard
Jun 19, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpcrt4: Use the thread pool in the RPC server for processing packets.
parent
1ddc722e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
87 deletions
+5
-87
rpc_server.c
dlls/rpcrt4/rpc_server.c
+5
-87
No files found.
dlls/rpcrt4/rpc_server.c
View file @
1437f8bd
...
...
@@ -53,7 +53,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(rpc);
typedef
struct
_RpcPacket
{
struct
_RpcPacket
*
next
;
struct
_RpcConnection
*
conn
;
RpcPktHdr
*
hdr
;
RPC_MESSAGE
*
msg
;
...
...
@@ -103,20 +102,9 @@ static HANDLE mgr_mutex;
/* set when server thread has finished opening connections */
static
HANDLE
server_ready_event
;
static
CRITICAL_SECTION
spacket_cs
;
static
CRITICAL_SECTION_DEBUG
spacket_cs_debug
=
{
0
,
0
,
&
spacket_cs
,
{
&
spacket_cs_debug
.
ProcessLocksList
,
&
spacket_cs_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": spacket_cs"
)
}
};
static
CRITICAL_SECTION
spacket_cs
=
{
&
spacket_cs_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
RpcPacket
*
spacket_head
;
static
RpcPacket
*
spacket_tail
;
static
HANDLE
server_sem
;
static
LONG
worker_
count
,
worker_free
,
worker_
tls
;
static
LONG
worker_tls
;
static
UUID
uuid_nil
;
...
...
@@ -165,34 +153,6 @@ static RpcServerInterface* RPCRT4_find_interface(UUID* object,
return
cif
;
}
static
void
RPCRT4_push_packet
(
RpcPacket
*
packet
)
{
packet
->
next
=
NULL
;
EnterCriticalSection
(
&
spacket_cs
);
if
(
spacket_tail
)
{
spacket_tail
->
next
=
packet
;
spacket_tail
=
packet
;
}
else
{
spacket_head
=
packet
;
spacket_tail
=
packet
;
}
LeaveCriticalSection
(
&
spacket_cs
);
}
static
RpcPacket
*
RPCRT4_pop_packet
(
void
)
{
RpcPacket
*
packet
;
EnterCriticalSection
(
&
spacket_cs
);
packet
=
spacket_head
;
if
(
packet
)
{
spacket_head
=
packet
->
next
;
if
(
!
spacket_head
)
spacket_tail
=
NULL
;
}
LeaveCriticalSection
(
&
spacket_cs
);
if
(
packet
)
packet
->
next
=
NULL
;
return
packet
;
}
typedef
struct
{
PRPC_MESSAGE
msg
;
void
*
buf
;
...
...
@@ -350,52 +310,12 @@ fail:
static
DWORD
CALLBACK
RPCRT4_worker_thread
(
LPVOID
the_arg
)
{
DWORD
obj
;
RpcPacket
*
pkt
;
for
(;;)
{
/* idle timeout after 5s */
obj
=
WaitForSingleObject
(
server_sem
,
5000
);
if
(
obj
==
WAIT_TIMEOUT
)
{
/* if another idle thread exist, self-destruct */
if
(
worker_free
>
1
)
break
;
continue
;
}
pkt
=
RPCRT4_pop_packet
();
if
(
!
pkt
)
continue
;
InterlockedDecrement
(
&
worker_free
);
for
(;;)
{
RPCRT4_process_packet
(
pkt
->
conn
,
pkt
->
hdr
,
pkt
->
msg
);
HeapFree
(
GetProcessHeap
(),
0
,
pkt
);
/* try to grab another packet here without waiting
* on the semaphore, in case it hits max */
pkt
=
RPCRT4_pop_packet
();
if
(
!
pkt
)
break
;
/* decrement semaphore */
WaitForSingleObject
(
server_sem
,
0
);
}
InterlockedIncrement
(
&
worker_free
);
}
InterlockedDecrement
(
&
worker_free
);
InterlockedDecrement
(
&
worker_count
);
RpcPacket
*
pkt
=
the_arg
;
RPCRT4_process_packet
(
pkt
->
conn
,
pkt
->
hdr
,
pkt
->
msg
);
HeapFree
(
GetProcessHeap
(),
0
,
pkt
);
return
0
;
}
static
void
RPCRT4_create_worker_if_needed
(
void
)
{
if
(
!
worker_free
&&
worker_count
<
MAX_THREADS
)
{
HANDLE
thread
;
InterlockedIncrement
(
&
worker_count
);
InterlockedIncrement
(
&
worker_free
);
thread
=
CreateThread
(
NULL
,
0
,
RPCRT4_worker_thread
,
NULL
,
0
,
NULL
);
if
(
thread
)
CloseHandle
(
thread
);
else
{
InterlockedDecrement
(
&
worker_free
);
InterlockedDecrement
(
&
worker_count
);
}
}
}
static
DWORD
CALLBACK
RPCRT4_io_thread
(
LPVOID
the_arg
)
{
RpcConnection
*
conn
=
(
RpcConnection
*
)
the_arg
;
...
...
@@ -429,9 +349,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
packet
->
conn
=
conn
;
packet
->
hdr
=
hdr
;
packet
->
msg
=
msg
;
RPCRT4_create_worker_if_needed
();
RPCRT4_push_packet
(
packet
);
ReleaseSemaphore
(
server_sem
,
1
,
NULL
);
QueueUserWorkItem
(
RPCRT4_worker_thread
,
packet
,
WT_EXECUTEDEFAULT
);
#endif
msg
=
NULL
;
}
...
...
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