summaryrefslogtreecommitdiff
path: root/src/global.c
Commit message (Collapse)AuthorAgeFilesLines
* global: free the error message when exiting a threadcmn/free-tls-errorCarlos Martín Nieto2014-09-141-0/+3
| | | | | When we free the global state at thread termination, we must also free the error message in order not to leak the string once per thread.
* Only create openssl_locks if thread support is enabledJacques Germishuys2014-07-131-0/+2
|
* ssl: init only once without threadsCarlos Martín Nieto2014-06-301-1/+7
| | | | | | | | The OpenSSL library-loading functions do not expect to be called multiple times. Add a flag in the non-threaded libgit2 init so we only call once. This fixes #2446.
* Merge pull request #2421 from libgit2/cmn/init-ssl-onceVicent Marti2014-06-141-0/+67
|\ | | | | netops: init OpenSSL once under lock
| * ssl: init everything all the timecmn/init-ssl-onceCarlos Martín Nieto2014-06-121-5/+48
| | | | | | | | | | | | | | | | Bring together all of the OpenSSL initialization to git_threads_init() so it's together and doesn't need locks. Moving it here also gives us libssh2 thread safety (when built against openssl).
| * ssl: init also without threadsCarlos Martín Nieto2014-06-121-9/+10
| |
| * ssl: cargo-cult thread safetyCarlos Martín Nieto2014-06-121-0/+20
| | | | | | | | OpenSSL's tests init everything in the main thread, so let's do that.
| * netops: init OpenSSL once under lockCarlos Martín Nieto2014-06-111-0/+3
| | | | | | | | | | | | | | | | The OpenSSL init functions are not reentrant, which means that running multiple fetches in parallel can cause us to crash. Use a mutex to init OpenSSL, and since we're adding this extra checks, init it only once.
* | Win32: Fix object::cache::threadmania test on x64Philip Kelley2014-06-071-2/+2
|/
* Merge pull request #2303 from jacquesg/mingw-lseekVicent Marti2014-05-191-1/+1
|\ | | | | WIP: Windows fixes
| * _InterlockedExchange expects a volatile LONGJacques Germishuys2014-05-011-1/+1
| |
* | Fix the issues in git_shutdownAnurag Gupta2014-05-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) Call to git_shutdown results in setting git__n_shutdown_callbacks to -1. Next call to git__on_shutdown results in ABW (Array Bound Write) for array git__shutdown_callbacks. In the current Implementation, git_atomic_dec is called git__n_shutdown_callbacks + 1 times. I have modified it to a for loop so that it is more readable. It would not set git__n_shutdown_callbacks to a negative number and reset the elements of git__shutdown_callbacks to NULL. 2) In function git_sysdir_get, shutdown function is registered only if git_sysdir__dirs_shutdown_set is set to 0. However, after this variable is set to 1, it is never reset to 0. If git_sysdir_global_init is called again from synchronized_threads_init it does not register shutdown function for this subsystem.
* | Fix the issues in git__on_shutdownAnurag Gupta2014-05-061-5/+7
|/
* Fix threading tests when threads disabledRussell Belfer2014-04-171-10/+10
|
* Correct C90 warningsJacques Germishuys2014-04-111-1/+2
|
* Move system directory cache out of utilsEdward Thomson2014-02-241-3/+3
|
* Don't use git_atomic as an integerBen Straub2013-10-041-4/+5
|
* Use InterlockedCompareExchange for the lockPhilip Kelley2013-10-041-49/+18
|
* Posix synchronized init, prototype win32 versionBen Straub2013-10-041-34/+89
|
* Add simple global shutdown hooksRussell Belfer2013-09-171-10/+28
| | | | | | | | | | Increasingly there are a number of components that want to do some cleanup at global shutdown time (at least if there are not going to be memory leaks). This creates a very simple system of shutdown hooks that will be invoked by git_threads_shutdown. Right now, the maximum number of hooks is hardcoded, but since adding a hook is not a public API, it should be fine and I thought it was better to start off with really simple code.
* Load SRWLock APIs at runtimeRussell Belfer2013-08-261-4/+8
| | | | | | This loads SRWLock APIs at runtime and in their absence (i.e. on Windows before Vista) falls back on a regular CRITICAL_SECTION that will not permit concurrent readers.
* preload configuration pathsEdward Thomson2013-07-111-5/+4
|
* Mutex init can failRussell Belfer2013-05-311-2/+4
| | | | | | | It is obviously quite a serious problem if this happens, but mutex initialization can fail and we should detect it. It's a bit like a memory allocation failure, in that you're probably pretty screwed if this occurs, but at least we'll catch it.
* Further threading fixesRussell Belfer2013-04-221-0/+6
| | | | | | | | | | | | | This builds on the earlier thread safety work to make it so that setting the odb, index, refdb, or config for a repository is done in a threadsafe manner with minimized locking time. This is done by adding a lock to the repository object and using it to guard the assignment of the above listed pointers. The lock is only held to assign the pointer value. This also contains some minor fixes to the other work with pack files to reduce the time that locks are being held to and fix an apparently memory leak.
* Switch search paths to classic delimited stringsRussell Belfer2013-03-181-2/+7
| | | | | | | | | | | | This switches the APIs for setting and getting the global/system search paths from using git_strarray to using a simple string with GIT_PATH_LIST_SEPARATOR delimited paths, just as the environment PATH variable would contain. This makes it simpler to get and set the value. I also added code to expand "$PATH" when setting a new value to embed the old value of the path. This means that I no longer require separate actions to PREPEND to the value.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* git__mwindow_mutex needs to be initialized even with pthreadsJustin Spahr-Summers2012-12-091-0/+2
| | | | This could also use PTHREAD_MUTEX_INITIALIZER, but a dynamic initializer seems like a more portable concept, and we won't need another #define on top of git_mutex_init()
* unload dll / destroy hash ctxs at shutdownEdward Thomson2012-11-131-0/+6
|
* move hash library func ptrs to global globalEdward Thomson2012-11-131-7/+38
|
* threads: Assert that the global state is initializedVicent Marti2012-10-011-0/+4
|
* Make the memory-window conrol structures globalCarlos Martín Nieto2012-08-201-0/+5
| | | | | | | | | | | | | Up to now, the idea was that the user would do all the operations for one repository in the same thread. Thus we could have the memory-mapped window information thread-local and avoid any locking. This is not practical in a few environments, such as Apple's GCD which allocates threads arbitrarily or the .NET CLR, where the OS-level thread can change at any moment. Make the control structure global and protect it with a mutex so we don't depend on the thread currently executing the code.
* Implement git_pool paged memory allocatorRussell Belfer2012-04-251-3/+3
| | | | | | | | | | | | | | | | | | This adds a `git_pool` object that can do simple paged memory allocation with free for the entire pool at once. Using this, you can replace many small allocations with large blocks that can then cheaply be doled out in small pieces. This is best used when you plan to free the small blocks all at once - for example, if they represent the parsed state from a file or data stream that are either all kept or all discarded. There are two real patterns of usage for `git_pools`: either for "string" allocation, where the item size is a single byte and you end up just packing the allocations in together, or for "fixed size" allocation where you are allocating a large object (e.g. a `git_oid`) and you generally just allocation single objects that can be tightly packed. Of course, you can use it for other things, but those two cases are the easiest.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* threads: Fix the shared global state with TLSVicent Marti2011-11-161-0/+134
See `global.c` for a description of what we're doing. When libgit2 is built with GIT_THREADS support, the threading system must be explicitly initialized with `git_threads_init()`.