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

Add basic logic for g_socket #8

Merged
merged 6 commits into from
May 7, 2024
Merged

Conversation

NoobsEnslaver
Copy link

Hi, it's needed for ability to share socket between udpsrc and udpsink - it is common case for NAT traversal

glib/gvalue.go Outdated Show resolved Hide resolved
glib/gsocket.go Outdated Show resolved Hide resolved
glib/glib.go Outdated Show resolved Hide resolved
glib/glib.go Outdated Show resolved Hide resolved
glib/gsocket.go Outdated Show resolved Hide resolved
Copy link
Member

@RSWilli RSWilli left a comment

Choose a reason for hiding this comment

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

These tiny changes prevent very hard to debug memory errors

glib/gsocket.go Outdated Show resolved Hide resolved
glib/gsocket.go Outdated Show resolved Hide resolved
@NoobsEnslaver NoobsEnslaver requested a review from RSWilli May 2, 2024 15:37
@RSWilli
Copy link
Member

RSWilli commented May 3, 2024

It looks like you have to add some build flags to prevent building the GSocket on Windows, so that Windows users can still use the library.

@NoobsEnslaver
Copy link
Author

It looks like you have to add some build flags to prevent building the GSocket on Windows, so that Windows users can still use the library.

let try to fix it with generics.
Problem in that - syscall.Socket returns int in *nix systems, but syscall.Handle -> uintptr -> uint in windows. uint and int - both int and looks like this generic may fix it, but i can't check it local or run pipeline

@RSWilli
Copy link
Member

RSWilli commented May 3, 2024

You could also handle it like the golangs syscall package itself handles the multiple systems: https://cs.opensource.google/go/go/+/refs/tags/go1.22.2:src/syscall/syscall_linux.go;l=1207. If you cannot test it in Windows I would be okay with it if you only provide an implementation for Linux (and MacOS, which already works), and leave the further implementation to someone that can test it. I myself cannot test it either, I fully rely on the GitHub pipeline.

@NoobsEnslaver
Copy link
Author

run pipeline plz, let check windows build. I can't run myself without approval

I think the example you gave will not work because in our case there are no two different functions to call, it is one, but with different types of argument depending on which file will participate in the build. Perhaps we can do without generics by explicitly converting the type to int - this will be ok for windows (uintptr -> int), and will be a truism for linux (int -> int), which may cause warnings, but it's still ok

@RSWilli
Copy link
Member

RSWilli commented May 4, 2024

I think the example you gave will not work because in our case there are no two different functions to call

My proposal was rather: don't provide an implementation for windows. If an implementation for windows is desired, then the function could also have completely different arguments, no need to provide an abstraction to unify the different systems

Copy link
Member

@RSWilli RSWilli left a comment

Choose a reason for hiding this comment

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

It seems to work now in our pipeline. Can you add some docs, please? The I would be happy to merge

glib/gsocket.go Show resolved Hide resolved
@RSWilli RSWilli merged commit 049fa91 into go-gst:main May 7, 2024
4 checks passed
@RSWilli
Copy link
Member

RSWilli commented May 7, 2024

@NoobsEnslaver Thanks for your contribution

@NoobsEnslaver NoobsEnslaver deleted the g_socket branch May 7, 2024 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants