-
Notifications
You must be signed in to change notification settings - Fork 182
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
What is the best way to let libulfius interact with libpq? #264
Comments
If someone is interested to protect a critical resource like the Cheers! |
Hello, In my experience, a mutex is the best way to ensure the stability, but I don't program with the intention to provide a highly performant solution, so this may not be the best way for your needs. The way I see it, you can try different approaches:
My best guess is to ask postgresql people, they have several mailing lists that may help you: https://www.postgresql.org/list/ I also suggest to open a discussion rather than an issue for these kind of questions. The discussions are a better format for interaction and feedbacks. |
Dear folks, Thank you so much for providing and maintaining this repository! I am using it together with the
libqp
API to access a PostgreSQL database. According to libpq documentation I cannot issue concurrent commands from different threads through the samePGconn
connection object. So, either I protect thePGconn
connection object from concurrent calls from different threads like @babelouest mentioned in issue #263 or I use a dedicatedPGconn
connection object for each and every client thread. In #263 @babelouest also mentioned that every client receives a dedicated thread as long as the default configuration oflibmicrohttpd
is not altered.My question: Securing the single
PGconn
connection object with something like a Mutex does introduce latency to the system for waiting until the protected resource is available again. I could avoid latency if I provide a dedicatedPGconn
connection object to every client thread. Is that possible?My second question: I could provide a dedicated
PGconn
connection object to the callback function of an API endpoint using theuser_data
parameter of the ulfius_add_endpoint_by_value function. However, this is not solving this issue. Two different client thread calling the same endpoint would use the samePGconn
connection object. I could create thePGconn
connection object inside thecallback_function
parameter. However, this introdues latency as aPGconn
connection object is created for each and every client request. Is this reasoning correct?Appreciate!
Cheers!
The text was updated successfully, but these errors were encountered: