1. 23 Feb, 2022 1 commit
  2. 11 Nov, 2021 1 commit
  3. 17 Oct, 2021 1 commit
    • str: introduce `git_str` for internal, `git_buf` is external · f0e693b1
      libgit2 has two distinct requirements that were previously solved by
      `git_buf`.  We require:
      
      1. A general purpose string class that provides a number of utility APIs
         for manipulating data (eg, concatenating, truncating, etc).
      2. A structure that we can use to return strings to callers that they
         can take ownership of.
      
      By using a single class (`git_buf`) for both of these purposes, we have
      confused the API to the point that refactorings are difficult and
      reasoning about correctness is also difficult.
      
      Move the utility class `git_buf` to be called `git_str`: this represents
      its general purpose, as an internal string buffer class.  The name also
      is an homage to Junio Hamano ("gitstr").
      
      The public API remains `git_buf`, and has a much smaller footprint.  It
      is generally only used as an "out" param with strict requirements that
      follow the documentation.  (Exceptions exist for some legacy APIs to
      avoid breaking callers unnecessarily.)
      
      Utility functions exist to convert a user-specified `git_buf` to a
      `git_str` so that we can call internal functions, then converting it
      back again.
      Edward Thomson committed
  4. 29 Nov, 2020 1 commit
    • Make the pack and mwindow implementations data-race-free · 322c15ee
      This change fixes a packfile heap corruption that can happen when
      interacting with multiple packfiles concurrently across multiple
      threads. This is exacerbated by setting a lower mwindow open file limit.
      
      This change:
      
      * Renames most of the internal methods in pack.c to clearly indicate
        that they expect to be called with a certain lock held, making
        reasoning about the state of locks a bit easier.
      * Splits the `git_pack_file` lock in two: the one in `git_pack_file`
        only protects the `index_map`. The protection to `git_mwindow_file` is
        now in that struct.
      * Explicitly checks for freshness of the `git_pack_file` in
        `git_packfile_unpack_header`: this allows the mwindow implementation
        to close files whenever there is enough cache pressure, and
        `git_packfile_unpack_header` will reopen the packfile if needed.
      * After a call to `p_munmap()`, the `data` and `len` fields are poisoned
        with `NULL` to make use-after-frees more evident and crash rather than
        being open to the possibility of heap corruption.
      * Adds a test case to prevent this from regressing in the future.
      
      Fixes: #5591
      lhchavez committed
  5. 11 Oct, 2020 1 commit
  6. 12 Jul, 2020 1 commit
  7. 27 Jun, 2020 1 commit
  8. 26 Jun, 2020 1 commit
    • Review feedback · eab2b044
      * Change the default of the file limit to 0 (unlimited).
      * Changed the heuristic to close files to be the file that contains the
        least-recently-used window such that the window is the
        most-recently-used in the file, and the file does not have in-use
        windows.
      * Parameterized the filelimit test to check for a limit of 1 and 100
        open windows.
      lhchavez committed
  9. 21 Jun, 2020 1 commit
    • mwindow: set limit on number of open files · 9679df57
      There are some cases in which repositories accrue a large number of
      packfiles. The existing mwindow limit applies only to the total size of
      mmap'd files, not on their number. This leads to a situation in which
      having lots of small packfiles could exhaust the allowed number of open
      files, particularly on macOS, where the default ulimit is very low
      (256).
      
      This change adds a new configuration parameter
      (GIT_OPT_SET_MWINDOW_FILE_LIMIT) that sets the maximum number of open
      packfiles, with a default of 128. This is low enough so that even macOS
      users should not hit it during normal use.
      
      Based on PR #5386, originally written by @josharian.
      
      Fixes: #2758
      lhchavez committed