How to catch session entry?
Added by Artem NA over 1 year ago
In the thread pool model (production installation) I need to perform some actions when some thread from the pool starts to service given session (WApplication).
Where I can catch the moment when thread switches sessions (starts to service given app and releases given WApplication)?
Replies
RE: How to catch session entry? - Added by Koen Deforche over 1 year ago
Hey Artem
Depending on what you actually want to do, specializing WApplication::notify() and calling the base implementation surrounded by your code should be sufficient. The only caveat is that this does not catch the WApplication construction itself (for obvious reasons).
Regards,
koen
RE: How to catch session entry? - Added by Artem NA over 1 year ago
I am trying to allocate DB connection from pool of connections to current session. Thank you - this is what I needed.
RE: How to catch session entry? - Added by Artem NA over 1 year ago
Is it possible to catch moment of process (or thread) creation for multithreaded mode (FastCGI)?
RE: How to catch session entry? - Added by Artem NA over 1 year ago
Instead of having pool of DB connections and assign session, process and connection in an unpredictable manner I want to attach connection to process and have same number of connections as number of prosesses. So only processes and sessions assigned on each request.
RE: How to catch session entry? - Added by Koen Deforche over 1 year ago
Hey Artem,
The main() routine is your entry point for a new process. The only caveat is that Wt in FastCGI mode will also create a number of intermediate proxy processes, and thus you may have a few connections too many to your database. Currently there is no documented way to see whether a process is a proxy process or an actual session process.
W.r.t. to threads, I would recommend to use thread specific data to associate data with a single thread.
Regards,
koen