-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Security component listeners added multiple times when reusing the kernel for multiple requests #8244
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
Comments
@pvandommelen Can you check that #8946 fixes the problem for you? |
@fabpot I haven't had the time yet to take a good look at it but the change in ExceptionListener looks suspicious. The leak is in registering the listener while the "fix" would only remove it when an actual exception occurs. I will take a better look sometime this week. |
@pvandommelen You're right, that's why I made another patch after the introduction of the new request finish event: 1b2ef74 |
@pvandommelen how can you receive two requests? just curious also you don't ->send() any of the responses before the terminates |
My code above is not the code I would actually be using. The idea we had that is while symfony is pretty fast, its (classloading, services) initialization isn't. We could have a continuously running (stateful) worker accepting requests and returning responses without shutting down. My initial test using beanstalkd (something from the php react project is probably better) to transfer serialized requests and responses had some promising results performance-wise. Running these tests I came across the leaks. Not sure if this will ever be used since I haven't spend much time on it since, but it's still very cool. |
oh so you are basically saying to have multiple frontends, well at least one and the one front controller consuming a queue/socket with requests! So to parallelize and max performance I guess. Very nice! |
Looks good to me. |
I am trying to re-use the $kernel object like this:
This is obviously a use-case which not too many have tried, but here I am. I was surprised that most components seem to be well behaved in this regard. Currently I have only found two initializations in the security component that incorrectly add listeners.
I would like to propose two guidelines for initialization in general:
$this->is_initialized
(or whatever) instead of checking forHttpKernelInterface::MASTER_REQUEST
ContextListener::handle() does not comply with the first. It registers a listener on every master request causing a leak. Easy fix.
Firewall::onKernelRequest() does not with the second. It registers all applicable listeners through
getListeners($event->getRequest())
on every master request causing a leak and potentially incorrect listeners from another firewall to be applied. A proper solution would require a restructure on how different firewalls exist within an application I think. I'm a bit out of my league here, but I think a general exception listener with a reference to the configuration should do it.A different solution might consist of clearing the old listeners before registring the new, but that seems uglier to me.
What obvious things did I miss? Is everyone ok with enabling a single kernel to handle multiple requests?
The text was updated successfully, but these errors were encountered: