In services::ensureDirectoryPathExists there is a while loop that checks to see if a directory exists and if it doesn't then it tries to create it for you. The directories follow the format of files/storage/atoms or files/storage/atoms_1 etc (we have been using it in conjunction with Scald).
There are two problems with this:
1, The mkdir command is prefixed with @ so any errors - like permission denied - are supressed.
2, The mkdir command isn't recursive, so if the storage directory doesn't exist - and we have experienced situations where it doesn't exist - then the mkdir never creates it as it will just try to create the atom_X directories within storage (as it's not recursive). This causes the while loop to never exit and become an infinite loop.
To recreate the issue you just need to delete/move the storage directory in files and try to use something which relies on Storage_api - for us that has been images that use storage_api. Then check top and you'll see apache2/php-fpm process max out (disclaimer: I have only used php-fpm with this).
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | storage_api-infinite_loop_fix-2407275-3.patch | 518 bytes | greyrhino |
| #1 | storage_api-infinite_loop_fix-2407275-1.patch | 511 bytes | greyrhino |
Comments
Comment #1
greyrhino commentedComment #2
perignon commentedThanks for bringing up this issue. I think we should be using drupal_mkdir instead of just php's mkdir so we can rely on site settings of file modes. I do realize that the existing code is using 0777 but the security conscious person in me does not like that. It should be 0755 (which is the default for drupal_mkdir).
Comment #3
greyrhino commentedHi Perignon - totally agree about 0777. Because of umask it never actually gets set as 777 but have removed and left for Drupal to decide using null as the second option for drupal_mkdir() - seems nicer that hard coding either.
New patch attached.
Comment #4
greyrhino commentedComment #6
perignon commentedCommitted to dev! Thanks for the contribution!
Comment #7
perignon commentedTagging for release documentation