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

Verify that the pgrx active thread is actually the main thread #1319

Merged

Conversation

thomcc
Copy link
Contributor

@thomcc thomcc commented Oct 2, 2023

Unrelated to my other work, but this has bugged me for a while and I figured I'd fix it.

Comment on lines +56 to +60
// Note that this returns `-1` in some error conditions.
//
// In these cases we are almost certainly not the main thread, but
// we don't know -- it's better for this function to return `None`
// in cases of uncertainty.
Copy link
Member

Choose a reason for hiding this comment

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

They claim this is about the thread not finishing initialization? https://opensource.apple.com/source/libpthread/libpthread-218.1.3/man/pthread_main_np.3.auto.html

//! this by remembering the first thread to call into postgres functions, and
//! panicking if we're called from a different thread.
//! this by remembering the first thread to call into postgres functions (the
//! "active thread" in some comments), and panicking if we're called from a
Copy link
Member

Choose a reason for hiding this comment

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

and also the big static ACTIVE_THREAD.... ^^;

@workingjubilee workingjubilee merged commit b71006c into pgcentralfoundation:develop Oct 12, 2023
17 of 18 checks passed
@workingjubilee
Copy link
Member

cc @LuminousMonkey By the way, is there something more clever we could be doing here for illumos?

@LuminousMonkey
Copy link
Contributor

@workingjubilee Sorry, I'm not sure to be honest. I only knew the one change I had to do so I could complete it on a Illumos machine. My working knowledge of things like this is minimal at best.

@thomcc thomcc deleted the main_thread_check branch December 23, 2023 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants