1. 09 Apr, 2018 2 commits
    • Alexander Zhavnerchik's avatar
      Fix operator->() · c0909b44
      Alexander Zhavnerchik authored
      Summary:
      According to http://en.cppreference.com/w/cpp/language/operators
        The overload of operator -> must either return a raw pointer or return an object (by reference or by value), for which operator -> is in turn overloaded.
      
      Hence this change.
      
      Reviewed By: mnv104
      
      Differential Revision: D7548832
      
      fbshipit-source-id: d98ff1f96bc00dc6e2e5cb084b96091a61421627
      c0909b44
    • Denis Samoylov's avatar
      brush up built-in commands in NestedCommandLineApp · acd1c17a
      Denis Samoylov authored
      Summary:
      Tudor who wrote this left the company... so RB.. you are the reviewers :)
      
      1. make default commands as constants
      2. remove fake message about ",h"
      3. align quota usage from mix to '
      4. add support for version command
      5. add function to identify built-in command (is needed for an external application to make a decision if something is mandatory or not)
      
      Reviewed By: marcinpe
      
      Differential Revision: D7048169
      
      fbshipit-source-id: b48cf7df28cfa387e028a1cc869332407314c906
      acd1c17a
  2. 08 Apr, 2018 1 commit
    • Alex Guzman's avatar
      Add some more OpenSSL 1.1.0 compat functions · 6d3f73dd
      Alex Guzman authored
      Summary: Adds a few more OpenSSL compatibility functions for working with X509_STORE and its objects.
      
      Reviewed By: knekritz
      
      Differential Revision: D7540930
      
      fbshipit-source-id: 0275a200d673386988bc25140b1d827859b04364
      6d3f73dd
  3. 07 Apr, 2018 1 commit
    • Marc Celani's avatar
      Make hazptr_obj copyable and moveable · a8f11418
      Marc Celani authored
      Summary: hazptr_obj is copyable and moveable, but doing so would cause a bug, because the next ptr would point to the object that was copied/moved from, which can oftentimes be garbage or another object that has not yet retired. This diff changes the copy/move constructors and assignment operators to simply check that the rhs has not been retired.
      
      Reviewed By: magedm
      
      Differential Revision: D7539444
      
      fbshipit-source-id: f9325c7b886fcf4b553344ee37f2355ca41268b6
      a8f11418
  4. 06 Apr, 2018 2 commits
    • Adam Simpkins's avatar
      install CMake package config file under lib/cmake/folly · cb28abd6
      Adam Simpkins authored
      Summary:
      Install the CMake package configuration file under lib/cmake/folly rather than
      share/folly.  CMake will automatically search both of these locations, but
      lib/cmake/folly appears to be a more commonly-used location across other open
      source projects.
      
      Reviewed By: Orvid
      
      Differential Revision: D7479056
      
      fbshipit-source-id: becd3d4c05e774d2aede20f6a7a50f57d6c05875
      cb28abd6
    • Adam Simpkins's avatar
      cmake: improvements to the installed package config file · 10d1edd8
      Adam Simpkins authored
      Summary:
      - Use CMakePackageConfigHelpers to help generate the file
      - Print a message about where folly was found if not using QUIET
      - Make the include, lib, and cmake installation directories configurable
      
      Reviewed By: wez
      
      Differential Revision: D7479058
      
      fbshipit-source-id: 2548acc9d6de90d11da02ac576a58ce5ca939766
      10d1edd8
  5. 05 Apr, 2018 5 commits
  6. 04 Apr, 2018 10 commits
    • Brian Gesiak's avatar
      Fix Coro.Sleep test for opt builds · db453a5b
      Brian Gesiak authored
      Summary:
      Optimized builds of //folly/experimental/coro test Coro.Sleep
      would almost always fail because the compiler would generate
      code that would only sleep for 0.98 seconds. Perform some
      simple rounding in order to ignore slight optimizations like
      these.
      
      Reviewed By: wqfish
      
      Differential Revision: D7496416
      
      fbshipit-source-id: f81ff30922fbf3e5d2086fde50f4a469bdf72e51
      db453a5b
    • Nathan Bronson's avatar
      document transferrability of F14HashToken between instances · dad687f7
      Nathan Bronson authored
      Summary:
      F14HashToken encapsulates the work of hash_function(), which
      is the same across F14 containers that have the same key_type and equal
      hash_function() (same type and operator==).  This diff adds documentation
      that callers may rely on this fact, which means they can use this feature
      to reduce work if a single key is access in multiple maps/sets.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: shixiao
      
      Differential Revision: D7506737
      
      fbshipit-source-id: 321032d619434501b1e0544962e54732bfc4c970
      dad687f7
    • Janusz Kudelka's avatar
      sorted_vector_types use the underlying container value_type · 9a31b9e8
      Janusz Kudelka authored
      Summary:
      Allow the user to give their own pair implementation. This allows
      using a packed pair.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7504521
      
      fbshipit-source-id: 11888594b8b3ef3f530ebd95b8006ef6f5afbc65
      9a31b9e8
    • Tom Jackson's avatar
      Pretty Big Numbers · 2caf3abc
      Tom Jackson authored
      Summary: Terabytes aren't Web Scale.
      
      Reviewed By: ot, philippv, luciang
      
      Differential Revision: D7479752
      
      fbshipit-source-id: fd353933e642b1ee024c28107c8fcb6a55fe755e
      2caf3abc
    • Tom Jackson's avatar
      double_conversion eats the 'e' in '123e' · 29fd00d2
      Tom Jackson authored
      Summary: Until I do a PR on `double_conversion`, we need to work around this by catching the trailing 'e' case.
      
      Reviewed By: luciang
      
      Differential Revision: D7481130
      
      fbshipit-source-id: 2734dbe834e6cd69c6dfe41d6b4e9a7a548a7da8
      29fd00d2
    • Jun Li (Wormhole)'s avatar
      Cancel immediate read callback when socket has error · ed0d101c
      Jun Li (Wormhole) authored
      Summary:
      When `startFail()` is called, it sets the state to StateEnum::ERROR.
      There is a chance that immediate read callback is scheduled to run in
      next event loop. The callback calls handleRead() then triggers
      `assert(state_ == StateEnum::ESTABLISHED)` in `AsyncSokcet::handleRead`.
      
      Cancel any immediate read callback when startFail is called.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7051956
      
      fbshipit-source-id: 0d6693d851b272355a4f36ab8d001969fa47750e
      ed0d101c
    • Brian Gesiak's avatar
      Reduce recursion, for ASAN at -O0 · f6ca0ac0
      Brian Gesiak authored
      Summary:
      At `-O0` each coroutine call results in a heap allocation. This
      combined with the increased memory pressure when using ASAN
      results in an invalid memory access beyond the maximum address.
      Avoid the problem by limiting the recursion to 5,000 frames deep,
      instead of 10,000. This still fulfills the intent of the test,
      but without pushing the limits of ASAN.
      
      Reviewed By: wqfish
      
      Differential Revision: D7503976
      
      fbshipit-source-id: 7850a9d9db23328d42c25b74a1290caa7773e6a7
      f6ca0ac0
    • Andrii Grynenko's avatar
      Remove sendRequestSync from RSocketClientChannel · 9d98a85d
      Andrii Grynenko authored
      Summary: sendRequestSync should only be implemented by channels, which own threads looping EventBases.
      
      Reviewed By: phoad
      
      Differential Revision: D7464392
      
      fbshipit-source-id: bde6edc85438bb406592291330869972f88c787a
      9d98a85d
    • Nathan Bronson's avatar
      make F14 prehash token default constructible · e5a6b518
      Nathan Bronson authored
      Summary:
      Using an array of prehash tokens is quite inconvenient without
      the ability to default construct them.
      
      Reviewed By: shixiao
      
      Differential Revision: D7490113
      
      fbshipit-source-id: f802a7dc6dc2c603c4682e5f384d9f135220cd54
      e5a6b518
    • Alex Wang's avatar
      Remove std:: from index_sequence in Synchronized ctor · 68cb50c5
      Alex Wang authored
      Summary:
      Apple Clang 9 (clang-900.0.39.2) on macOS 10.13.3, when configured with
      `FOLLY_USE_LIBCPP`, fails to build `SynchronizedTest.cpp` with the following
      error:
      
          In file included from /Users/awang/code/folly/folly/test/SynchronizedTest.cpp:20:
          /Users/awang/code/folly/folly/Synchronized.h:511:9: error: no matching constructor for
                initialization of 'folly::Synchronized<int, NonDefaultConstructibleMutex>'
                : Synchronized{std::piecewise_construct,
                  ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~
          /Users/awang/code/folly/folly/test/SynchronizedTest.cpp:539:25: note: in instantiation
                of function template specialization 'folly::Synchronized<int,
                NonDefaultConstructibleMutex>::Synchronized<int &&, int &&>' requested here
            auto&& synchronized = folly::Synchronized<int, NonDefaultConstructibleMutex>{
                                  ^
          /Users/awang/code/folly/folly/Synchronized.h:499:12: note: candidate constructor not
                viable: no known conversion from 'const std::__1::piecewise_construct_t' to
                'in_place_t' (aka 'folly::in_place_tag (&)(folly::in_place_tag)') for 1st argument
            explicit Synchronized(in_place_t, Args&&... args)
                     ^
          /Users/awang/code/folly/folly/Synchronized.h:764:3: note: candidate template ignored:
                could not match 'std::__1::integer_sequence' against 'folly::integer_sequence'
            Synchronized(
            ^
          <other constructors not viable due to number-of-parameter mismatches>
      
      The proximate cause of the error is that `make_index_sequence` is
      generating a `folly::index_sequence`, but the delegatee constructor only
      accepts `std::index_sequence`.
      
      Changing the delegatee constructor to take an unqualified `index_sequence`
      solves the problem, since the return type for an unqualified
      `make_index_sequence` should be the same as the unqualified
      `index_sequence`.
      
      This appears to have been introduced in
      8581e9e0.
      
      Clang ends up using the Folly implementation of
      `make_integer_sequence` because `__cpp_lib_integer_sequence` is
      still not defined, even though `integer_sequence` support was added
      to libc++ way back in mid-2013, in revision 185343. There is a bug open
       on the LLVM bug tracker (#18584 [1]) to add the
      `__cpp_lib_integer_sequence` and other feature test macros,
      but the last activity on it was in late 2014. This results in
      the compiler successfully finding the definition for `std::index_sequence`
      (unlike what would happen with C++11 compilers), but using the folly
      implementation for `make_index_sequence`.
      
      Qualified `std::index_sequence` is used in a few other places, but `std::`
      was not removed from those usages because they reside in functions that
      have C++14 features that would prevent a C++11 compiler from compiling
      them at all, let alone with a `std::` v.s. `folly::`
      mismatch:
      
          - folly/test/FormatBenchmark.cpp
              - decltype(auto) is used for format20Numbers()
          - folly/container/Foreach-inl.h
              - decltype(auto) and generic lambdas are used in a few of the
                for_each_range_impl() overloads
              - decltype(auto) is used in some of the impl() overloads
              - decltype(auto) is used as the return type for fetch()
          - folly/container/Iterator.h
              - decltype(auto) is used as the get_emplace_arg() and unwrap_emplace_arg() return type
      
      A different way of solving the problem would be to add a special case
      for Clang to the `integer_sequence` check, similar to what is done for
      MSVC, but that seemed like partially papering over the problem. The best
      solution would be to get those feature macros into libc++, but that
      wouldn't help for already-released versions of LLVM.
      
          [0]: https://blogs.msdn.microsoft.com/vcblog/2014/06/06/c14-stl-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/
          [1]: https://bugs.llvm.org/show_bug.cgi?id=18584
      Closes https://github.com/facebook/folly/pull/810
      
      Reviewed By: aary
      
      Differential Revision: D7482813
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 36310acbc227bfe646d6fad877a406b8d57407e5
      68cb50c5
  7. 03 Apr, 2018 4 commits
    • Orvid King's avatar
      Always use folly::index_sequence · ec7690d7
      Orvid King authored
      Summary:
      Continuing from D7482813, ensure everywhere in folly is using the folly versions of integer and index sequences.
      Also implement index_sequence_for and use it.
      
      Reviewed By: aary
      
      Differential Revision: D7490483
      
      fbshipit-source-id: 082209dd6c6ca11f67b38dbe4529d46e9dce57ce
      ec7690d7
    • Steve O'Brien's avatar
      folly/String: split out `UTF8StringPiece` · 92320e04
      Steve O'Brien authored
      Summary:
      This has functionality not overlapping with `FBString` or `folly::fbstring` or `folly::StringPiece`; and a pretty expensive dependency on `boost/regex`.
      
      Much of the thrift-gen `_types.h` code comes from this inclusion chain:
      
      * `_types.h` uses strings (for `str` fields in thrift structs); these are represented by `folly::fbstring`, from...
      * `folly/String.h` includes `FBString.h` and other things to support string-related stuff; simple enough.  But it has a class `UTF8StringPiece`, which uses an iterator, from Boost called `boost::u8_to_u32_iterator<char const *>`.  So then we have...
      * `boost/regex/pending/unicode_iterator.hpp` includes tons of things in the usual boost header avalanche: iterator facades, lots of `mpl` code.
      
      Reviewed By: meyering
      
      Differential Revision: D7373577
      
      fbshipit-source-id: efdb920b6fe8c7b7c57d3becf2bf0710975fcf73
      92320e04
    • Xiao Shi's avatar
      fix erase use-after-free in F14Vector containers · d22d402e
      Xiao Shi authored
      Summary:
      Upon `erase`, F14 vector containers destroys the value and erases the item
      (i.e., index into the `values_` vector) from the underlying hashtable. However,
      the item still needs to be hashable when erasing from the hashtable, so we have
      to destroy the value _afterwards_.
      
      This diff fixes the bug.
      
      There are a couple of reasons that this was previous undetected / did not cause
      a problem:
        * for POD types, `allocator_traits::destroy` is a no-op.
        * this code path is only hit if the chunk of the destroyed item has hosted
          overflowed items
        * the use was immediately after free
        * our test coverage did not have vector policy + non-SSO string keys
      
      Reviewed By: nbronson
      
      Differential Revision: D7488050
      
      fbshipit-source-id: ea29e875a0c7a39b8deed40a15777a6983438836
      d22d402e
    • Anton Likhtarov's avatar
      folly::settings basic functionality · 3cec1c6b
      Anton Likhtarov authored
      Summary:
      A library that provides gflags-like functionality, with the addition of:
      - Threadsafe read/writes for all flags
      - Arbitrary C++ types
      - No declare/define split, all setting definitions are declaration and are safe to place in headers
      - Runtime introspection of all flags
      - Compile time and runtime collision checks
      - Namespaces per project
      
      Down the road:
      - Overlay support (change a set of settings based on some context)
      - Construct arbitrary user types from string
      - Support multiple library instances with distinct settings in a single process
      - Callbacks on setting updates
      
      Reviewed By: aary, mnv104
      
      Differential Revision: D6217956
      
      fbshipit-source-id: 7c03d79c7601ce7b266df78e62b7193712d8331e
      3cec1c6b
  8. 02 Apr, 2018 1 commit
  9. 01 Apr, 2018 1 commit
    • Andrew Gallagher's avatar
      folly/Singleton: remove use of `link_whole` · 7c996f43
      Andrew Gallagher authored
      Summary:
      We used `link_whole` to make sure the `setStackTraceGetter` constructor is
      always linked when using Singleton's to setup symbolizer for stack traces.
      However, using `link_whole` means we always link in the singleton library, even
      if it's never used.
      
      This diff merges `SingletonStackTrace.cpp` into `Singleton.cpp` to avoid the
      need for `link_whole` and to link the former if and only if we use the latter.
      
      Reviewed By: pixelb
      
      Differential Revision: D7230733
      
      fbshipit-source-id: de9be51a4eefee201563523d25800ab19ea777e3
      7c996f43
  10. 31 Mar, 2018 3 commits
    • Orvid King's avatar
      Explicitly mark the pthread forward declarations as extern C · c73cbb82
      Orvid King authored
      Summary: These were being mangled as C++ functions rather than C functions.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7462668
      
      fbshipit-source-id: e4e83e16aafad3d888599dd78bdbb4ac2711ad7f
      c73cbb82
    • Orvid King's avatar
      Drop unused exception local · 9f878bfe
      Orvid King authored
      Summary: It's unused, remove it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7462683
      
      fbshipit-source-id: 604c5691d69f2576c83c25350d29515efbc77a7b
      9f878bfe
    • Orvid King's avatar
      Fix build of chrono/Conv.h under MSVC · 1b2d5ef8
      Orvid King authored
      Summary: `timespec` is defined in `sys/time.h`, so don't rely on `<chrono>` including it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7462731
      
      fbshipit-source-id: 590954e2230a0da322e2f5eb966bb49b18aa56f7
      1b2d5ef8
  11. 30 Mar, 2018 3 commits
  12. 29 Mar, 2018 4 commits
    • Dave Watson's avatar
      Remove batch · 1e71e4c0
      Dave Watson authored
      Summary:
      Remove hazptr_obj_batch feature.  Not required after D7429494:
      
      After timer runs out, *all* thread caches are cleaned up, not just the current one,
      so it should be safe to push anything to local thread cache, even if thread isn't used often,
      as long as *some* thread is used.
      
      Reviewed By: magedm
      
      Differential Revision: D7433978
      
      fbshipit-source-id: 01508fd199fcd267550efc08d2695b53f1569c84
      1e71e4c0
    • Dave Watson's avatar
      Timed reclamation · d211a58c
      Dave Watson authored
      Summary:
      Continued reclamation issues from lots of UnboundedQueue batches, or lots of threads.
      
      In addition to the current number of outstanding objects, cleanup *all threads* on a timer
      basis.
      
      Reviewed By: magedm
      
      Differential Revision: D7429494
      
      fbshipit-source-id: 7e9bdae9ae49927ca0b6e3f24963a4d4b23a4f0b
      d211a58c
    • Boris Burkov's avatar
      add StrictlyOrderable interface · a8e02287
      Boris Burkov authored
      Summary:
      I would like to store a folly::Poly I'm defining in an ordered
      container (boost::containers::flat_set). While I could implement operator<
      for exactly my type, it seems nicer to add it as another interface all
      Poly users can reuse.
      
      Reviewed By: ericniebler
      
      Differential Revision: D7415861
      
      fbshipit-source-id: 1912eaa009acea5c243db3e14fc0715a0829f251
      a8e02287
    • Yedidya Feldblum's avatar
      Move Replaceable mixin param defaults to base template · 87305387
      Yedidya Feldblum authored
      Summary:
      [Replaceable] Move `Replaceable` mixin param defaults to base template.
      
      Saves a few lines overall.
      
      Reviewed By: WillerZ
      
      Differential Revision: D7421561
      
      fbshipit-source-id: f56d1ffdd081b0a8a20cb7a492f06c9647445782
      87305387
  13. 28 Mar, 2018 3 commits
    • Erik Hortsch's avatar
      Remove check for uncaught exception · f2b80e52
      Erik Hortsch authored
      Summary: This check is causing some issues in github commits. Figuring out exactly which versions of 4.9 have the bug is a pain, so let's just get rid of it. See D6695110 for more context.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7431713
      
      fbshipit-source-id: 17d1b025edf52592495c5f69c5a15025b33b3895
      f2b80e52
    • Orvid King's avatar
      Support setThreadName on Windows · 1674ee82
      Orvid King authored
      Summary: Windows doesn't have a nice function to do this, so we have to do it ourself, throwing the right exception with a struct that no public header defines, because Windows.
      
      Reviewed By: akrieger
      
      Differential Revision: D5100900
      
      fbshipit-source-id: 4f6840e50c5c1aef36adade098739201c97b9af7
      1674ee82
    • Orvid King's avatar
      Remove FOLLY_DEPRECATED entirely · 511ddcc6
      Orvid King authored
      Summary: Actually remove it. All uses of it (outside of thrift) were removed in the previous diff.
      
      Reviewed By: ot
      
      Differential Revision: D7422614
      
      fbshipit-source-id: 6a59c34b3cbc0ee7c50f8cbf8c5e641352f2db1a
      511ddcc6