1. 10 Apr, 2018 6 commits
    • Alexander Zhavnerchik's avatar
      folly::settings do not inline settings definition · 75765b5c
      Alexander Zhavnerchik authored
      Summary:
      If FOLLY_SETTING_DEFINE(...) is put into .cpp file right now you will get linker error about undefined references.
      
      According to http://en.cppreference.com/w/cpp/language/inline
        2) The definition of an inline function or variable (since C++17) must be present in the translation unit where it is accessed (not necessarily before the point of access).
      
      Hence the linker error. This diff fixes that.
      
      Reviewed By: alikhtarov, mnv104
      
      Differential Revision: D7567469
      
      fbshipit-source-id: 02049e4881e50c414aeb506745e02eed1256daad
      75765b5c
    • Adam Simpkins's avatar
      allow specifying the directory containing CMakeLists.txt · 7be9cf6a
      Adam Simpkins authored
      Summary:
      Update `cmake_configure()`, `cmake_install()`, and `fb_github_cmake_install()`
      to support specifying the directory where CMakeLists.txt is found, relative to
      the directory where the build is being performed.  Previously these functions
      where hardcoded to assume that CMakeLists.txt was always found at '..'
      
      Reviewed By: snarkmaster
      
      Differential Revision: D7540689
      
      fbshipit-source-id: efd3d044345fadc0346e436c01d0a247e1b6fd70
      7be9cf6a
    • Adam Simpkins's avatar
      add a `FOLLY_INIT_LOGGING_CONFIG()` helper macro · 48407345
      Adam Simpkins authored
      Summary:
      Add a macro to help users define the `getBaseLoggingConfig()` function.
      
      While I would prefer to avoid macros if possible, this seems worthwhile.  This
      saves 4 or 5 lines of boilerplate code in each program that sets a custom base
      logger setting.  It also reduces the likelihood of a developer accidentally
      having a typo in the function name, which would still build successfully but
      not have the desired results.
      
      Reviewed By: chadaustin
      
      Differential Revision: D7457652
      
      fbshipit-source-id: 1c316c7ea6949c16bd7b61c0440cc1ee69ecb83e
      48407345
    • Adam Simpkins's avatar
      logging: add an initLoggingOrDie() function · e374ef6a
      Adam Simpkins authored
      Summary:
      Add folly::initLoggingOrDie(), which behaves like `initLogging()` but handles
      errors by printing a message to stderr and then calling `exit(1)`.
      
      Most programs are expected to initialize logging early on during program
      start-up, and will likely use a command line argument or other configuration
      value as the logging settings.  If an error occurs they usually want to print
      the message to stderr and exit unsuccesfully. `initLoggingOrDie()` makes it
      easy to perform these steps without requiring programs to write their own
      exception handlers to handle errors from `initLogging()`.
      
      Reviewed By: chadaustin
      
      Differential Revision: D7164830
      
      fbshipit-source-id: d688046f1b6240c948e4aaabfc9fb24ba3d9ff89
      e374ef6a
    • Anton Likhtarov's avatar
      folly::settings: simplify; define/declare split; Metadata · dd2f2ef7
      Anton Likhtarov authored
      Summary:
      - Let's enforce a single definition. Also makes the implementation much simpler.
      - Collect all static info about a setting in a Metadata struct
      
      Differential Revision: D7544210
      
      fbshipit-source-id: d3f2ef617bd817d355a37e11fa9425b6a4259384
      dd2f2ef7
    • Eugene Pekurovsky's avatar
      F14Map: Add a method for getting the size of dynamically allocated map memory · f09d03aa
      Eugene Pekurovsky authored
      Summary:
      Currently, the memory used by a map instance is available only via computeStats(),
      which is quite expensive. A lightweight method is needed for getting the map memory
      footprint on a hot code path.
      
      Reviewed By: nbronson
      
      Differential Revision: D7544180
      
      fbshipit-source-id: 3cbc98bb9f1c5e7f75fd9eb7f89016580fbb6523
      f09d03aa
  2. 09 Apr, 2018 3 commits
    • Orvid King's avatar
      Fix build on MSVC2015 Update 3 · ed118811
      Orvid King authored
      Summary: Which only supports C++11 style constepxr.
      
      Reviewed By: simpkins
      
      Differential Revision: D7546457
      
      fbshipit-source-id: 52db98379096dd3b25f656e7e62238ce10537bf7
      ed118811
    • 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
  3. 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
  4. 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
  5. 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
  6. 05 Apr, 2018 5 commits
  7. 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
  8. 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
  9. 02 Apr, 2018 1 commit
  10. 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
  11. 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
  12. 30 Mar, 2018 3 commits