Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Oct 31, 2024
1 parent 2bfa5a2 commit 68abdae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions bee/net/bpoll_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ namespace bee::net {
bpoll_handle bpoll_create() noexcept {
afd::afd_context ctx;
if (!afd::afd_create(ctx)) {
return retired_fd;
return invalid_bpoll_handle;
}
afd::poller* ep = new (std::nothrow) afd::poller(std::move(ctx));
if (ep == NULL) {
afd::afd_destroy(ctx);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return retired_fd;
return invalid_bpoll_handle;
}
return (fd_t)ep;
}

bool bpoll_close(bpoll_handle handle) noexcept {
if (handle == retired_fd) {
if (handle == invalid_bpoll_handle) {
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
Expand All @@ -29,7 +29,7 @@ namespace bee::net {
}

bool bpoll_ctl_add(bpoll_handle handle, fd_t socket, const bpoll_event_t& event) noexcept {
if (handle == retired_fd) {
if (handle == invalid_bpoll_handle) {
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
Expand All @@ -47,7 +47,7 @@ namespace bee::net {
}

bool bpoll_ctl_mod(bpoll_handle handle, fd_t socket, const bpoll_event_t& event) noexcept {
if (handle == retired_fd) {
if (handle == invalid_bpoll_handle) {
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
Expand All @@ -65,7 +65,7 @@ namespace bee::net {
}

bool bpoll_ctl_del(bpoll_handle handle, fd_t socket) noexcept {
if (handle == retired_fd) {
if (handle == invalid_bpoll_handle) {
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
Expand All @@ -83,7 +83,7 @@ namespace bee::net {
}

int bpoll_wait(bpoll_handle handle, const span<bpoll_event_t>& events, int timeout) noexcept {
if (handle == retired_fd) {
if (handle == invalid_bpoll_handle) {
SetLastError(ERROR_INVALID_HANDLE);
return -1;
}
Expand Down
6 changes: 3 additions & 3 deletions bee/win/afd/afd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ namespace bee::net::afd {
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(ObjectName, Attributes) \
{ sizeof(OBJECT_ATTRIBUTES), NULL, ObjectName, Attributes, NULL, NULL }

static UNICODE_STRING afd__device_name = RTL_CONSTANT_STRING(L"\\Device\\Afd\\Wepoll");
static OBJECT_ATTRIBUTES afd__device_attributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(&afd__device_name, 0);
static UNICODE_STRING afd_device_name = RTL_CONSTANT_STRING(L"\\Device\\Afd\\bee\\epoll");
static OBJECT_ATTRIBUTES afd_device_attributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(&afd_device_name, 0);

static uint32_t bpoll_events_to_afd_events(bpoll_event bpoll_events) noexcept {
uint32_t afd_events = AFD_POLL_LOCAL_CLOSE;
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace bee::net::afd {
return false;
}
IO_STATUS_BLOCK iosb;
NTSTATUS status = NtCreateFile(&ctx.afd_handle, SYNCHRONIZE, &afd__device_attributes, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, kFILE_OPEN, 0, NULL, 0);
NTSTATUS status = NtCreateFile(&ctx.afd_handle, SYNCHRONIZE, &afd_device_attributes, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, kFILE_OPEN, 0, NULL, 0);
if (status != NTSTATUS_SUCCESS) {
CloseHandle(ctx.iocp_handle);
SetLastError(RtlNtStatusToDosError(status));
Expand Down

0 comments on commit 68abdae

Please sign in to comment.