1. 20 Feb, 2018 2 commits
    • Chad Austin's avatar
      Fix typo in SharedMutex documentation · 37b2d8bb
      Chad Austin authored
      Summary: s/lock_unshared/unlock_shared/
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7017355
      
      fbshipit-source-id: 7f9d12b4c80cc796086a74890c58aceea931d93c
      37b2d8bb
    • Yedidya Feldblum's avatar
      Less goto in ltrimWhitespace and rtrimWhitespace · 1d687403
      Yedidya Feldblum authored
      Summary:
      [Folly] Less `goto` in `ltrimWhitespace` and `rtrimWhitespace`.
      
      The generated machine code remains unchanged for `g++ -O3` builds.
      
      Generally, prefer to use `goto` in cases which cannot, or which can only arduously, be accomplished without it. In other words, reserve `goto` to cases where `goto` is necessary, rather than to cases where it saves one line.
      
      Closes #732.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D7027269
      
      fbshipit-source-id: 91a4c5dba0e4c13dc727393799edc9b596cdb8b9
      1d687403
  2. 18 Feb, 2018 1 commit
    • Andrew Krieger's avatar
      std::make_from_tuple is VS2017+ · 69aa532b
      Andrew Krieger authored
      Summary: It's not available in VS2015u3.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7005874
      
      fbshipit-source-id: 5477018e444d9bf118089bbbcfabbbf4e16a3198
      69aa532b
  3. 17 Feb, 2018 1 commit
  4. 16 Feb, 2018 3 commits
    • Andrew Krieger's avatar
      Gate hazptr static_assert which is guaranteed to fail in MSVC · a47a5531
      Andrew Krieger authored
      Summary:
      std::atomic is no longer trivial, and VS2015 and VS2017 both
      fail this static assert, as will future versions of conforming compilers.
      Updates to folly mean that the hazptr header is transitively included in
      more places which makes it easier to trip this even when not using hazptr.
      Disabling this assert to visual studio at least saves users a headache.
      
      Reviewed By: yfeldblum, magedm
      
      Differential Revision: D7006587
      
      fbshipit-source-id: 8481e1d5668aee8cab703a04b2a390550c210a2c
      a47a5531
    • Nick Terrell's avatar
      Fix ConcurrentHashMap iterator copy · cf18a86f
      Nick Terrell authored
      Summary:
      UndefinedBehaviorSanitizer: null-pointer-use buck-out/dev-asan-ubsan/gen/folly/concurrency/concurrent_hash_map#header-mode-symlink-tree-with-header-map,headers/folly/concurrency/ConcurrentHashMap.h:440:30 in
      Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/882372015
      Summary (total time 1.49s):
        PASS: 0
        FAIL: 0
        SKIP: 0
        FATAL: 1
          folly/concurrency/test:concurrent_hash_map_test - ConcurrentHashMap.CopyIterator
        TIMEOUT: 0
        OMIT: 0
      ```
      
      Reviewed By: djwatson
      
      Differential Revision: D7003359
      
      fbshipit-source-id: d6764caf2dfb1f19cf5b38a9e89d7c0583c75412
      cf18a86f
    • Yedidya Feldblum's avatar
      Cut outdated comment referencing TFramedAsyncChannel · 83e410eb
      Yedidya Feldblum authored
      Summary: [Folly] Cut outdated comment referencing `TFramedAsyncChannel`.
      
      Reviewed By: knekritz
      
      Differential Revision: D7002980
      
      fbshipit-source-id: 206ac77abf8882e26a5b98ad4229c7a645912947
      83e410eb
  5. 15 Feb, 2018 2 commits
    • Andrii Grynenko's avatar
      addCallback API · 6dea6401
      Andrii Grynenko authored
      Summary: This makes it easier to integrate folly::Observer with callback-based code.
      
      Reviewed By: spalamarchuk
      
      Differential Revision: D6888234
      
      fbshipit-source-id: ccf9b57c07ee323ee11496d14f8c90e3331cc7bb
      6dea6401
    • Andrii Grynenko's avatar
      Make FiberManager.batonTimedWaitTimeout less flaky · 1172173d
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D6957008
      
      fbshipit-source-id: 848932827efaf8529513026b45446da2c1697253
      1172173d
  6. 14 Feb, 2018 1 commit
    • Phil Willoughby's avatar
      relax requirements on join wrapper template · 7ee12309
      Phil Willoughby authored
      Summary: The template that this template wraps requires only forward iterators, so it doesn't make sense for the wrapper to be stricter than that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6988987
      
      fbshipit-source-id: 575dcacf7b1873ea0d7112acf84670842ee82fa7
      7ee12309
  7. 13 Feb, 2018 2 commits
    • Nick Gibson's avatar
      ConcurrentHashMap Deletion Test · ac3169a8
      Nick Gibson authored
      Summary: Add hazptr_cleanup to ConcurrentHashMap destructor & add a test to ensure deletion is working.
      
      Reviewed By: djwatson
      
      Differential Revision: D6951359
      
      fbshipit-source-id: 277c304a0e5073605010b14764d05a27e6e10b2d
      ac3169a8
    • Maged Michael's avatar
      hazptr: Fix hazptr_cleanup · 8635022f
      Maged Michael authored
      Summary:
      Added missing steps for registering and deregistering per-thread hazptr_priv structures with the default domain.
      Updated tests to detect the error
      
      Reviewed By: djwatson, davidtgoldblatt
      
      Differential Revision: D6965459
      
      fbshipit-source-id: 6eb6a5981c1d22518f318ace7387a3941a013352
      8635022f
  8. 12 Feb, 2018 2 commits
    • Igor Sugak's avatar
      enable FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER macro in ASAN · a12a2a09
      Igor Sugak authored
      Summary:
      It's common to use UBSAN with ASAN at the same time, and we'll merge them eventually too. As a result we can check for ASAN defined macros to conditionally compile code for UBSAN.
      
      We still have a few build modes that use standalone UBSAN, and unlike other sanitizers, UBSAN doesn't define a magic macro that we could use. In the past we added UNDEFINED_SANITIZER to our compiler flags, but I'd like to go away from it towards a more standard solution (eg check for ASAN).
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D6931054
      
      fbshipit-source-id: 4b298d1cd72cecd693bf99eda309568ef019c544
      a12a2a09
    • Sergey Anpilov's avatar
      Make folly.TypeError compatible with -Wdeprecated · 4e5b3630
      Sergey Anpilov authored
      Summary: Starting with C++11, implicit generation of copy/move constructors/operators in presence of user-defined destructors/constructors/operators is deprecated
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6875337
      
      fbshipit-source-id: a623a3ce2e7f5559d2de2324565c8995682085c7
      4e5b3630
  9. 09 Feb, 2018 4 commits
  10. 08 Feb, 2018 3 commits
    • Yedidya Feldblum's avatar
      A transparent adapter to facilitate the is_transparent protocol · 7c1e9ed8
      Yedidya Feldblum authored
      Summary:
      [Folly] A `transparent` adapter to facilitate the `is_transparent` protocol.
      
      Compare types with member type or member alias `is_transparent` may be used to enable heterogeneous lookup in ordered containers which support it, such as `std::set` and `std::map` as of C++14, and `folly::sorted_vector_set` and `folly::sorted_vector_map`.
      
      In some cases, nothing more is required than to add that `is_transparent` member to an existing compare type - `folly::transparent` may facilitate such cases.
      
      Example:
      
      ```lang=c++
      using TransparentStringPieceLess = folly::transparent<std::less<folly::StringPiece>>>;
      std::map<std::string, float, /* Compare = */ TransparentStringPieceLess> m;
      m["somekey"] = 12.;
      m.find(folly::StringPiece("somekey"))->second = 13.; // heterogeneous lookup
      ```
      
      To demonstrate the example, rewrite the `folly::sorted_vector_set` and `folly::sorted_vector_map` transparent-lookup tests.
      
      Reviewed By: ot
      
      Differential Revision: D6921862
      
      fbshipit-source-id: 306ff1f6f178ae29ac80ee7cd28595b80fc393d1
      7c1e9ed8
    • Jiawei Ou's avatar
      OpenSSL adaptor for OpenSSL1.1.0 · cd90eca5
      Jiawei Ou authored
      Summary: Implement some OpenSSL 1.1.0 specific methods, so that code written with OpenSSL 1.1.0 can be compiled with OpenSSL 1.0.2
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6930234
      
      fbshipit-source-id: 257893787cecdfeaf9df13dce0ada46c15990699
      cd90eca5
    • Maged Michael's avatar
      hazptr: Fix null domain_ dereference in ~hazptr_array · 8c0bca50
      Maged Michael authored
      Summary: Fix a case of null pointer dereference when ~hazptr_array() calls ~hazptr_holder(). For speed hazptr_array doesn't fill the domain_ field of hazptr_holder. The common case is that elements of the array are taken from and returned to the thread cache. If ~hazptr_array() doesn't find enough space in the thread cache, then it calls ~hazptr_holder() with a null domain_. The fix is to set domain_ to &default_hazptr_domain() before calling ~hazptr_holder() in such a case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6928705
      
      fbshipit-source-id: 9c756dce2854a2d1869a0712c4e6ed30f5df6b30
      8c0bca50
  11. 07 Feb, 2018 7 commits
    • Yedidya Feldblum's avatar
      Work around UB signed-integer-overflow in Histogram · 72512e53
      Yedidya Feldblum authored
      Summary: [Folly] Work around UB `signed-integer-overflow` in `Histogram`.
      
      Reviewed By: igorsugak
      
      Differential Revision: D6922381
      
      fbshipit-source-id: 96ab6ffae9509ce8138f1741ea976226dec597c8
      72512e53
    • Yedidya Feldblum's avatar
      Fix UB signed-integer-overflow in tracing test · b8d7f18e
      Yedidya Feldblum authored
      Summary: [Folly] Fix UB `signed-integer-overflow` in tracing test.
      
      Reviewed By: igorsugak
      
      Differential Revision: D6922450
      
      fbshipit-source-id: 0d9a338fdcf205987d88875aac4112666ca32b65
      b8d7f18e
    • Fred Emmott's avatar
      add missing ifndef FOLLY_NO_CONFIG around include in folly/compression/Counters.cpp · 10a4cd2a
      Fred Emmott authored
      Summary: Needed to update folly in the open source build of HHVM.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6913772
      
      fbshipit-source-id: 50e540fe30651c991dc198ede66d4816a85f68db
      10a4cd2a
    • Adam Simpkins's avatar
      logging: suppress ASAN warnings about leaking the LoggerDB singleton · d2364be6
      Adam Simpkins authored
      Summary:
      During program destruction we destroy registered log handlers (to allow them to
      flush state if desired).  However we intentionally leak the LoggerDB object
      itself and the LogCategory objects it contains, so it will still be safe if
      static destruction code that runs later still tries to log messages.
      
      However, when run with `ASAN_OPTIONS` set to `detect_leaks=1` ASAN complains
      about the fact that we leak the LoggerDB singleton.
      
      This changes the code to store the LoggerDB address in a static variable, to
      prevent ASAN from complaining that we leak it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6920772
      
      fbshipit-source-id: 62f6837053ba4a538a89b4b61f9b1c722f253d33
      d2364be6
    • Maged Michael's avatar
      folly] hazptr: Add hazptr_cleanup function · 2518ee52
      Maged Michael authored
      Summary: The free function hazptr_cleanup reclaims all reclaimable objects retired to a domain before this call.
      
      Reviewed By: djwatson
      
      Differential Revision: D6876253
      
      fbshipit-source-id: 54a6b98291712286597561e971fc9b6ac9c4d6f0
      2518ee52
    • Yedidya Feldblum's avatar
      Do nothing in spin_pause_until if spin_max is zero · 5ec4d977
      Yedidya Feldblum authored
      Summary:
      [Folly] Do nothing in `spin_pause_until` if `spin_max` is zero.
      
      Rather than go through the loop at all, if the instruction is not to spin - encoded as `spin_max <= 0` - then return early.
      
      Reviewed By: nbronson
      
      Differential Revision: D6910431
      
      fbshipit-source-id: fa94510e7ec1ebdd7bc3f1a407dcf70e1e153b40
      5ec4d977
    • Zekun Li's avatar
      use weak ref for event loop to avoid leaking it · 3b08af41
      Zekun Li authored
      Summary: This dict holds strong reference to all the loops and leads to leak if new loop is created and used, change it to weakref to avoid it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6892775
      
      fbshipit-source-id: a628a3743876ef0580acce5fb9f283da573cf459
      3b08af41
  12. 06 Feb, 2018 8 commits
    • Adam Simpkins's avatar
      logging: add a default handler during early initialization · d81cde8f
      Adam Simpkins authored
      Summary:
      This updates the code to create a default LogHandler that logs to stderr when
      the main LoggerDB singleton is first created.  With this change users will get
      reasonable log behavior even if they never call `folly::initLogging()` (log
      messages will go to stderr instead of being ignored).
      
      This new initialization code can potentially run very early during program
      initialization (before `main()` starts and before folly `Singleton`
      initialization) if some code in the program logs messages before main.  However
      this current initialization code should be safe to run before main.
      
      For compilers that support weak symbols (clang and gcc), I have defined
      `initializeLoggerDB()` as a weak symbol, allowing users to override this
      behavior at link time on a per-program basis should they choose to.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6893207
      
      fbshipit-source-id: 13b72a01aa383c4611204df88ff8dad93abcc7b2
      d81cde8f
    • Michael Lee's avatar
      Remove the assertion that thread cache and private are enabled · b05a90dc
      Michael Lee authored
      Summary: With the mobile thread_local changes, these assertions are no longer correct.
      
      Reviewed By: magedm
      
      Differential Revision: D6915065
      
      fbshipit-source-id: 42072ed638b3dca56cba65ca0cff5e4d7aef2cb3
      b05a90dc
    • Adam Simpkins's avatar
      logging: update LoggerDB::get() to return a reference · 9656bacc
      Adam Simpkins authored
      Summary:
      Change `LoggerDB::get()` to a reference instead of a pointer since this
      function can never return null.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6893206
      
      fbshipit-source-id: af47063918a79c851fd39b838d6c63755166e033
      9656bacc
    • Adam Simpkins's avatar
      logging: disallow move construction/assignment for LogCategory · 18c4beb3
      Adam Simpkins authored
      Summary:
      LogCategory objects store pointers to their parent and sibling categories.  The
      address of each LogCategory therefore matters, and we cannot allow moving them
      to another address.
      
      Explicitly delete the move constructor and assignment operator to ensure that
      no-one ever accidentally tries to move a LogCategory object.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6893208
      
      fbshipit-source-id: 32f36c5992e850cc6e90d02c7c74fb758e9f745b
      18c4beb3
    • Adam Simpkins's avatar
      cmake: compile with -Wno-nullability-completeness · d7dfcff9
      Adam Simpkins authored
      Summary:
      When compiling with clang, also specify -Wno-nullability-completeness
      
      We currently use this flag for internal Facebook builds using buck.  This
      brings the CMake and buck compilation command lines closer in sync.  Even
      though the folly code currently does not produce any nullability completeness
      warnings, we are likely to break this in the future since we do not have
      this warning enabled internally.
      
      It also seems like `-Wnullability-completeness` results in code that cannot be
      compiled successfully across various clang versions.  Recent versions of clang
      complain about missing nullability specifiers on `std::unique_ptr` arguments,
      while slightly older clang versions produce compilation errors if nullability
      specifiers are listed on anything but raw pointers.
      
      Reviewed By: igorsugak
      
      Differential Revision: D6902930
      
      fbshipit-source-id: 0b8cd5eca17cf8f9deda6b0c32f5838489542128
      d7dfcff9
    • Alexey Spiridonov's avatar
      Enable IPv6 loopback for tests · 7c644897
      Alexey Spiridonov authored
      Summary:
      Unit tests using the IPv6 loopback would fail on Travis with `[::1]:0: Cannot assign requested address`.
      
      The issue is discussed at length here: https://github.com/travis-ci/travis-ci/issues/8711
      
      Reviewed By: jstrizich
      
      Differential Revision: D6914321
      
      fbshipit-source-id: c247c6760dddcd875a67f7b31419bde974514f19
      7c644897
    • Bennett Magy's avatar
      Added getShared function to Observer::Snapshot · d2604fb2
      Bennett Magy authored
      Summary:
      Added a function to Observer::Snapshot that allows the user to get the shared_ptr held in a snapshot. This is to make it easier to integrate Observers with other Api's that expect shared_ptrs.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D6909245
      
      fbshipit-source-id: 4fe108e04f43a5a250bd7bdc3031994833d73a60
      d2604fb2
    • Yedidya Feldblum's avatar
      Hack around MSVC not supporting constexpr storage · 63fcb6c7
      Yedidya Feldblum authored
      Summary:
      [Folly] Hack around MSVC not supporting `constexpr` storage.
      
      GCC and Clang do, but MSVC does not, support:
      
      ```lang=c++
      extern int const num;
      constexpr int const num = 3;
      ```
      
      Work around it.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D6903413
      
      fbshipit-source-id: 3a0957816d8d82718fb6187dc1803df1605f80aa
      63fcb6c7
  13. 05 Feb, 2018 4 commits
    • Dave Watson's avatar
      Increase refcount size · 36f840db
      Dave Watson authored
      Summary:
      The refcounting logic is correct, however, decreasing the next node's
      refcount only happens in ~NodeT, after going through hazptr bulkReclaim.
      
      The current default for bulkReclaim is 1k, which exceeds the value of
      refcount uint8_t.  Increase size to uint16_t so that we don't wrap refcount
      before bulkReclaim calls the node destructors.
      
      Reviewed By: magedm
      
      Differential Revision: D6900530
      
      fbshipit-source-id: 9b2530dc6cd0609b4795b909fd46aeffbb1ae821
      36f840db
    • Adam Simpkins's avatar
      add a build status badge to the README · 8e8bfe9c
      Adam Simpkins authored
      Summary:
      Now that we have Travis CI builds enabled and passing, add a link to the build
      status to the README.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6903206
      
      fbshipit-source-id: 643b72a63a4113e00ff1602b1c3638384115b23d
      8e8bfe9c
    • Petr Lapukhov's avatar
      Add JSONPointer support · 6c653dc9
      Petr Lapukhov authored
      Summary:
      Allow retrieving sub-tree from folly::dynamic using JSON pointer syntax (RFC6901). This adds new overload for the `get_ptr` method, retrieving raw pointer to a sub-tree, or returning `nullptr` if element is not found.
      
      The `folly::dynamic` implementation traverses the path specified by JSON pointer string dynamically every time, since the underlying object may change, and JSON pointer traversal depends on the underlying object structure. E.g. "123" could be a key name for `dynamic::object` and index in `dynamic::array`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6790515
      
      fbshipit-source-id: bb6ea10acb83673e87721cf1e5a02506b44bb273
      6c653dc9
    • Igor Kobzar's avatar
      fbcode_builder: Update cmake for debian 8.6 os image · 32a318c7
      Igor Kobzar authored
      Summary: Debian 8.6 comes with a CMake version that is too old for folly. Add commands to update cmake.
      
      Reviewed By: snarkmaster
      
      Differential Revision: D6842797
      
      fbshipit-source-id: 22f4c407f82a92c3fa90a5c2de334cf8b92e584b
      32a318c7