1. 19 May, 2017 3 commits
  2. 17 May, 2017 2 commits
    • Alexey Spiridonov's avatar
      ThreadedRepeatingFunctionRunner: Name all the threads · c75c575b
      Alexey Spiridonov authored
      Summary: Name all repeating function threads for ease of debugging.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5065281
      
      fbshipit-source-id: e875e654dfa644a265e44416baf5fbf23c9da434
      c75c575b
    • Phil Willoughby's avatar
      Tweak basic_fbstring construction from std types · 6c244d16
      Phil Willoughby authored
      Summary:
      Previously we defined an assignment from std::string on all basic_fbstring
      specialisations, but we don't actually want to do that because it's nonsense to
      construct a basic_fbstring<char16_t> from an std::string. Equally it's not
      nonsense to construct one of those from an std::u16string but the previous code
      didn't allow it.
      
      We now permit basic_fbstring<C, T, A1, S> to be constructed or assigned-to from
      std::basic_string<C, T, A2>. The character type and traits must match but the
      allocator is permitted to vary.
      
      Background on my determination that the allocator type was unimportant and
      could be disregarded: In part this is because C++17 made the same choice for
      basic_string_view. Another factor was C++17's std::pmr::string (it's a
      std::string with a different allocator) which I thought should be convertible
      to fbstring in the same way as std::string.
      
      Reviewed By: Gownta
      
      Differential Revision: D5060569
      
      fbshipit-source-id: f8984c528b76356240970c67916c58995d3f228d
      6c244d16
  3. 16 May, 2017 4 commits
  4. 15 May, 2017 5 commits
    • Yedidya Feldblum's avatar
      Drop support for deprecated associative containers · 7d151d2c
      Yedidya Feldblum authored
      Summary:
      [Folly] Drop support for deprecated associative containers.
      
      Namely, `__gnu_cxx::hash_set` and `__gnu_cxx::hash_map`.
      
      Reviewed By: wqfish
      
      Differential Revision: D5058813
      
      fbshipit-source-id: ebbcf10765f5d06776ee8f697cfb78614a3a566c
      7d151d2c
    • Nathan Bronson's avatar
      StampedPtr · 0da40510
      Nathan Bronson authored
      Summary:
      This diff adds StampedPtr, which packs a pointer and a uint16_t into
      a uint64_t with maximum portability and without adding any additional
      functionality.
      
      Reviewed By: yfeldblum, davidtgoldblatt
      
      Differential Revision: D4804614
      
      fbshipit-source-id: 25fe7aff47d1e126ac8edfff4eb0bbb1d34071aa
      0da40510
    • Maxim Georgiev's avatar
      In AsyncSocket::handleErrMessages() inside the loop check if the callback was not uninstalled · 98ceba40
      Maxim Georgiev authored
      Summary: AsyncSocket::handleErrMessages() should check if the error message callback is still installing before calling it, since the callback could be uninstaled on the previous loop iteration.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5051001
      
      fbshipit-source-id: fc01932c0d36bd8f72bf1905f12211fb83d28674
      98ceba40
    • Yedidya Feldblum's avatar
      List the new GCC 4.9 and C++14 minimum requirement · 7bdb20f8
      Yedidya Feldblum authored
      Summary:
      [Folly] List the new GCC 4.9 and C++14 minimum requirement.
      
      We no longer support GCC 4.8 or C++11.
      
      Closes #590.
      
      Reviewed By: Orvid, mzlee
      
      Differential Revision: D5058942
      
      fbshipit-source-id: 0545d1bb294494e5ef5f17a40c9cf3ac688bd8d0
      7bdb20f8
    • Arkady Shapkin's avatar
      Fix compilation ChecksumDetail.cpp with MSVC · 1559d510
      Arkady Shapkin authored
      Summary:
      MSVC doesn't support `^` and `&` operator for __m128i type
      Closes https://github.com/facebook/folly/pull/594
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D5053356
      
      Pulled By: djwatson
      
      fbshipit-source-id: f789824052e0c679c265c83ad704109805c21402
      1559d510
  5. 13 May, 2017 1 commit
    • Koen De Keyser's avatar
      Fix compilation on Linux systems without vDSO support · 55b25ffb
      Koen De Keyser authored
      Summary:
      Problems:
      - The vDSO check code in configure.ac is broken, and will always fail (uses AC_LANG_PROGRAM but with arguments in the AC_LANG_SOURCE style)
      - On Linux, using dlopen/dlsym requires -ldl (libdl) during the link phase. This check was missing and this argument was not added to the linker arguments.
      - On a Linux system without vDSO support, libfolly.so still uses vDSO in ClockGettimeWrappers.cpp
      
      Solution:
      - Switched to AC_LANG_SOURCE
      - Required libdl to exist when build target is Linux. This also adds this dependency to libfolly.la, resulting in fixing a dependency issue for Proxygen (recent Proxygen build would have issues in building examples due to failing linking step due to missing dlopen / dlsym / dlclose symbols)
      - In ClockGettimeWrappers.cpp, checking if `__linux__` is set is not sufficient to determine that the system has vDSO support. The autoconf script already exposes a correct check: FOLLY_HAVE_LINUX_VDSO (this is already used in folly/detail/CacheLocality.cpp), so switched to that one.
      Closes https://github.com/facebook/folly/pull/592
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5049816
      
      Pulled By: Orvid
      
      fbshipit-source-id: 58b2ed4c4101274505c61b4825accf262c0d56ef
      55b25ffb
  6. 12 May, 2017 7 commits
    • Philip Pronin's avatar
      return range from AsyncIO::cancel(), fix test · 7728c4b3
      Philip Pronin authored
      Summary:
      Return not just number of cancelled ops, but all of them as well.
      Test was incorrectly assuming `wait(1)` will return exactly one operation, fix
      that as well.
      
      Reviewed By: ot
      
      Differential Revision: D5054684
      
      fbshipit-source-id: 1c53c3f7ba855d1fcfeac8b1b27f90f0872d2c21
      7728c4b3
    • Yedidya Feldblum's avatar
      exception_wrapper::get_object<> · f0daf647
      Yedidya Feldblum authored
      Summary:
      [Folly] `exception_wrapper::get_object<>`.
      
      Returns a pointer to the stored object, if the template type parameter is of the right sort.
      
      Reviewed By: jsedgwick
      
      Differential Revision: D5000720
      
      fbshipit-source-id: 2869439085e8dfb56e6cb439794b03876b7d715c
      f0daf647
    • Yinghai Lu's avatar
      Fix broken promise error in folly::retrying · 4762a35e
      Yinghai Lu authored
      Summary: This diff shows an issue in `folly::retrying`. When the future generation function throws an exception and `folly::retrying` is nested in another functor that returns Future, it will throw `broken promise` instead of the actual exception message, which can be very generic and confusing. Fix is to capture the exception so that exact error message can be propagated up.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5050690
      
      fbshipit-source-id: 5b9b24977788f60aa778bb8e9cdf4281ea9a0023
      4762a35e
    • James Sedgwick's avatar
      include folly/portability/Sockets.h instead of netinet/tcp.h · b8fb402e
      James Sedgwick authored
      Summary: To satisfy internal linter
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4957870
      
      fbshipit-source-id: 191ac768790fbd8cc8a4d24036c016644ff1d125
      b8fb402e
    • James Sedgwick's avatar
      add FOLLY_FALLTHROUGH throughout to satisfy internal linter · ce7751a2
      James Sedgwick authored
      Summary: changes as suggested by FB-internal linter
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4957742
      
      fbshipit-source-id: c9d94c477d24f153cab0d25edccfd39ff31fdfdf
      ce7751a2
    • James Sedgwick's avatar
      include folly/portability/OpenSSL.h instead of openssl/*.h · d19f7312
      James Sedgwick authored
      Summary: suggested by internal linter
      
      Reviewed By: Orvid
      
      Differential Revision: D4958232
      
      fbshipit-source-id: 69c67d80be092db17703d672524124ca5ef7ba32
      d19f7312
    • Eric Niebler's avatar
      Copying a non-const FunctionRef lvalue should be a trivial operation · 6435670b
      Eric Niebler authored
      Summary: Before this change, when a non-const FunctionRef lvalue is copied, it is treated as any other callable: it is wrapped with an indirection. That's semantically incorrect and potentially creates lifetime problems. Instead, use the compiler generated copy constructor, which only copies the object and function pointers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5040843
      
      fbshipit-source-id: f691060bdced2e287ba22d22b961c02c2b924147
      6435670b
  7. 11 May, 2017 7 commits
    • Nick Terrell's avatar
      Switch uncompressedLength to an Optional<uint64_t> · 1e8e9c94
      Nick Terrell authored
      Summary: Instead of using `UNKNWON_UNCOMPRESSED_LENGTH` use an `Optional`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5038919
      
      fbshipit-source-id: 7fb60542277019996be3ff50509df5a5060cb1a0
      1e8e9c94
    • Ashwin Bharambe's avatar
      Outline `Optional::require_value()` · 42c42914
      Ashwin Bharambe authored
      Summary:
      We would like to use `folly/Optional` in settings where exceptions
      are disabled. An example is ObjC++ codebases where supporting exceptions
      doesn't quite help (since objc_msgSend() can throw) and yet we need to pay the
      additional binary size cost for the unwind tables.
      
      This patch makes a small change to outline the "assert" utility included
      inside Optional.h
      
      Reviewed By: yfeldblum, mzlee
      
      Differential Revision: D5030172
      
      fbshipit-source-id: 7def3c6eda22c41c8cab2037444978e0a4c50abf
      42c42914
    • Philip Pronin's avatar
      AsyncIO::cancel · c8aadaad
      Philip Pronin authored
      Summary:
      It should be implemented with `io_cancel`, but it is not
      supported (D682836), so still have to drain events, ignoring only
      op callbacks.
      
      Reviewed By: luciang, ot
      
      Differential Revision: D5044020
      
      fbshipit-source-id: 0bcd04c91a437fccaf2189ccf771a1cb61c68942
      c8aadaad
    • Victor Zverovich's avatar
      Fix a race on destruction of ScopedEventBaseThread · e17fce32
      Victor Zverovich authored
      Summary:
      This diff fixes a race that happens on destruction of `ScopedEventBaseThread`.
      
      ```
      Thread1: ~ScopedEventBaseThread()
      Thread1: eb_.terminateLoopSoon() <- preempted just after stop_ = true
      Thread2: eb->loopForever() in run(...) exits because stop_ is true
      Thread2: ...
      Thread2: eb->~EventBase()
      Thread1: queue_->putMessage(nullptr) <- accesses destroyed EventBase
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5042654
      
      fbshipit-source-id: 95515ed7cde09ff5f125ef121bea86ab3907f98a
      e17fce32
    • Yedidya Feldblum's avatar
      hasher instances for 8-bit and 16-bit integral types · 9c626faa
      Yedidya Feldblum authored
      Summary:
      [Folly] `hasher` instances for 8-bit and 16-bit integral types.
      
      Allowing the use of `Hash` with such types.
      
      They are not necessarily the ideal algorithms for those widths, essentially forwarding to the 32-bit instances.
      
      Reviewed By: luciang
      
      Differential Revision: D5043094
      
      fbshipit-source-id: 6ef96dfc8d1baf0a15b9bdd585b7c7672099e4f0
      9c626faa
    • Kevin Chen's avatar
      Add writable() to AsyncTransport · f3bbb0b1
      Kevin Chen authored
      Summary:
      This is useful for checking if it's possible to still write to a transport,
      even if its read side is closed (for transports that support half shutdown,
      like AsyncSocket). Default implementation just returns true for now (up
      to implementers to override).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4982649
      
      fbshipit-source-id: 0a9a2e2b745ea3db57e9f151f3a8634e1bda2465
      f3bbb0b1
    • Mathieu Baudet's avatar
      add missing const to fix `folly::toDynamic` on `std::vector<bool>` · ea2c005e
      Mathieu Baudet authored
      Summary: [folly] add missing const to fix `folly::toDynamic` on `std::vector<bool>`
      
      Reviewed By: ender-wieczorek, yfeldblum
      
      Differential Revision: D5039403
      
      fbshipit-source-id: edd052c7d1d832d424166cba15fcd9f4f8bd219c
      ea2c005e
  8. 10 May, 2017 2 commits
    • Victor Loh's avatar
      Add pollWithRusage to Subprocess · 31751bbf
      Victor Loh authored
      Summary:
      I was looking for a way to get rusage of a particular pid because
      getrusage isn't good enough since it records the rusage of all the children
      that has been terminated (and waited for). Even though wait4 is marked as
      deprecated, wait3 (the cousin of wait4) is still being used in places like
      time. Furthermore, there is no suitable replacement to get rusage with wait*.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5008084
      
      fbshipit-source-id: 6e511ebec7464d21309e5112aca95083e9307ea1
      31751bbf
    • Anton Lunov's avatar
      Revert D4982969: [Folly] Destroy promise/future callback functions before waking waiters · 646be295
      Anton Lunov authored
      Summary: This reverts commit 71134c1657bdd4c38c12d8ca17f8335ef4c27352
      
      Differential Revision: D4982969
      
      fbshipit-source-id: fc1e766a5fd03fbd02c345904c3c6587013f38d5
      646be295
  9. 09 May, 2017 6 commits
    • Arkadiy Shapkin's avatar
      Fix FBString with MSVC · e8d25954
      Arkadiy Shapkin authored
      Summary: Closes https://github.com/facebook/folly/pull/588
      
      Reviewed By: ericniebler
      
      Differential Revision: D5029876
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 6a8f16373dcfb1c7b2741eb808da0f6dbc4207b6
      e8d25954
    • Eric Niebler's avatar
      Add folly::Identity function object to Utility.h; replace AtomicHashArray's... · abc55483
      Eric Niebler authored
      Add folly::Identity function object to Utility.h; replace AtomicHashArray's AHAIdentity and folly/gen's Identity with it
      
      Summary: Code duplication is bad.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5011806
      
      fbshipit-source-id: cab7bb3af1c934a5a63cd3fb98aa33f2578aebfb
      abc55483
    • Arkady Shapkin's avatar
      Support static gflags library · 6d94a087
      Arkady Shapkin authored
      Summary: Closes https://github.com/facebook/folly/pull/587
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5022071
      
      Pulled By: Orvid
      
      fbshipit-source-id: 2506087de76ba4544bf68a330bc2a18977c65f28
      6d94a087
    • Yedidya Feldblum's avatar
      Destroy promise/future callback functions before waking waiters · 0be5c0a4
      Yedidya Feldblum authored
      Summary:
      Code may pass a callback which captures an object with a destructor which mutates through a stored reference, triggering heap-use-after-free or stack-use-after-scope.
      
      ```lang=c++
      void performDataRace() {
        auto number = std::make_unique<int>(0);
        auto guard = folly::makeGuard([&number] { *number = 1; });
        folly::via(getSomeExecutor(), [guard = std::move(guard)]() mutable {}).wait();
        // data race - we may wake and destruct number before guard is destructed on the
        // executor thread, which is both stack-use-after-scope and heap-use-after-free!
      }
      ```
      
      We can avoid this condition by always destructing the provided functor before setting any result on the promise.
      
      Reviewed By: spacedentist
      
      Differential Revision: D4982969
      
      fbshipit-source-id: 71134c1657bdd4c38c12d8ca17f8335ef4c27352
      0be5c0a4
    • Philipp Unterbrunner's avatar
      back_emplace_iterator and related classes and utility functions · d5986bf0
      Philipp Unterbrunner authored
      Summary:
      C++ up to and including C++17 lacks an alternative to std::back_inserter() that uses emplace_back() instead of push_back(). This causes unnecessary temporary objects in some cases, when using std::back_inserter() together with STL functions such as std::copy() or std::transform(). The same holds for std::front_inserter() and std::inserter().
      This diff introduces folly::back_emplacer(), folly::front_emplacer(), folly::emplacer(), and related iterator classes, which call emplace_back(), emplace_front(), and emplace() respectively, with perfect forwarding of any arguments to the output iterator's operator=.
      Includes support for variadic emplacement / multi-argument constructors through a utility function folly::make_emplace_args() which packs its arguments into a special tuple for use with operator=.
      
      Reviewed By: ericniebler
      
      Differential Revision: D4897174
      
      fbshipit-source-id: c85c30c457e0c946938051819baa662d1a0b8ca1
      d5986bf0
    • Christopher Dykes's avatar
      Codemod folly::make_unique to std::make_unique · f34acf2c
      Christopher Dykes authored
      Summary: There are still some upstream references to `folly::make_unique` that need to be removed before it can be full killed, but this gets it most of the way there.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5024310
      
      fbshipit-source-id: 6cfe8ea93662be18bb55588c8200dec72946e205
      f34acf2c
  10. 08 May, 2017 3 commits
    • Jim Meyering's avatar
      change EXPECT_EQ(false, ... to EXPECT_FALSE(...; ditto for true/EXPECT_TRUE · fea92be9
      Jim Meyering authored
      Summary:
      Change every instance of EXPECT_EQ(false, ... to the simpler/shorter EXPECT_FALSE(...
      Likewise, convert each EXPECT_EQ(true, ... to EXPECT_TRUE(...
      
      Differential Revision: D5019004
      
      fbshipit-source-id: 0203f10fa47237f869a75a057ac4456ef03e1f53
      fea92be9
    • Anirudh Ramachandran's avatar
      Move OpenSSLPtrTypes.h from folly/io/async/ssl to folly/ssl · 6b1a43fd
      Anirudh Ramachandran authored
      Summary:
      There's nothing io/async/ssl-specific in this file. Moving to the
      top-level directory will help this be more discoverable. Part of general cleanup
      for io/async/ssl
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5005566
      
      fbshipit-source-id: 66a05a2139ee80a6d63791d1851da3f1858e8abf
      6b1a43fd
    • Dave Watson's avatar
      Add hardware crc impl · d9acfc9e
      Dave Watson authored
      Summary:
      A faster crc32 impl for folly.  Similar to crc32c, except
      intel doesn't provide crc32 directly in hardware - instead, pclmul can be used,
      which is ~2x slower than crc32c, but still ~5-10x faster than software implementation.
      
      Reviewed By: Orvid, yfeldblum
      
      Differential Revision: D4994761
      
      fbshipit-source-id: ad8ba856649eea6dc7b541d561329ff7d7fe2d60
      d9acfc9e