1. 03 Mar, 2017 1 commit
    • Yedidya Feldblum's avatar
      Tweak size handling in Endian · 97377ac8
      Yedidya Feldblum authored
      Summary:
      [Folly] Tweak size handling in `Endian`.
      
      Either multiply by 8 in one place, or divide by 8 in another place. Go with the latter, because `sizeof` in C++ emits byte sizes, not bit sizes.
      
      Reviewed By: simpkins
      
      Differential Revision: D4645020
      
      fbshipit-source-id: cb78600ba4c20bebc66aed506d4b5d6c378fc998
      97377ac8
  2. 02 Mar, 2017 3 commits
    • Christopher Dykes's avatar
      Revert D4618623: Give observer manager threads a name · c9cbfdb7
      Christopher Dykes authored
      Summary: This reverts commit 21b86944f513da0700039a3e3736937fd72e8887
      
      Differential Revision: D4618623
      
      fbshipit-source-id: 6ab6498a2ce22895d7052e258d1af216d46ca178
      c9cbfdb7
    • Subodh Iyengar's avatar
      Add a method to AsyncSSLSocket to supply connect timeouts · feff1cde
      Subodh Iyengar authored
      Summary:
      The current method to supply connect timeouts to AsyncSSLSocket
      is to supply only the max connect + ssl connect time.
      
      However in some cases when connect time is known, it is desirable
      to supply it so that if connect does not succeed in connect time
      we can error out quicker and retry.
      
      This adds a new method for connect time in addition to the total
      Connect time.
      
      An alternative to this would be to create a AsyncSocket, connect it
      and then pass it's fd to AsyncSSLSocket, however that approach does
      not work well when TFO is being used, because TFO State is a part of
      the AsyncSocket's state and that is not encapsulated with the fd transfer.
      
      We could move the state around, but that is error prone, and this is much
      simpler and isolated to AsyncSSLSocket.
      
      Reviewed By: knekritz
      
      Differential Revision: D4626924
      
      fbshipit-source-id: d802d035efbced68873ab59314d9f0e661e5509b
      feff1cde
    • Yedidya Feldblum's avatar
      Refactor Endian · e473e0f9
      Yedidya Feldblum authored
      Summary:
      [Folly] Refactor `Endian`.
      
      Define `swap` for all types, instead of only declaring it for all types, but have its implementation call a function that only has a given set of non-template overloads for a given set of supported types.
      
      The effective change is that now `Endian::swap<std::string>` will fail to compile, rather than compile but fail to link.
      
      And support floating-point types.
      
      Reviewed By: nbronson
      
      Differential Revision: D4615706
      
      fbshipit-source-id: 5034e1e4466b8118a258d917ce8f4094460ca01a
      e473e0f9
  3. 01 Mar, 2017 4 commits
    • Andrii Grynenko's avatar
      Fix ASAN integration with detect_stack_use_after_return turned on · 58285440
      Andrii Grynenko authored
      Summary: detect_stack_use_after_return enables fake stack logic. Previous implementation was relying on fiber releasing its fake stack before switch, which is not safe, because that fake stack may actually be in use. This diff implements a hacky workaround by building a freeFakeStack function, which can release fake stack outside of the fiber. Ideally this function should be provided by ASAN itself.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4631962
      
      fbshipit-source-id: 6213e2a6b3cbc35fae3793fcf86b0614dd8ff825
      58285440
    • Andrii Grynenko's avatar
      Disable MemoryIdler::unmapUnusedStack with ASAN · 94a3d5d3
      Andrii Grynenko authored
      Summary: It doesn't work nicely with fake stacks (which are used with detect_stack_use_after_return).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4631995
      
      fbshipit-source-id: f139041314f8f64c0cf0a15874d6a4710fb2a5b6
      94a3d5d3
    • Nathan Bronson's avatar
      rename Range template arg for increased readability · f330bc23
      Nathan Bronson authored
      Summary:
      Parameterizing Range by the template arg T is potentially
      confusing because it violates the typical container pattern of T being
      the value type.  This diff uses Range<Iter> consistently in Range.h when
      the template arg refers to a fully general iterator.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4635270
      
      fbshipit-source-id: f70bb2e3e23ab9875fba3dbf7b11492613a037b8
      f330bc23
    • Philipp Unterbrunner's avatar
      New C++17 backport: folly::enable_shared_from_this · 512aa175
      Philipp Unterbrunner authored
      Summary:
      C++14 has no direct means of creating a std::weak_ptr, one must always create a (temporary) std::shared_ptr first. C++17 adds weak_from_this() to std::enable_shared_from_this to avoid that overhead.
      Alas code that is meant to compile under different language versions cannot rely on std::enable_shared_from_this::weak_from_this().
      This new utility class uses SFINAE to call std::enable_shared_from_this<T>::weak_from_this() if available. Falls back to std::enable_shared_from_this<T>::shared_from_this() otherwise.
      Use as a drop-in replacement for std::enable_shared_from_this where weak_from_this() is desired.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4616394
      
      fbshipit-source-id: 73bf6cd8852d4a33478a9280cc69c81e7ea73423
      512aa175
  4. 28 Feb, 2017 1 commit
    • Haijun Zhu's avatar
      Give observer manager threads a name · c180b702
      Haijun Zhu authored
      Summary: As title, convenient for debugging. Asked for from D4542856
      
      Reviewed By: nkg-
      
      Differential Revision: D4618623
      
      fbshipit-source-id: 21b86944f513da0700039a3e3736937fd72e8887
      c180b702
  5. 27 Feb, 2017 6 commits
    • Ted Percival's avatar
      Update googletest to 1.8.0 · 04574f42
      Ted Percival authored
      Summary:
      `make check` was failing because <gmock.h> is included but not supplied. Updating to googletest 1.8.0 includes both googletest & googlemock, so `make check` now runs (and passes).
      Closes https://github.com/facebook/folly/pull/547
      
      Reviewed By: igorsugak
      
      Differential Revision: D4593403
      
      Pulled By: Orvid
      
      fbshipit-source-id: 02f80e7b67e17562ff981e9c80a37f985eb685be
      04574f42
    • Kyle Nekritz's avatar
      Move some tests out of FOLLY_ALLOW_TFO ifdef. · 5e77af42
      Kyle Nekritz authored
      Summary: I think this ended up encompassing more than intended.
      
      Reviewed By: yfeldblum, maxgeorg
      
      Differential Revision: D4622645
      
      fbshipit-source-id: 26597098a479b85d6ecc64abef2ecc53637ee759
      5e77af42
    • Kyle Nekritz's avatar
      Don't call memcpy with empty buffer in IOBuf::copyBuffer(). · d0683981
      Kyle Nekritz authored
      Summary: Fixes "undefined behavior" in ubsan builds when using an empty ByteRange.
      
      Reviewed By: siyengar
      
      Differential Revision: D4613663
      
      fbshipit-source-id: 4b53ba764609acc986340f10613f84585fa697cf
      d0683981
    • Christopher Dykes's avatar
      Kill checks in configure.ac that aren't used · da08e63c
      Christopher Dykes authored
      Summary: They are checks that aren't actually used anywhere to guard anything, so kill them. Many are for things that have long since been standard, or aren't even used.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4615947
      
      fbshipit-source-id: 2179caff4ef8583c89efedbff3136ae5fc552424
      da08e63c
    • Christopher Dykes's avatar
      Use cstdint instead of inttypes.h · 89f9bd3e
      Christopher Dykes authored
      Summary: This is the only place `inttypes.h` is used in Folly and it's used in a context where `cstdint` would have sufficed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4619248
      
      fbshipit-source-id: e67dccb7d8bf1ad5f7539d4b039590253e8d8c79
      89f9bd3e
    • Christopher Dykes's avatar
      Kill unused include of sched.h · a595dcb5
      Christopher Dykes authored
      Summary: These are the only includes of `sched.h` in Folly, and they really are unused:
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4615501
      
      fbshipit-source-id: 6a3a1aad7a91a92a322fd93d18e1284aa3f86b89
      a595dcb5
  6. 26 Feb, 2017 2 commits
    • Philip Pronin's avatar
      reduce consumed stack size in symbolizer · 3ba178b5
      Philip Pronin authored
      Summary:
      It currently takes ~32kB of stack trace to run symbolizer, which is
      very close to ASan alt stack size (32 kB).
      
      If we exclude `demangle` (which can use unbound stack size in extreme cases),
      the heaviest path in symbolizer includes `FrameArray<100>` and three arrays of
      `PATH_MAX` (4 kB) size.  This diff removes the former and one of the latters,
      reducing this code path from 32 kB to ~10 kB.
      
      Reviewed By: ot, yfeldblum
      
      Differential Revision: D4618467
      
      fbshipit-source-id: e6a53b61b3d5f6e8b892216d2e9b839ed8430d0e
      3ba178b5
    • Christopher Dykes's avatar
      Drop FOLLY_HAVE_STD_THIS_THREAD_SLEEP_FOR · ba35fe5d
      Christopher Dykes authored
      Summary: It was only needed for GCC 4.7 support. GCC 4.8 and above support it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4616044
      
      fbshipit-source-id: 177d7b3b7090134f9d8084a3ba7a984446c87d5e
      ba35fe5d
  7. 25 Feb, 2017 1 commit
    • Michael Lee's avatar
      Fix -Wshadow warning in sorted_vector_types · 29deb3cf
      Michael Lee authored
      Summary: `last` was already passed in as a variable, so switch this so there isn't a local variable at all.
      
      Reviewed By: mlogan, yfeldblum
      
      Differential Revision: D4615206
      
      fbshipit-source-id: dd8e3157e54dc2abe3dfd97837ce327371f4f7b2
      29deb3cf
  8. 24 Feb, 2017 2 commits
    • Yedidya Feldblum's avatar
      Drop support for gcc 4.7 with byteswap shim · 80430673
      Yedidya Feldblum authored
      Summary: [Folly] Drop support for gcc 4.7 with byteswap shim
      
      Reviewed By: igorsugak, Orvid
      
      Differential Revision: D4610746
      
      fbshipit-source-id: 092cd432c7bda9ca5507d0230b6fcaa43b96c500
      80430673
    • Giuseppe Ottaviano's avatar
      Fix a corner case in EliasFanoReader::previousValue · e639eac2
      Giuseppe Ottaviano authored
      Summary:
      `previousValue` makes the incorrect assumption that `outer_`
      is a multiple of the word size. This is incorrect because `skipToNext`
      can reposition at an arbitrary point.
      
      The bug is very rare because it can only happen if there is a gap
      larger than the skip quantum after the first element in the upper
      bits.
      
      Reviewed By: philippv
      
      Differential Revision: D4607270
      
      fbshipit-source-id: ff016f09f3f1f87314b68370e3dc137b82694f45
      e639eac2
  9. 23 Feb, 2017 1 commit
    • Mark Logan's avatar
      Remove duplicates during bulk insertion. · 3900132e
      Mark Logan authored
      Summary:
      antonl noticed that bulk_insert doesn't remove duplicates.
      We now run a std::unique() pass after merging.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4595304
      
      fbshipit-source-id: 538364150aeea64b95488da158c09e07a6597e7c
      3900132e
  10. 21 Feb, 2017 1 commit
  11. 20 Feb, 2017 1 commit
    • Mark Williams's avatar
      Prevent a crash in folly::Symbolizer · ae910818
      Mark Williams authored
      Summary:
      dbg and dbgo builds of hhvm with gcc-5 crash when generating
      backtraces using folly::Symbolizer, because the .debug_aranges for
      libc-2.23.so are SHF_COMPRESSED, and folly::Symbolizer doesn't
      recognize that.
      
      Just pretend that the section doesn't exist if it has SHF_COMPRESSED
      set.
      
      We might eventually want to support decompressing such sections under
      an option - but folly::Symbolizer's goal is to just mmap and walk the
      debug info without allocating memory (so that it can run while
      handling signals etc).
      
      Reviewed By: pixelb
      
      Differential Revision: D4586762
      
      fbshipit-source-id: bef61ed670d1a80caa4f7aac1f80fd2a92cc4ba9
      ae910818
  12. 17 Feb, 2017 2 commits
    • Maged Michael's avatar
      Add Baton variants with multiple posters and with a non-blocking waiter · f795d501
      Maged Michael authored
      Summary:
      Added two variants of Baton by adding two Boolean template parameters with defaults that correspond to the original single poster blocking waiter version:
      - SinglePoster (single poster vs multiple posters). Default true.
      - Blocking (vs spinning). Default true.
      
      The multi-poster baton (SinglePoster = false) can be handed over by multiple concurrent posters, where redundant post()-s are idempotent but if a post() arrives after the baton is reset() then it unblocks the waiter.
      
      The nonblocking Baton (Blocking = false) has faster common case post(), by avoiding CAS in the critical path. It does so by disallowing waiter blocking and timed_wait().
      
      Reviewed By: nbronson
      
      Differential Revision: D4506728
      
      fbshipit-source-id: e5b65ad93e443fbba22164319c985ebc8424554a
      f795d501
    • Yedidya Feldblum's avatar
      Fix exception_wrapper::throwException when called before main · 05499631
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `exception_wrapper::throwException` when called before `main`.
      
      When the `exception_wrapper` is empty, then `throwException` emits a message to `std::cerr` and terminates. If called before `main` begins or after `main` ends, then `std::cerr` might not have been constructed yet or might have already been destructed. Bad. Segfault, etc. So we need to ensure that `std::cerr` is alive by holding an instance of `std::ios_base::Init`.
      
      Reviewed By: Orvid
      
      Differential Revision: D4576190
      
      fbshipit-source-id: dd84b5e82eb6bd817d405baf530714e0f4c314c5
      05499631
  13. 16 Feb, 2017 6 commits
    • Yedidya Feldblum's avatar
      Drop support for Clang < 3.9 · 1d804f03
      Yedidya Feldblum authored
      Summary: [Folly] Drop support for Clang < 3.9.
      
      Reviewed By: igorsugak
      
      Differential Revision: D4567233
      
      fbshipit-source-id: cd94c711f0390d249b6736ab292721a477022b02
      1d804f03
    • Christopher Dykes's avatar
      Workaround MSVC 2015 limitations in Traits.h · 1a8db4b8
      Christopher Dykes authored
      Summary: MSVC 2015 has issues with templated `using` declarations using `decltype`, so adjust the definition to use constexpr evaluation to fill a template parameter of a base type instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4510155
      
      fbshipit-source-id: cc2e33625b515085dff4e682971299810905fef0
      1a8db4b8
    • Christopher Dykes's avatar
      Adjust a few things to avoid triggering warnings under MSVC · dfc2add7
      Christopher Dykes authored
      Summary: This includes both unused parameters (W4100) and conditional expression is constant (W4127).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4525057
      
      fbshipit-source-id: 7c057dbe239d02fa2e3ce96373d53814591994ec
      dfc2add7
    • Christopher Dykes's avatar
      Use std::this_thread::yield rather than sched_yield · 79b78eaa
      Christopher Dykes authored
      Summary: They do the same thing, and the first is portable.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4569649
      
      fbshipit-source-id: db0434766f674a7789d6e59335e122b4d2131e06
      79b78eaa
    • Maged Michael's avatar
      Fix data race in Futex<EmulatedFutexAtomic> · eab7000d
      Maged Michael authored
      Summary: Fixed a data race between an atomic store by the waker and a nonatomic memcpy by the waiter.
      
      Reviewed By: nbronson
      
      Differential Revision: D4572410
      
      fbshipit-source-id: 3982ca433e0f628636916516e35aeb7738ae030f
      eab7000d
    • Lovro Puzar's avatar
      Add AtomicIntrusiveLinkedList::reverseSweep() · f54a0bdb
      Lovro Puzar authored
      Summary: In D4558451 I want to pull elements off an atomic list onto a thread-local (single-consumer) vector and pop to get elements in insertion order.  A sweep that provides elements in LIFO order will avoid a redundant pair of list reversals.
      
      Reviewed By: nbronson
      
      Differential Revision: D4564816
      
      fbshipit-source-id: 38cf50418e6afe0be3eec96ce85d571c65f06d7e
      f54a0bdb
  14. 15 Feb, 2017 3 commits
    • Philip Pronin's avatar
      optimize EliasFanoEncoder::defaultNumLowerBits · b49a44c4
      Philip Pronin authored
      Summary:
      `defaultNumLowerBits` is heavily used during PL encoding with
      optimally-partitioned EF. This diff improves its performance by 3.5x by
      avoiding expensive 64-bit division.
      
      Reviewed By: ot, luciang
      
      Differential Revision: D4564615
      
      fbshipit-source-id: 4521d3c05f19573cd2c84f702fcfeaace5f98e77
      b49a44c4
    • Phil Willoughby's avatar
      Replace the future-splitting system · bb76b0f7
      Phil Willoughby authored
      Summary:
      The previous mechanism in SharedPromise doesn't work if the lifetime of the
      SharedPromise object ends before the Future which it was splitting is
      completed.
      
      This variation on the same theme doesn't have that problem.
      
      Reviewed By: spacedentist
      
      Differential Revision: D4339670
      
      fbshipit-source-id: f619762bff1390481715575b3e638ec26b5c4edd
      bb76b0f7
    • Anton Likhtarov's avatar
      Fix undefined behaviour · 1ce2015a
      Anton Likhtarov authored
      Summary: memcpy's src cannot be nullptr even if the size is 0.
      
      Reviewed By: djwatson
      
      Differential Revision: D4560100
      
      fbshipit-source-id: 37cd3ed73f902a136f711a5c1a918258f94d1063
      1ce2015a
  15. 14 Feb, 2017 2 commits
  16. 11 Feb, 2017 1 commit
    • Adam Simpkins's avatar
      add Range constructors from std::array · 60b6e844
      Adam Simpkins authored
      Summary:
      Add explicit constructors to create Range objects referring to the contents of
      a std::array.
      
      D4165608 previously added a folly::range() factory function to create Ranges
      around const arrays.  However, it did not support non-const arrays.  However,
      providing this as a constructor seems better.  This new constructor does not
      appear ambiguous with any existing constructors, and a constructor allows for
      more natural support of non-const arrays: the caller can explicitly indicate
      if they want to construct a Range to const or non-const data in this case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4523515
      
      fbshipit-source-id: c1a262f9e8f76907d87d80b03f252576506e70ab
      60b6e844
  17. 10 Feb, 2017 3 commits
    • Andrii Grynenko's avatar
      Minor GDB script fix · e1a26ff9
      Andrii Grynenko authored
      Reviewed By: lbrandy
      
      Differential Revision: D4544705
      
      fbshipit-source-id: d60f2026d31c94e020df51f8c887b995986ddcd7
      e1a26ff9
    • Jack Montgomery's avatar
      changed Synchronized.md to reflect SharedMutex as default · 78443c5a
      Jack Montgomery authored
      Summary: folly/docs/Synchronized.md now reflects the fact that SharedMutex is default mutex for Synchronized
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4529851
      
      fbshipit-source-id: b3b8eafe908ba92e3629392fbc4b856b5a99b658
      78443c5a
    • Andrew Krieger's avatar
      Detect identity conversion in toDynamic · 6e4f4207
      Andrew Krieger authored
      Summary:
      D4499520 added typedefs to `dynamic` which made it start matching
      tests for ranges/containers. However, the typedefs are unconditional on the
      actual contents of the `dynamic`. This made toDynamic(dynamic) select the
      range-based conversion operator, always, which immediately asserts when
      trying to do range-based iteration over an Object or a primitive. Add tests
      to the converters that enable/disable depending on whether the object is
      already a `dynamic` and early-out in that case.
      
      Reviewed By: mzlee
      
      Differential Revision: D4538617
      
      fbshipit-source-id: f3a5aafab07946a221dcead782fc27de51afa0a6
      6e4f4207