On 27.11.2012 20:49, Gabriel Kerneis wrote:
> On Tue, Nov 27, 2012 at 12:28:31PM +0200, [email protected] wrote:
>> Which leaves two "bugs"
>> 1. Documentation incorrectly states that new cache files can be created with "exclusive open", while
>> in reality without cooperative locking on part of Polipo and the process creating the new file,
>> there could be race conditions.
>
> Could you give an example of such a race condition?
I'm not familiar with the codebase, but I'll give it a try.
Polipo #1 decides to write cache data to a file and does so.
Polipo #2 decides it needs to read this cache file, while Polipo #1 is writing it.
Thus a basic race condition occurs.
I don't know what happens as a result. Maybe internal data structure corruption?
There seems to be some validation on part of Polipo when reading a file, but as it's a lot of
unknown code, I don't know what it does. And it tackles a different problem. For shared file access,
flock() is the function.
>> 2. Documentation doesn't state how Polipo itself creates (or modifies) cache files. Does it
>> use locking? Does it create a temporary file and then rename it?
>
> Looking into diskcache.c indicates that it uses "exclusive open" for disk
> entries.
Some of the open() function calls use O_EXCL. It's purpose, according to the documenation, is to
ensure that the file being "open()"ed got created as a result of the call (O_EXCL is used with
O_CREAT). That is, if the file existed when the called was made, the call fails.
> Best,
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
DESIGN Expert tips on starting your parallel project right.
http://goparallel.sourceforge.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.