implemented sweeping of handle tables
[reactos.git] / reactos / ntoskrnl / lpc / listen.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/listen.c
6 * PURPOSE: Communication mechanism
7 *
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
9 */
10
11 /* INCLUDES ******************************************************************/
12
13 #include <ntoskrnl.h>
14 #define NDEBUG
15 #include <internal/debug.h>
16
17 /* FUNCTIONS *****************************************************************/
18
19 /**********************************************************************
20 * NAME EXPORTED
21 * NtListenPort@8
22 *
23 * DESCRIPTION
24 * Listen on a named port and wait for a connection attempt.
25 *
26 * ARGUMENTS
27 * PortHandle [IN] LPC port to listen on.
28 *
29 * ConnectMsg [IN] User provided storage for a
30 * possible connection request LPC message.
31 *
32 * RETURN VALUE
33 * STATUS_SUCCESS if a connection request is received
34 * successfully; otherwise an error code.
35 *
36 * The buffer ConnectMessage is filled with the connection
37 * request message queued by NtConnectPort() in PortHandle.
38 *
39 * NOTE
40 */
41 /*EXPORTED*/ NTSTATUS STDCALL
42 NtListenPort (IN HANDLE PortHandle,
43 IN PPORT_MESSAGE ConnectMsg)
44 {
45 NTSTATUS Status;
46
47 /*
48 * Wait forever for a connection request.
49 */
50 for (;;)
51 {
52 Status = NtReplyWaitReceivePort(PortHandle,
53 NULL,
54 NULL,
55 ConnectMsg);
56 /*
57 * Accept only LPC_CONNECTION_REQUEST requests.
58 * Drop any other message.
59 */
60 if (!NT_SUCCESS(Status) ||
61 LPC_CONNECTION_REQUEST == ConnectMsg->u2.s2.Type)
62 {
63 DPRINT("Got message (type %x)\n", LPC_CONNECTION_REQUEST);
64 break;
65 }
66 DPRINT("Got message (type %x)\n", ConnectMsg->u2.s2.Type);
67 }
68
69 return (Status);
70 }
71
72
73 /* EOF */