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 same PGconn connection object. So, either I protect the PGconn connection object from concurrent calls from different threads like @babelouest mentioned in issue #263 or I use a dedicated PGconn 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 of libmicrohttpd 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 dedicated PGconn 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 the user_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 same PGconn connection object. I could create the PGconn connection object inside the callback_function parameter. However, this introdues latency as a PGconn connection object is created for each and every client request. Is this reasoning correct?
Appreciate!
Cheers!
Dear folks, Thank you so much for providing and maintaining this repository! I am using it together with the
libqpAPI to access a PostgreSQL database. According to libpq documentation I cannot issue concurrent commands from different threads through the samePGconnconnection object. So, either I protect thePGconnconnection object from concurrent calls from different threads like @babelouest mentioned in issue #263 or I use a dedicatedPGconnconnection 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 oflibmicrohttpdis not altered.My question: Securing the single
PGconnconnection 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 dedicatedPGconnconnection object to every client thread. Is that possible?My second question: I could provide a dedicated
PGconnconnection object to the callback function of an API endpoint using theuser_dataparameter 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 samePGconnconnection object. I could create thePGconnconnection object inside thecallback_functionparameter. However, this introdues latency as aPGconnconnection object is created for each and every client request. Is this reasoning correct?Appreciate!
Cheers!