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
File session expire when browser sends multiple concurrent requests #146
Comments
Maybe a better solution would be something like this (instead of QReadWriteLock): |
Thank you, but do we really need 2 locks (one for processes and one for threads) ? In current implementation the rwLock is global static variable, so: |
2 locks are needed.
It's my compromise. |
OK, one more question, why tf_lockfile() doesn't have implementation for Windows ? |
It seems open() function locks against opening by other processes on Qt/Windows, so the function includes locking of the file. |
App server (tadpole.exe) of TreeFrog is multiprocessing and multithreading. application.ini:
|
Session still expires, but not as often as before. I think QReadLocker/QWriteLocker should be placed before file is open. BTW: You mention than 2 locks are needed. I suppose you mean WinAPI LockFile that blocks only processes. But take a look at source code of QLockedFile. They don't use LockFile, but named mutexes. Here is example: |
Thanks! Try this setting in application.ini;
|
Session still expires. It's because object destruction order is wrong. ~QWriteLocker() <- releases lock If we move QReadLocker/QWriteLocker before QFile like this: QWriteLocker locker(&rwLock); // lock for threads the destruction order would be OK: ~QFile() <- flushes data to file |
Finally fixed, thank you very much for help ! |
Thank you, too. |
This happens when browser sends to treefrog multiple concurrent requests and each access session stored in file. One of the action threads try to write to file session, and another one reads session from the file at the same time.
In treefrog.log there is ERROR: Failed to load a session from the file store, and then session id is regenerated.
In debugger QDataStream::status() returned QDataStream::ReadPastEnd
Please add QWriteLocker in TSessionFileStore::store() just before session in written, and QReadLocker in TSessionFileStore::find() - tried this and worked for me.
Config:
Windows 10 x64
Qt 5.9 +MSVC 2015 32bit
TreeFrog 1.17.0
application.ini:
Session.StoreType=file
Session.AutoIdRegeneration=false
Session.LifeTime=0
Session.CookiePath=/
Session.GcProbability=100
Session.GcMaxLifeTime=1800
The text was updated successfully, but these errors were encountered: