Skip to content

Login: Don't block other pages while connecting to the server - #1369

Open
landsman wants to merge 2 commits into
vrana:mainfrom
landsman:login-session-lock
Open

landsman wants to merge 2 commits into
vrana:mainfrom
landsman:login-session-lock

Conversation

@landsman

Copy link
Copy Markdown
Contributor

The session stays locked while Driver::connect() runs, so a login to a server that accepts the connection but never answers blocks every other page of the session until the connect gives up. Queries already release the lock by stop_session(); this moves that call before the connect. The two writes after it, the CSRF token and the token for the next attempt in auth_error(), reopen the session by restart_session() first, as auth_error() already does before add_invalid_login().

To reproduce, it needs a server running more than one request at a time; plain php -S serializes the requests anyway:

php -r '$s = stream_socket_server("tcp://127.0.0.1:5433"); $c = stream_socket_accept($s, -1); sleep(30);' &
PHP_CLI_SERVER_WORKERS=2 php -S localhost:8000

Log in to PostgreSQL at 127.0.0.1:5433, and while it waits, open Adminer in another tab. That tab took 29 s before and 0.003 s after (PHP 8.4).

A plugin writing to $_SESSION in login() without restart_session() would lose the write now; login-otp already calls it.

@vrana

vrana commented Oct 25, 2026

Copy link
Copy Markdown
Owner

This would be a nice improvement but it's slightly more complicated. E.g. password_required() or drivers (igdb.php) write to a session here.

@landsman

landsman commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Right, thanks. Now the session is closed only for Driver::connect() and reopened right after it, so password_required(), login() and plugins write to it as before. The two extra restart_session() calls are gone.

I checked every session write. Of the drivers' connect() functions, only igdb writes to the session (the cached token), so it now calls restart_session() first, like the other writes made after stop_session(). Reading $_SESSION there still works, e.g. in mongo.

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.

2 participants