[squid-dev] [PATCH] Make PID file check/creation atomic

Amos Jeffries squid3 at treenet.co.nz
Tue May 16 12:21:44 UTC 2017


On 16/05/17 01:42, Eduard Bagdasaryan wrote:
> Could you clarify, what are these processes that 'operate as threads'? 
> AFAIK,
> Squid spawns its children by fork() and execlp(), and each new process 
> is a
> common process with its own address space. As for atomicity, the OS itself
> guarantees that only one process can have an exclusive file lock at a
> given time. Where do you suggest to use std::atomic then?
>

The main Squid binary is threaded via the DiskIO implementations (at the 
least). These threads may be operational at any time after the first 
StoreInit() call, and unfortunately do reach other parts of the startup 
logic.


An static std::atomic lock/flag around the File::File() try{...} 
internals to make it threadsafe should resolve any potential issues 
there, the fnctl locks should be able to cope with anything once the 
lock() method returns.


Amos



More information about the squid-dev mailing list