Re: Make the git codebase thread-safe
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 15, 2014, 00:56 UTC
- Message-ID
- <CACsJy8AQNmmW40R-H7kz1dmwiaSKVgu+GP=Jt1qTKgfbZoMkMA@mail.gmail.com>
- In-Reply-To
- <CAHOQ7J-gGbnADQ+3TGy6b6LJSLH8jvAbdTrc20Ybh=p0D2FmsQ@mail.gmail.com>
On Sat, Feb 15, 2014 at 7:50 AM, Stefan Zager <szager@google.com> wrote:
Show 22 quoted lines
> On Fri, Feb 14, 2014 at 4:45 PM, Duy Nguyen <pclouds@gmail.com> wrote: >> On Sat, Feb 15, 2014 at 2:16 AM, Zachary Turner <zturner@chromium.org> wrote: >>> (Gah, sorry if you're receiving multiple emails to your personal >>> addresses, I need to get used to manually setting Plain-text mode >>> every time I send a message). >>> >>> For the mixed read, we wouldn't be looking for another caller of >>> pread() (since it doesn't care what the file pointer is), but instead >>> a caller of read() or lseek() (since those do depend on the current >>> file pointer). In index-pack.c, I see two possible culprits: >>> >>> 1) A call to xread() from inside fill() >>> 2) A call to lseek in parse_pack_objects() >>> >>> Do you think these could be related? If so, maybe that opens up some >>> other solutions? >> >> For index-pack alone, what's wrong with open one file handle per thread? > > Nothing wrong with that, except that it would mean either using > thread-local storage (which the code doesn't currently use); or > plumbing pack_fd through the call stack, which doesn't sound very fun.
Current code does use thread-local storage (struct thread_local and get_thread_data). Adding a new file handle when NO_THREAD_SAFE_PREAD is defined is simpler imo.
-- Duy