Skip to content
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

Close connections on shutdown #415

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Resources/config/session.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parameters>

<services>
<service id="snc_redis.session.handler" class="%snc_redis.session.handler.class%">
<service id="snc_redis.session.handler" class="%snc_redis.session.handler.class%" public="true">
<argument type="service" id="snc_redis.session.client" />
<argument>%session.storage.options%</argument>
<argument>%snc_redis.session.prefix%</argument>
Expand Down
13 changes: 13 additions & 0 deletions SncRedisBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,17 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new MonologPass());
$container->addCompilerPass(new SwiftMailerPass());
}

/**
* {@inheritDoc}
*/
public function shutdown()
{
// Close session handler connection to avoid using up all available connection slots in tests
if ($this->container->has('snc_redis.session.handler')) {
if (!method_exists($this->container, 'initialized') || $this->container->initialized('snc_redis.session.handler')) {
$this->container->get('snc_redis.session.handler')->close();
}
}
}
}