Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows named pipes #236

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions server/lib/named_pipe/named_pipe_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ class NamedPipeListener : public INamedPipeListener {

if (!Connect(&listener_data)) return;

if (thread_active_) on_event_callback_({NamedPipeListenerEventType::ClientConnected});

while (thread_active_) {
switch (WaitForSingleObject(listener_data.overlap.hEvent, 5)) {
case WAIT_OBJECT_0:
Expand Down Expand Up @@ -177,6 +175,13 @@ class NamedPipeListener : public INamedPipeListener {
LogError("GetOverlappedResult failed");
break;
}

if (listener_data.state == NamedPipeListenerState::Connecting) {
if (thread_active_) {
on_event_callback_({NamedPipeListenerEventType::ClientConnected});
}
}

listener_data.state = NamedPipeListenerState::Reading;
}
}
Expand Down Expand Up @@ -205,6 +210,7 @@ class NamedPipeListener : public INamedPipeListener {
}
}

DisconnectNamedPipe(hPipeInst); // Not 100% sure this is needed, but winapi seems to like this better
CloseHandle(hPipeInst);
CloseHandle(hEvent);
}
Expand All @@ -216,4 +222,4 @@ class NamedPipeListener : public INamedPipeListener {

std::function<void(NamedPipeListenerEvent)> on_event_callback_;
std::function<void(T*)> on_data_callback_;
};
};
Loading