src: rename 'afd_helper' to the more descriptive 'afd_device'

This commit is contained in:
Bert Belder 2020-05-26 18:42:36 +02:00
parent 78bb46e678
commit 07af653b17
No known key found for this signature in database
GPG Key ID: 7A77887B2E2ED461
5 changed files with 28 additions and 28 deletions

View File

@ -9,24 +9,24 @@
#define IOCTL_AFD_POLL 0x00012024 #define IOCTL_AFD_POLL 0x00012024
static UNICODE_STRING afd__helper_name = static UNICODE_STRING afd__device_name =
RTL_CONSTANT_STRING(L"\\Device\\Afd\\Wepoll"); RTL_CONSTANT_STRING(L"\\Device\\Afd\\Wepoll");
static OBJECT_ATTRIBUTES afd__helper_attributes = static OBJECT_ATTRIBUTES afd__device_attributes =
RTL_CONSTANT_OBJECT_ATTRIBUTES(&afd__helper_name, 0); RTL_CONSTANT_OBJECT_ATTRIBUTES(&afd__device_name, 0);
int afd_create_helper_handle(HANDLE iocp_handle, int afd_create_device_handle(HANDLE iocp_handle,
HANDLE* afd_helper_handle_out) { HANDLE* afd_device_handle_out) {
HANDLE afd_helper_handle; HANDLE afd_device_handle;
IO_STATUS_BLOCK iosb; IO_STATUS_BLOCK iosb;
NTSTATUS status; NTSTATUS status;
/* By opening \Device\Afd without specifying any extended attributes, we'll /* By opening \Device\Afd without specifying any extended attributes, we'll
* get a handle that lets us talk to the AFD driver, but that doesn't have an * get a handle that lets us talk to the AFD driver, but that doesn't have an
* associated endpoint (so it's not a socket). */ * associated endpoint (so it's not a socket). */
status = NtCreateFile(&afd_helper_handle, status = NtCreateFile(&afd_device_handle,
SYNCHRONIZE, SYNCHRONIZE,
&afd__helper_attributes, &afd__device_attributes,
&iosb, &iosb,
NULL, NULL,
0, 0,
@ -38,22 +38,22 @@ int afd_create_helper_handle(HANDLE iocp_handle,
if (status != STATUS_SUCCESS) if (status != STATUS_SUCCESS)
return_set_error(-1, RtlNtStatusToDosError(status)); return_set_error(-1, RtlNtStatusToDosError(status));
if (CreateIoCompletionPort(afd_helper_handle, iocp_handle, 0, 0) == NULL) if (CreateIoCompletionPort(afd_device_handle, iocp_handle, 0, 0) == NULL)
goto error; goto error;
if (!SetFileCompletionNotificationModes(afd_helper_handle, if (!SetFileCompletionNotificationModes(afd_device_handle,
FILE_SKIP_SET_EVENT_ON_HANDLE)) FILE_SKIP_SET_EVENT_ON_HANDLE))
goto error; goto error;
*afd_helper_handle_out = afd_helper_handle; *afd_device_handle_out = afd_device_handle;
return 0; return 0;
error: error:
CloseHandle(afd_helper_handle); CloseHandle(afd_device_handle);
return_map_error(-1); return_map_error(-1);
} }
int afd_poll(HANDLE afd_helper_handle, int afd_poll(HANDLE afd_device_handle,
AFD_POLL_INFO* poll_info, AFD_POLL_INFO* poll_info,
IO_STATUS_BLOCK* io_status_block) { IO_STATUS_BLOCK* io_status_block) {
NTSTATUS status; NTSTATUS status;
@ -62,7 +62,7 @@ int afd_poll(HANDLE afd_helper_handle,
assert(io_status_block != NULL); assert(io_status_block != NULL);
io_status_block->Status = STATUS_PENDING; io_status_block->Status = STATUS_PENDING;
status = NtDeviceIoControlFile(afd_helper_handle, status = NtDeviceIoControlFile(afd_device_handle,
NULL, NULL,
NULL, NULL,
io_status_block, io_status_block,
@ -81,7 +81,7 @@ int afd_poll(HANDLE afd_helper_handle,
return_set_error(-1, RtlNtStatusToDosError(status)); return_set_error(-1, RtlNtStatusToDosError(status));
} }
int afd_cancel_poll(HANDLE afd_helper_handle, int afd_cancel_poll(HANDLE afd_device_handle,
IO_STATUS_BLOCK* io_status_block) { IO_STATUS_BLOCK* io_status_block) {
NTSTATUS cancel_status; NTSTATUS cancel_status;
IO_STATUS_BLOCK cancel_iosb; IO_STATUS_BLOCK cancel_iosb;
@ -92,7 +92,7 @@ int afd_cancel_poll(HANDLE afd_helper_handle,
return 0; return 0;
cancel_status = cancel_status =
NtCancelIoFileEx(afd_helper_handle, io_status_block, &cancel_iosb); NtCancelIoFileEx(afd_device_handle, io_status_block, &cancel_iosb);
/* NtCancelIoFileEx() may return STATUS_NOT_FOUND if the operation completed /* NtCancelIoFileEx() may return STATUS_NOT_FOUND if the operation completed
* just before calling NtCancelIoFileEx(). This is not an error. */ * just before calling NtCancelIoFileEx(). This is not an error. */

View File

@ -29,13 +29,13 @@ typedef struct _AFD_POLL_INFO {
AFD_POLL_HANDLE_INFO Handles[1]; AFD_POLL_HANDLE_INFO Handles[1];
} AFD_POLL_INFO, *PAFD_POLL_INFO; } AFD_POLL_INFO, *PAFD_POLL_INFO;
WEPOLL_INTERNAL int afd_create_helper_handle(HANDLE iocp_handle, WEPOLL_INTERNAL int afd_create_device_handle(HANDLE iocp_handle,
HANDLE* afd_helper_handle_out); HANDLE* afd_device_handle_out);
WEPOLL_INTERNAL int afd_poll(HANDLE afd_helper_handle, WEPOLL_INTERNAL int afd_poll(HANDLE afd_device_handle,
AFD_POLL_INFO* poll_info, AFD_POLL_INFO* poll_info,
IO_STATUS_BLOCK* io_status_block); IO_STATUS_BLOCK* io_status_block);
WEPOLL_INTERNAL int afd_cancel_poll(HANDLE afd_helper_handle, WEPOLL_INTERNAL int afd_cancel_poll(HANDLE afd_device_handle,
IO_STATUS_BLOCK* io_status_block); IO_STATUS_BLOCK* io_status_block);
#endif /* WEPOLL_AFD_H_ */ #endif /* WEPOLL_AFD_H_ */

View File

@ -15,7 +15,7 @@ static const size_t POLL_GROUP__MAX_GROUP_SIZE = 32;
typedef struct poll_group { typedef struct poll_group {
port_state_t* port_state; port_state_t* port_state;
queue_node_t queue_node; queue_node_t queue_node;
HANDLE afd_helper_handle; HANDLE afd_device_handle;
size_t group_size; size_t group_size;
} poll_group_t; } poll_group_t;
@ -32,7 +32,7 @@ static poll_group_t* poll_group__new(port_state_t* port_state) {
queue_node_init(&poll_group->queue_node); queue_node_init(&poll_group->queue_node);
poll_group->port_state = port_state; poll_group->port_state = port_state;
if (afd_create_helper_handle(iocp_handle, &poll_group->afd_helper_handle) < if (afd_create_device_handle(iocp_handle, &poll_group->afd_device_handle) <
0) { 0) {
free(poll_group); free(poll_group);
return NULL; return NULL;
@ -45,7 +45,7 @@ static poll_group_t* poll_group__new(port_state_t* port_state) {
void poll_group_delete(poll_group_t* poll_group) { void poll_group_delete(poll_group_t* poll_group) {
assert(poll_group->group_size == 0); assert(poll_group->group_size == 0);
CloseHandle(poll_group->afd_helper_handle); CloseHandle(poll_group->afd_device_handle);
queue_remove(&poll_group->queue_node); queue_remove(&poll_group->queue_node);
free(poll_group); free(poll_group);
} }
@ -54,8 +54,8 @@ poll_group_t* poll_group_from_queue_node(queue_node_t* queue_node) {
return container_of(queue_node, poll_group_t, queue_node); return container_of(queue_node, poll_group_t, queue_node);
} }
HANDLE poll_group_get_afd_helper_handle(poll_group_t* poll_group) { HANDLE poll_group_get_afd_device_handle(poll_group_t* poll_group) {
return poll_group->afd_helper_handle; return poll_group->afd_device_handle;
} }
poll_group_t* poll_group_acquire(port_state_t* port_state) { poll_group_t* poll_group_acquire(port_state_t* port_state) {

View File

@ -16,6 +16,6 @@ WEPOLL_INTERNAL void poll_group_delete(poll_group_t* poll_group);
WEPOLL_INTERNAL poll_group_t* poll_group_from_queue_node( WEPOLL_INTERNAL poll_group_t* poll_group_from_queue_node(
queue_node_t* queue_node); queue_node_t* queue_node);
WEPOLL_INTERNAL HANDLE WEPOLL_INTERNAL HANDLE
poll_group_get_afd_helper_handle(poll_group_t* poll_group); poll_group_get_afd_device_handle(poll_group_t* poll_group);
#endif /* WEPOLL_POLL_GROUP_H_ */ #endif /* WEPOLL_POLL_GROUP_H_ */

View File

@ -54,7 +54,7 @@ static inline void sock__free(sock_state_t* sock_state) {
static int sock__cancel_poll(sock_state_t* sock_state) { static int sock__cancel_poll(sock_state_t* sock_state) {
assert(sock_state->poll_status == SOCK__POLL_PENDING); assert(sock_state->poll_status == SOCK__POLL_PENDING);
if (afd_cancel_poll(poll_group_get_afd_helper_handle(sock_state->poll_group), if (afd_cancel_poll(poll_group_get_afd_device_handle(sock_state->poll_group),
&sock_state->io_status_block) < 0) &sock_state->io_status_block) < 0)
return -1; return -1;
@ -233,7 +233,7 @@ int sock_update(port_state_t* port_state, sock_state_t* sock_state) {
sock_state->poll_info.Handles[0].Events = sock_state->poll_info.Handles[0].Events =
sock__epoll_events_to_afd_events(sock_state->user_events); sock__epoll_events_to_afd_events(sock_state->user_events);
if (afd_poll(poll_group_get_afd_helper_handle(sock_state->poll_group), if (afd_poll(poll_group_get_afd_device_handle(sock_state->poll_group),
&sock_state->poll_info, &sock_state->poll_info,
&sock_state->io_status_block) < 0) { &sock_state->io_status_block) < 0) {
switch (GetLastError()) { switch (GetLastError()) {