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

Windows support for the sidecar #305

Merged
merged 41 commits into from
Feb 14, 2024
Merged

Windows support for the sidecar #305

merged 41 commits into from
Feb 14, 2024

Conversation

bwoebi
Copy link
Contributor

@bwoebi bwoebi commented Feb 6, 2024

Adds NamedPipes and spawning of the sidecar process for windows support.

pawelchcki and others added 30 commits February 14, 2023 15:31
spawn working on windows
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
@bwoebi bwoebi force-pushed the sidecar-windows branch 4 times, most recently from b122789 to 3161803 Compare February 7, 2024 18:30
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Copy link
Contributor

@gleocadie gleocadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

Copy link
Contributor

@bantonsson bantonsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Only nits.

impl ShmHandle {
pub fn new(size: usize) -> anyhow::Result<ShmHandle> {
// If one uses null_mut() for the name, DuplicateHandle will emit a very confusing "The system cannot find the file specified. (os error 2)".
// It seems like DuplicateHandle requires a name to re-open the FileMapping within another process. Oh well. Let's generate an unique one.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very long lines.


impl NamedShmHandle {
fn format_name(path: &CString) -> CString {
// Global\ namespace is reserved for Session ID 0. We cannot rely on our PHP process having permissions to write to Global\.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Global\ twice in this comment (and it's long).

};

let socket_path = self.socket_path.clone();
// Have a ProcessHandle::Getter() so that we don't immediately block in case the sidecar is still starting up, but only the first time we want to submit shared memory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More long comments

Ok(Channel::from_client_handle_and_pid(
unsafe { OwnedHandle::from_raw_handle(pipe) },
ProcessHandle::Getter(Box::new(move || {
// Await the shared memory handle which will contain the pid of the sidecar - it may not be immediately available during startup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here as well

use super::ChannelMetadata;

#[derive(Debug)]
#[pin_project(project = NamedPipeProject)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to add some comments and/or links to docs explaining projections and structural pinning for ppl unfamiliar with the code base and Rust.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
…dows

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
@bwoebi bwoebi force-pushed the sidecar-windows branch 3 times, most recently from d3f73c8 to 84411b3 Compare February 13, 2024 13:54
@github-actions github-actions bot removed the ci-build label Feb 14, 2024
@bwoebi bwoebi merged commit 2f211cb into main Feb 14, 2024
19 checks passed
@bantonsson bantonsson deleted the sidecar-windows branch March 7, 2024 07:16
ivoanjo added a commit that referenced this pull request Mar 11, 2024
…C` helper

**What does this PR do?**

This PR introduces a new `DDOG_CHARSLICE_C_BARE` helper, as well
as undoes the change to `DDOG_CHARSLICE_C` from
https://github.com/DataDog/libdatadog/pull/305/files#diff-5c00b9c49c81bf0d0a754e0bcc6e0add4fe849bf0ea4a4d1ebfac8f698150f0b

There are now two helpers: `DDOG_CHARSLICE_C` that includes the
`(ddog_CharSlice)` cast and `DDOG_CHARSLICE_C_BARE` which doesn't.

**Motivation:**

In a nutshell @bwoebi explained to me that on Windows there's times
where you need to use `(ddog_CharSlice) {.ptr = ..., .len = ...}` and
others where you need to use `{.ptr = ..., .len = ...}` and cannot
include the cast.

Thus in #305 we tweaked the helper to never have `(ddog_CharSlice)`,
with the intention of using `(ddog_CharSlice) DDOG_CHARSLICE_C(...)`
some times, and `DDOG_CHARSLICE_C(...)` the other times.

But... this had the downside of making some of our Ruby Profiler code
really ugly, as we'd need to move from `DDOG_CHARSLICE_C` to
`(CharSlice) DDOG_CHARSLICE_C` in a lot of cases.

Thus, this PR introduces one helper for each variant, so that
we always have a nice user-friendly option for each case, and avoid
needing to sprinkle casts.

**Additional Notes:**

Arghhh C/C++ you always manage to be weird and annoying.

**How to test the change?**

I've tested this change by compiling the Ruby profiler to use this
branch of libdatadog, and validating that it compiles successfully
on Linux.
bantonsson pushed a commit that referenced this pull request Mar 25, 2024
…C` helper

**What does this PR do?**

This PR introduces a new `DDOG_CHARSLICE_C_BARE` helper, as well
as undoes the change to `DDOG_CHARSLICE_C` from
https://github.com/DataDog/libdatadog/pull/305/files#diff-5c00b9c49c81bf0d0a754e0bcc6e0add4fe849bf0ea4a4d1ebfac8f698150f0b

There are now two helpers: `DDOG_CHARSLICE_C` that includes the
`(ddog_CharSlice)` cast and `DDOG_CHARSLICE_C_BARE` which doesn't.

**Motivation:**

In a nutshell @bwoebi explained to me that on Windows there's times
where you need to use `(ddog_CharSlice) {.ptr = ..., .len = ...}` and
others where you need to use `{.ptr = ..., .len = ...}` and cannot
include the cast.

Thus in #305 we tweaked the helper to never have `(ddog_CharSlice)`,
with the intention of using `(ddog_CharSlice) DDOG_CHARSLICE_C(...)`
some times, and `DDOG_CHARSLICE_C(...)` the other times.

But... this had the downside of making some of our Ruby Profiler code
really ugly, as we'd need to move from `DDOG_CHARSLICE_C` to
`(CharSlice) DDOG_CHARSLICE_C` in a lot of cases.

Thus, this PR introduces one helper for each variant, so that
we always have a nice user-friendly option for each case, and avoid
needing to sprinkle casts.

**Additional Notes:**

Arghhh C/C++ you always manage to be weird and annoying.

**How to test the change?**

I've tested this change by compiling the Ruby profiler to use this
branch of libdatadog, and validating that it compiles successfully
on Linux.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants