ReactOS 0.4.16-dev-329-g9223134
select.c File Reference
#include "afd.h"
Include dependency graph for select.c:

Go to the source code of this file.

Functions

static VOID PrintEvents (ULONG Events)
 
static VOID CopyBackStatus (PAFD_HANDLE HandleArray, UINT HandleCount)
 
VOID ZeroEvents (PAFD_HANDLE HandleArray, UINT HandleCount)
 
VOID SignalSocket (PAFD_ACTIVE_POLL Poll OPTIONAL, PIRP _Irp OPTIONAL, PAFD_POLL_INFO PollReq, NTSTATUS Status)
 
static VOID NTAPI SelectTimeout (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
VOID KillSelectsForFCB (PAFD_DEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN OnlyExclusive)
 
NTSTATUS NTAPI AfdSelect (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS NTAPI AfdEventSelect (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS NTAPI AfdEnumEvents (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static BOOLEAN UpdatePollWithFCB (PAFD_ACTIVE_POLL Poll, PFILE_OBJECT FileObject)
 
VOID PollReeval (PAFD_DEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
 

Variables

static KDEFERRED_ROUTINE SelectTimeout
 

Function Documentation

◆ AfdEnumEvents()

NTSTATUS NTAPI AfdEnumEvents ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 328 of file select.c.

329 {
333 PAFD_FCB FCB = FileObject->FsContext;
334 PKEVENT UserEvent;
336
338
339 AFD_DbgPrint(MID_TRACE,("Called (FCB %p)\n", FCB));
340
341 if( !SocketAcquireStateLock( FCB ) ) {
342 return LostSocket( Irp );
343 }
344
345 if ( !EnumReq ) {
347 }
348
349 /* An event may optionally be provided for us to clear */
350 if (EnumReq->Event != NULL)
351 {
355 UserMode,
356 (PVOID *)&UserEvent,
357 NULL);
358 if (!NT_SUCCESS(Status))
359 {
360 AFD_DbgPrint(MIN_TRACE,("Unable to reference event %x\n", Status));
362 }
363
364 /* Clear the event */
365 KeClearEvent(UserEvent);
366 ObDereferenceObject(UserEvent);
367 }
368
369 /* Copy the poll state, masking out disabled events */
370 EnumReq->PollEvents = (FCB->PollState & ~FCB->EventSelectDisabled);
371 RtlCopyMemory( EnumReq->EventStatus,
372 FCB->PollStatus,
373 sizeof(EnumReq->EventStatus) );
374
375 /* Disable the events that triggered the select until the reenabling function is called */
376 FCB->EventSelectDisabled |= (FCB->PollState & FCB->EventSelectTriggers);
377
379}
LONG NTSTATUS
Definition: precomp.h:26
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
PVOID LockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Output, KPROCESSOR_MODE *LockMode)
Definition: lock.c:24
NTSTATUS LostSocket(PIRP Irp)
Definition: lock.c:387
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
Definition: lock.c:375
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
Definition: lock.c:360
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
Status
Definition: gdiplustypes.h:25
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
#define UserMode
Definition: asm.h:35
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
POBJECT_TYPE ExEventObjectType
Definition: event.c:18
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
struct _AFD_ENUM_NETWORK_EVENTS_INFO * PAFD_ENUM_NETWORK_EVENTS_INFO
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS EventStatus[AFD_MAX_EVENTS]
Definition: shared.h:132
Definition: afd.h:159
Definition: cdstruc.h:902
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by AfdDispatch().

◆ AfdEventSelect()

NTSTATUS NTAPI AfdEventSelect ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 265 of file select.c.

266 {
269 PAFD_EVENT_SELECT_INFO EventSelectInfo =
271 PAFD_FCB FCB = FileObject->FsContext;
272
274
275 if( !SocketAcquireStateLock( FCB ) ) {
276 return LostSocket( Irp );
277 }
278
279 if ( !EventSelectInfo ) {
281 0 );
282 }
283 AFD_DbgPrint(MID_TRACE,("Called (Event %p Triggers %u)\n",
284 EventSelectInfo->EventObject,
285 EventSelectInfo->Events));
286
287 if( FCB->EventSelect ) ObDereferenceObject( FCB->EventSelect );
288 FCB->EventSelect = NULL;
289
290 if( EventSelectInfo->EventObject && EventSelectInfo->Events ) {
291 Status = ObReferenceObjectByHandle( (PVOID)EventSelectInfo->
292 EventObject,
295 UserMode,
296 (PVOID *)&FCB->EventSelect,
297 NULL );
298
299 if( !NT_SUCCESS(Status) )
300 {
301 AFD_DbgPrint(MIN_TRACE,("Failed reference event (0x%x)\n", Status));
302 FCB->EventSelect = NULL;
303 }
304 else
305 FCB->EventSelectTriggers = EventSelectInfo->Events;
306 } else {
307 FCB->EventSelect = NULL;
308 FCB->EventSelectTriggers = 0;
310 }
311
312 if((FCB->EventSelect) &&
313 (FCB->PollState & (FCB->EventSelectTriggers & ~FCB->EventSelectDisabled)))
314 {
315 AFD_DbgPrint(MID_TRACE,("Setting event %p\n", FCB->EventSelect));
316
317 /* Set the application's event */
318 KeSetEvent( FCB->EventSelect, IO_NETWORK_INCREMENT, FALSE );
319 }
320
321 AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
322
324 0 );
325}
#define FALSE
Definition: types.h:117
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
struct _AFD_EVENT_SELECT_INFO * PAFD_EVENT_SELECT_INFO

Referenced by AfdDispatch().

◆ AfdSelect()

NTSTATUS NTAPI AfdSelect ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 165 of file select.c.

166 {
170 PAFD_POLL_INFO PollReq = Irp->AssociatedIrp.SystemBuffer;
171 PAFD_DEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
173 UINT i, Signalled = 0;
174 ULONG Exclusive = PollReq->Exclusive;
175
177
178 AFD_DbgPrint(MID_TRACE,("Called (HandleCount %u Timeout %d)\n",
179 PollReq->HandleCount,
180 (INT)(PollReq->Timeout.QuadPart)));
181
182 SET_AFD_HANDLES(PollReq,
183 LockHandles( PollReq->Handles, PollReq->HandleCount ));
184
185 if( !AFD_HANDLES(PollReq) ) {
186 Irp->IoStatus.Status = STATUS_NO_MEMORY;
187 Irp->IoStatus.Information = 0;
189 return STATUS_NO_MEMORY;
190 }
191
192 if( Exclusive ) {
193 for( i = 0; i < PollReq->HandleCount; i++ ) {
194 if( !AFD_HANDLES(PollReq)[i].Handle ) continue;
195
196 KillSelectsForFCB( DeviceExt,
197 (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle,
198 TRUE );
199 }
200 }
201
202 KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
203
204 for( i = 0; i < PollReq->HandleCount; i++ ) {
205 if( !AFD_HANDLES(PollReq)[i].Handle ) continue;
206
207 FileObject = (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle;
208 FCB = FileObject->FsContext;
209
210 AFD_DbgPrint(MID_TRACE, ("AFD: Select Events: "));
211 PrintEvents( PollReq->Handles[i].Events );
212 AFD_DbgPrint(MID_TRACE,("\n"));
213
214 PollReq->Handles[i].Status =
215 PollReq->Handles[i].Events & FCB->PollState;
216 if( PollReq->Handles[i].Status ) {
217 AFD_DbgPrint(MID_TRACE,("Signalling %p with %x\n",
218 FCB, FCB->PollState));
219 Signalled++;
220 }
221 }
222
223 if( Signalled ) {
225 Irp->IoStatus.Status = Status;
226 SignalSocket( NULL, Irp, PollReq, Status );
227 } else {
228
229 PAFD_ACTIVE_POLL Poll = NULL;
230
232 sizeof(AFD_ACTIVE_POLL),
234
235 if (Poll){
236 Poll->Irp = Irp;
237 Poll->DeviceExt = DeviceExt;
238 Poll->Exclusive = Exclusive;
239
241
243
244 InsertTailList( &DeviceExt->Polls, &Poll->ListEntry );
245
246 KeSetTimer( &Poll->Timer, PollReq->Timeout, &Poll->TimeoutDpc );
247
251 } else {
252 AFD_DbgPrint(MAX_TRACE, ("FIXME: do something with the IRP!\n"));
254 }
255 }
256
257 KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
258
259 AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
260
261 return Status;
262}
#define SET_AFD_HANDLES(x, y)
Definition: afd.h:101
#define AFD_HANDLES(x)
Definition: afd.h:100
DRIVER_CANCEL AfdCancelHandler
Definition: afd.h:302
#define TAG_AFD_ACTIVE_POLL
Definition: afd.h:49
#define MAX_TRACE
Definition: debug.h:16
struct _FCB FCB
#define STATUS_PENDING
Definition: d3dkmdt.h:43
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
PAFD_HANDLE LockHandles(PAFD_HANDLE HandleArray, UINT HandleCount)
Definition: lock.c:310
VOID KillSelectsForFCB(PAFD_DEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN OnlyExclusive)
Definition: select.c:125
static KDEFERRED_ROUTINE SelectTimeout
Definition: select.c:95
VOID SignalSocket(PAFD_ACTIVE_POLL Poll OPTIONAL, PIRP _Irp OPTIONAL, PAFD_POLL_INFO PollReq, NTSTATUS Status)
Definition: select.c:56
static VOID PrintEvents(ULONG Events)
Definition: select.c:13
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NonPagedPool
Definition: env_spec_w32.h:307
__in PWDFDEVICE_INIT __in BOOLEAN Exclusive
ULONG Handle
Definition: gdb_input.c:15
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
IoMarkIrpPending(Irp)
IoSetCancelRoutine(Irp, CancelRoutine)
unsigned int UINT
Definition: ndis.h:50
@ NotificationTimer
#define IoCompleteRequest
Definition: irp.c:1240
PIRP Irp
Definition: afd.h:116
KDPC TimeoutDpc
Definition: afd.h:118
LIST_ENTRY ListEntry
Definition: afd.h:115
KTIMER Timer
Definition: afd.h:119
PAFD_DEVICE_EXTENSION DeviceExt
Definition: afd.h:117
BOOLEAN Exclusive
Definition: afd.h:121
LIST_ENTRY Polls
Definition: afd.h:110
KSPIN_LOCK Lock
Definition: afd.h:111
ULONG Events
Definition: shared.h:51
NTSTATUS Status
Definition: shared.h:52
LARGE_INTEGER Timeout
Definition: shared.h:56
ULONG HandleCount
Definition: shared.h:57
AFD_HANDLE Handles[1]
Definition: shared.h:59
ULONG_PTR Exclusive
Definition: shared.h:58
Definition: ketypes.h:699
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by AfdDispatch().

◆ CopyBackStatus()

static VOID CopyBackStatus ( PAFD_HANDLE  HandleArray,
UINT  HandleCount 
)
static

Definition at line 34 of file select.c.

35 {
36 UINT i;
37
38 for( i = 0; i < HandleCount; i++ ) {
39 HandleArray[i].Events = HandleArray[i].Status;
40 HandleArray[i].Status = 0;
41 }
42}

Referenced by SignalSocket().

◆ KillSelectsForFCB()

VOID KillSelectsForFCB ( PAFD_DEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject,
BOOLEAN  OnlyExclusive 
)

Definition at line 125 of file select.c.

127 {
129 PLIST_ENTRY ListEntry;
130 PAFD_ACTIVE_POLL Poll;
131 PIRP Irp;
132 PAFD_POLL_INFO PollReq;
133 PAFD_HANDLE HandleArray;
134 UINT i;
135
136 AFD_DbgPrint(MID_TRACE,("Killing selects that refer to %p\n", FileObject));
137
138 KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
139
140 ListEntry = DeviceExt->Polls.Flink;
141 while ( ListEntry != &DeviceExt->Polls ) {
142 Poll = CONTAINING_RECORD(ListEntry, AFD_ACTIVE_POLL, ListEntry);
143 ListEntry = ListEntry->Flink;
144 Irp = Poll->Irp;
145 PollReq = Irp->AssociatedIrp.SystemBuffer;
146 HandleArray = AFD_HANDLES(PollReq);
147
148 for( i = 0; i < PollReq->HandleCount; i++ ) {
149 AFD_DbgPrint(MAX_TRACE,("Req: %u, This %p\n",
150 HandleArray[i].Handle, FileObject));
151 if( (PVOID)HandleArray[i].Handle == FileObject &&
152 (!OnlyExclusive || (OnlyExclusive && Poll->Exclusive)) ) {
153 ZeroEvents( PollReq->Handles, PollReq->HandleCount );
154 SignalSocket( Poll, NULL, PollReq, STATUS_CANCELLED );
155 }
156 }
157 }
158
159 KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
160
161 AFD_DbgPrint(MID_TRACE,("Done\n"));
162}
VOID ZeroEvents(PAFD_HANDLE HandleArray, UINT HandleCount)
Definition: select.c:44
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_CANCELLED
Definition: udferr_usr.h:170

Referenced by AfdCleanupSocket(), AfdCloseSocket(), and AfdSelect().

◆ PollReeval()

VOID PollReeval ( PAFD_DEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject 
)

Definition at line 407 of file select.c.

407 {
408 PAFD_ACTIVE_POLL Poll = NULL;
409 PLIST_ENTRY ThePollEnt = NULL;
412 PAFD_POLL_INFO PollReq;
413
414 AFD_DbgPrint(MID_TRACE,("Called: DeviceExt %p FileObject %p\n",
415 DeviceExt, FileObject));
416
417 KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
418
419 /* Take care of any event select signalling */
420 FCB = (PAFD_FCB)FileObject->FsContext;
421
422 if( !FCB ) {
423 KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
424 return;
425 }
426
427 /* Now signal normal select irps */
428 ThePollEnt = DeviceExt->Polls.Flink;
429
430 while( ThePollEnt != &DeviceExt->Polls ) {
431 Poll = CONTAINING_RECORD( ThePollEnt, AFD_ACTIVE_POLL, ListEntry );
432 PollReq = Poll->Irp->AssociatedIrp.SystemBuffer;
433 AFD_DbgPrint(MID_TRACE,("Checking poll %p\n", Poll));
434
435 if( UpdatePollWithFCB( Poll, FileObject ) ) {
436 ThePollEnt = ThePollEnt->Flink;
437 AFD_DbgPrint(MID_TRACE,("Signalling socket\n"));
438 SignalSocket( Poll, NULL, PollReq, STATUS_SUCCESS );
439 } else
440 ThePollEnt = ThePollEnt->Flink;
441 }
442
443 KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
444
445 if((FCB->EventSelect) &&
446 (FCB->PollState & (FCB->EventSelectTriggers & ~FCB->EventSelectDisabled)))
447 {
448 AFD_DbgPrint(MID_TRACE,("Setting event %p\n", FCB->EventSelect));
449
450 /* Set the application's event */
451 KeSetEvent( FCB->EventSelect, IO_NETWORK_INCREMENT, FALSE );
452 }
453
454 AFD_DbgPrint(MID_TRACE,("Leaving\n"));
455}
struct _AFD_FCB * PAFD_FCB
static BOOLEAN UpdatePollWithFCB(PAFD_ACTIVE_POLL Poll, PFILE_OBJECT FileObject)
Definition: select.c:382
PVOID SystemBuffer
union _IRP::@1583 AssociatedIrp

Referenced by AfdAccept(), AfdConnectedSocketReadData(), AfdConnectedSocketWriteData(), AfdCreateSocket(), AfdPacketSocketReadData(), AfdWaitForListen(), DisconnectComplete(), ListenComplete(), MakeSocketIntoConnection(), PacketSocketRecvComplete(), PacketSocketSendComplete(), ReceiveActivity(), SendComplete(), and StreamSocketConnectComplete().

◆ PrintEvents()

static VOID PrintEvents ( ULONG  Events)
static

Definition at line 13 of file select.c.

13 {
14#if DBG
15 char *events_list[] = { "AFD_EVENT_RECEIVE",
16 "AFD_EVENT_OOB_RECEIVE",
17 "AFD_EVENT_SEND",
18 "AFD_EVENT_DISCONNECT",
19 "AFD_EVENT_ABORT",
20 "AFD_EVENT_CLOSE",
21 "AFD_EVENT_CONNECT",
22 "AFD_EVENT_ACCEPT",
23 "AFD_EVENT_CONNECT_FAIL",
24 "AFD_EVENT_QOS",
25 "AFD_EVENT_GROUP_QOS",
26 NULL };
27 int i;
28
29 for( i = 0; events_list[i]; i++ )
30 if( Events & (1 << i) ) AFD_DbgPrint(MID_TRACE,("%s ", events_list[i] ));
31#endif
32}
HANDLE Events[3]
Definition: schedsvc.c:40

Referenced by AfdSelect().

◆ SelectTimeout()

static VOID NTAPI SelectTimeout ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)
static

Definition at line 96 of file select.c.

99 {
101 PAFD_POLL_INFO PollReq;
102 PIRP Irp;
104 PAFD_DEVICE_EXTENSION DeviceExt;
105
109
110 AFD_DbgPrint(MID_TRACE,("Called\n"));
111
112 Irp = Poll->Irp;
113 DeviceExt = Poll->DeviceExt;
114 PollReq = Irp->AssociatedIrp.SystemBuffer;
115
116 ZeroEvents( PollReq->Handles, PollReq->HandleCount );
117
118 KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
119 SignalSocket( Poll, NULL, PollReq, STATUS_TIMEOUT );
120 KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
121
122 AFD_DbgPrint(MID_TRACE,("Timeout\n"));
123}
#define STATUS_TIMEOUT
Definition: d3dkmdt.h:49
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:112
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:688
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:687
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:689

◆ SignalSocket()

VOID SignalSocket ( PAFD_ACTIVE_POLL Poll  OPTIONAL,
PIRP _Irp  OPTIONAL,
PAFD_POLL_INFO  PollReq,
NTSTATUS  Status 
)

Definition at line 56 of file select.c.

62{
63 UINT i;
64 PIRP Irp = _Irp ? _Irp : Poll->Irp;
65 AFD_DbgPrint(MID_TRACE,("Called (Status %x)\n", Status));
66
67 if (Poll)
68 {
69 KeCancelTimer( &Poll->Timer );
70 RemoveEntryList( &Poll->ListEntry );
72 }
73
74 Irp->IoStatus.Status = Status;
75 Irp->IoStatus.Information =
76 FIELD_OFFSET(AFD_POLL_INFO, Handles) + sizeof(AFD_HANDLE) * PollReq->HandleCount;
77 CopyBackStatus( PollReq->Handles,
78 PollReq->HandleCount );
79 for( i = 0; i < PollReq->HandleCount; i++ ) {
81 (MAX_TRACE,
82 ("Handle(%x): Got %x,%x\n",
83 PollReq->Handles[i].Handle,
84 PollReq->Handles[i].Events,
85 PollReq->Handles[i].Status));
86 }
87 UnlockHandles( AFD_HANDLES(PollReq), PollReq->HandleCount );
88 if( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
89 AFD_DbgPrint(MID_TRACE,("Completing\n"));
92 AFD_DbgPrint(MID_TRACE,("Done\n"));
93}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
VOID UnlockHandles(PAFD_HANDLE HandleArray, UINT HandleCount)
Definition: lock.c:348
VOID UnlockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: lock.c:180
static VOID CopyBackStatus(PAFD_HANDLE HandleArray, UINT HandleCount)
Definition: select.c:34
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
struct _AFD_HANDLE_ AFD_HANDLE
SOCKET Handle
Definition: shared.h:50
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by AfdSelect(), CleanupPendingIrp(), KillSelectsForFCB(), PollReeval(), and SelectTimeout().

◆ UpdatePollWithFCB()

static BOOLEAN UpdatePollWithFCB ( PAFD_ACTIVE_POLL  Poll,
PFILE_OBJECT  FileObject 
)
static

Definition at line 382 of file select.c.

382 {
383 UINT i;
385 UINT Signalled = 0;
387
389
390 for( i = 0; i < PollReq->HandleCount; i++ ) {
391 if( !AFD_HANDLES(PollReq)[i].Handle ) continue;
392
393 FileObject = (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle;
394 FCB = FileObject->FsContext;
395
396 PollReq->Handles[i].Status = PollReq->Handles[i].Events & FCB->PollState;
397 if( PollReq->Handles[i].Status ) {
398 AFD_DbgPrint(MID_TRACE,("Signalling %p with %x\n",
399 FCB, FCB->PollState));
400 Signalled++;
401 }
402 }
403
404 return Signalled ? 1 : 0;
405}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define ASSERT(a)
Definition: mode.c:44

Referenced by PollReeval().

◆ ZeroEvents()

VOID ZeroEvents ( PAFD_HANDLE  HandleArray,
UINT  HandleCount 
)

Definition at line 44 of file select.c.

45 {
46 UINT i;
47
48 for( i = 0; i < HandleCount; i++ ) {
49 HandleArray[i].Status = 0;
50 HandleArray[i].Events = 0;
51 }
52}

Referenced by CleanupPendingIrp(), KillSelectsForFCB(), and SelectTimeout().

Variable Documentation

◆ SelectTimeout

KDEFERRED_ROUTINE SelectTimeout
static

Definition at line 95 of file select.c.

Referenced by AfdSelect().