-
Notifications
You must be signed in to change notification settings - Fork 164
Description
Several functions use pool_alloctmpspace() to return a string allocated in Pool's temporary area.
Such strings must be processed and discarded immediately.
Everything works fine as long as the code runs in a single thread.
We're currently writing new dnfdaemon - a DBus interface that processes incoming requests in an infinite loop and turns them into asynchronous threads. We are aware of potential concurrency issues, designing the code to avoid them as much as possible.
Our use case is: load repositories into Pool and let users run multiple queries at a time.
We believe that pool_alloctmpspace() might become an issue when used in threads and that impacts all libsolv functions that use it, incl. pool_solvable2str() for example.
Locking doesn't seem to be a good idea, because a user would have to always unlock it explicitly after the value is consumed and it also decreases performance.
I'm wondering if thread_local annotation on pool->tmpspace couldn't be used to eliminate race conditions among threads.
Maybe also returning a newly allocated string might be an option, but I don't know the performance impact.
Or do you have any better idea?