8000 Symfony not working on SMB · Issue #45990 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Symfony not working on SMB #45990

New issue
8000

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

Closed
qinshuze opened this issue Apr 11, 2022 · 3 comments
Closed

Symfony not working on SMB #45990

qinshuze opened this issue Apr 11, 2022 · 3 comments

Comments

@qinshuze
Copy link
Contributor

Symfony version(s) affected

6

Description

Hi I am using Symfony 6 and PHP 8.1.4
I share the project over SMB on Windows and mount the project on Linux, but I run into a problem when running the project, accessing the project keeps waiting until it times out; this only happens on SMB shared directories, running locally when everything works.
How can I get the project to work properly on an SMB shared folder?
English is not my native language; please excuse typing errors.

How to reproduce

Share the project folder via SMB on Windows10, mount the shared folder in Linux (Debian11) and run it
Mount command: mount -o uid=1000,gid=1000,username=qsz,password=123456,rsize=1048576,wsize=1048576 -t cifs //192.1 68.100.1/Web/mnt/web/

Possible Solution

After investigation, it is found that when the program executes this code under the vendor\symfony\http-kernel\Kernel.php file, it will always get stuck
image
Try adding flock($lock, \LOCK_UN); before if (!flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) { and the program works fine
image

Additional Context

No response

@nicolas-grekas
Copy link
Member

Can you try this patch? Does it work around the issue on SMB?

--- a/src/Symfony/Component/HttpKernel/Kernel.php
+++ b/src/Symfony/Component/HttpKernel/Kernel.php
@@ -528,9 +528,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
             is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true);
 
             if ($lock = fopen($cachePath.'.lock', 'w')) {
-                flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock);
-
-                if (!flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
+                if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
                     fclose($lock);
                     $lock = null;
                 } elseif (!is_file($cachePath) || !\is_object($this->container = include $cachePath)) {

@nicolas-grekas
Copy link
Member

(please send a PR on branch 4.4 if that works)

@qinshuze
Copy link
Contributor Author
qinshuze commented Apr 12, 2022

Yes this solves my problem with SMB

Can you try this patch? Does it work around the issue on SMB?

--- a/src/Symfony/Component/HttpKernel/Kernel.php 
+++ b/src/Symfony/Component/HttpKernel/Kernel.php 
@@ -528,9 +528,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
             is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true);
 
             if ($lock = fopen($cachePath.'.lock', 'w')) {
-                flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock);
- 
-                 if (!flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) { 
+                 if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \ LOCK_SH : \LOCK_EX)) {
                     fclose($lock);
                     $lock = null;
                 } elseif (!is_file($cachePath) || !\is_object($this->container = include $cachePath)) {

qinshuze added a commit to qinshuze/symfony that referenced this issue Apr 12, 2022
nicolas-grekas added a commit that referenced this issue Apr 12, 2022
This PR was merged into the 4.4 branch.

Discussion
----------

[HttpKernel] Fix Symfony not working on SMB share

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #45990
| License       | MIT
| Doc PR        | -

Commits
-------

1ff7ebc Fix Symfony not working on SMB share #45990
nicolas-grekas added a commit that referenced this issue Apr 12, 2022
* 4.4:
  [Workflow] Catch error when trying to get an uninitialized marking
  Add missing license header
  Use reference date in reverse transform Fixes #40997
  Fix env resolution in lock configuration
  Fix Symfony not working on SMB share #45990
  [Cache] make LockRegistry use static properties instead of static variables
  fix: return-path has higher priority for envelope address than from address (fixes #41322)
  [HttpClient] Fix sending content-length when streaming the body
  [Console] Header with column max width is now well wrap with separator
  [DependencyInjection] Add TaggedIteratorArgument unit tests
nicolas-grekas added a commit that referenced this issue Apr 12, 2022
* 5.4: (21 commits)
  Add missing license header
  [Workflow] Catch error when trying to get an uninitialized marking
  Add missing license header
  Allow usage of Provider domains if possible
  Use reference date in reverse transform Fixes #40997
  Fix env resolution in lock configuration
  Fix Symfony not working on SMB share #45990
  [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver
  [Cache] make LockRegistry use static properties instead of static variables
  fix: return-path has higher priority for envelope address than from address (fixes #41322)
  [HttpClient] Fix sending content-length when streaming the body
  [Console] Header with column max width is now well wrap with separator
  Fix use_cookies framework session configuration
  [FrameworkBundle] [Command] Fix `debug:router --no-interaction` error …
  [Intl] Update the ICU data to 71.1 - 5.4
  [Intl] Update the ICU data to 71.1 - 4.4
  Add tests to messenger connection get for OraclePlatform
  [RateLimiter] Adding default empty value
  [DependencyInjection] Add TaggedIteratorArgument unit tests
  [Process] Fix Process::getEnv() when setEnv() hasn't been called before
  ...
nicolas-grekas added a commit that referenced this issue Apr 12, 2022
* 6.0: (22 commits)
  Add missing license header
  Add missing license header
  [Workflow] Catch error when trying to get an uninitialized marking
  Add missing license header
  Allow usage of Provider domains if possible
  Use reference date in reverse transform Fixes #40997
  Fix env resolution in lock configuration
  Fix Symfony not working on SMB share #45990
  [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver
  [Cache] make LockRegistry use static properties instead of static variables
  fix: return-path has higher priority for envelope address than from address (fixes #41322)
  [HttpClient] Fix sending content-length when streaming the body
  [Console] Header with column max width is now well wrap with separator
  Fix use_cookies framework session configuration
  [FrameworkBundle] [Command] Fix `debug:router --no-interaction` error …
  [Intl] Update the ICU data to 71.1 - 5.4
  [Intl] Update the ICU data to 71.1 - 4.4
  Add tests to messenger connection get for OraclePlatform
  [RateLimiter] Adding default empty value
  [DependencyInjection] Add TaggedIteratorArgument unit tests
  ...
PhilETaylor pushed a commit to PhilETaylor/symfony that referenced this issue Sep 6, 2023
* 4.4:
  [Workflow] Catch error when trying to get an uninitialized marking
  Add missing license header
  Use reference date in reverse transform Fixes symfony#40997
  Fix env resolution in lock configuration
  Fix Symfony not working on SMB share symfony#45990
  [Cache] make LockRegistry use static properties instead of static variables
  fix: return-path has higher priority for envelope address than from address (fixes symfony#41322)
  [HttpClient] Fix sending content-length when streaming the body
  [Console] Header with column max width is now well wrap with separator
  [DependencyInjection] Add TaggedIteratorArgument unit tests
PhilETaylor pushed a commit to PhilETaylor/symfony that referenced this issue Sep 6, 2023
* 5.4: (21 commits)
  Add missing license header
  [Workflow] Catch error when trying to get an uninitialized marking
  Add missing license header
  Allow usage of Provider domains if possible
  Use reference date in reverse transform Fixes symfony#40997
  Fix env resolution in lock configuration
  Fix Symfony not working on SMB share symfony#45990
  [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver
  [Cache] make LockRegistry use static properties instead of static variables
  fix: return-path has higher priority for envelope address than from address (fixes symfony#41322)
  [HttpClient] Fix sending content-length when streaming the body
  [Console] Header with column max width is now well wrap with separator
  Fix use_cookies framework session configuration
  [FrameworkBundle] [Command] Fix `debug:router --no-interaction` error …
  [Intl] Update the ICU data to 71.1 - 5.4
  [Intl] Update the ICU data to 71.1 - 4.4
  Add tests to messenger connection get for OraclePlatform
  [RateLimiter] Adding default empty value
  [DependencyInjection] Add TaggedIteratorArgument unit tests
  [Process] Fix Process::getEnv() when setEnv() hasn't been called before
  ...
PhilETaylor pushed a commit to PhilETaylor/symfony that referenced this issue Sep 6, 2023
* 6.0: (22 commits)
  Add missing license header
  Add missing license header
  [Workflow] Catch error when trying to get an uninitialized marking
  Add missing license header
  Allow usage of Provider domains if possible
  Use reference date in reverse transform Fixes symfony#40997
  Fix env resolution in lock configuration
  Fix Symfony not working on SMB share symfony#45990
  [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver
  [Cache] make LockRegistry use static properties instead of static variables
  fix: return-path has higher priority for envelope address than from address (fixes symfony#41322)
  [HttpClient] Fix sending content-length when streaming the body
  [Console] Header with column max width is now well wrap with separator
  Fix use_cookies framework session configuration
  [FrameworkBundle] [Command] Fix `debug:router --no-interaction` error …
  [Intl] Update the ICU data to 71.1 - 5.4
  [Intl] Update the ICU data to 71.1 - 4.4
  Add tests to messenger connection get for OraclePlatform
  [RateLimiter] Adding default empty value
  [DependencyInjection] Add TaggedIteratorArgument unit tests
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0