From f62c3bd1698f60c8a71e5906ecfcf22c63bbf674 Mon Sep 17 00:00:00 2001 From: NerdGuruDevelopers Date: Sat, 20 Feb 2021 10:02:29 -0500 Subject: [PATCH] ftok can have collisions within certain contexts. Pulling the file's inode instead will prevent collisions especially when using temp files for shared memory storage. --- src/Cache/SharedMemory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cache/SharedMemory.php b/src/Cache/SharedMemory.php index e96e66b..6fdb7be 100644 --- a/src/Cache/SharedMemory.php +++ b/src/Cache/SharedMemory.php @@ -65,8 +65,8 @@ public function attach($file = __FILE__) throw new \RuntimeException("file is not exists and it can not be created. file: {$file}"); } } - $key = ftok($file, 'a'); - $this->shm = shm_attach($key, $this->size); //allocate shared memory + + $this->shm = shm_attach(fileinode($file), $this->size); //allocate shared memory } /** @@ -173,4 +173,4 @@ public function __wakeup() { $this->attach(); } -} \ No newline at end of file +}