1. 11 Apr, 2017 5 commits
  2. 10 Apr, 2017 7 commits
    • Alexander Shaposhnikov's avatar
      Remove superfluous std::move · 0fa94136
      Alexander Shaposhnikov authored
      Summary: Cleanup: remove superfluous std::move for return values.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4856421
      
      fbshipit-source-id: bf2cb66f3b43eb8f3b183e22b0acd31e0a0c0958
      0fa94136
    • Nick Terrell's avatar
      Fix std::max() call in Compression.cpp · 03ce292a
      Nick Terrell authored
      Summary:
      `std::max(uint64_t, size_t)` was called.
      Fixes https://github.com/facebook/folly/issues/576.
      
      Reviewed By: Orvid
      
      Differential Revision: D4861336
      
      fbshipit-source-id: 1b6f67b291451048ba79d638d2c1184f9245dc0c
      03ce292a
    • Christopher Dykes's avatar
      Fix the build... Whoops... · b8ec2ef5
      Christopher Dykes authored
      Summary: I landed a change to Folly that used a feature I had just re-written in Folly without updating the change. This has broken everything. Whoops.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4861562
      
      fbshipit-source-id: 05beadbe233d1fdf90fb4435e65b718cdec7f63e
      b8ec2ef5
    • Christopher Dykes's avatar
      Re-work the OpenSSL portability header to be a portability header · 9783dc4e
      Christopher Dykes authored
      Summary:
      It was defining the same functions as OpenSSL, but it was putting them in the `folly::ssl` namespace and requiring a manual `use namespace` everywhere to actually be able to use it. Proper portability headers require no interaction to function correctly other than including them in the build.
      This adjusts it so including it is all that is required to get an OpenSSL 1.1.0 compatible API.
      This also re-organizes the code to significantly lower the amount of nesting in the `#if`'s, and puts it in order from oldest APIs to newest, rather than haphazard.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4856784
      
      fbshipit-source-id: 7c00fdf4a3e51e37287d2b1ef294046f38a96a43
      9783dc4e
    • Jason Fried's avatar
      Client RequestChannels and folly/python/futures.h · 46b709bc
      Jason Fried authored
      Summary:
      Use RequestChannel to construct Thrift Clients.
      
      use folly/python/futures.h to marry up thrift client rpc futures to
      asyncio futures. No gil exchanges
      
      py3 clients are async context managers now.
      
      Reviewed By: ambv, yfeldblum
      
      Differential Revision: D4639677
      
      fbshipit-source-id: 6b400747507446882d3cfcb1cf7e85c3daa07a2e
      46b709bc
    • Andrii Grynenko's avatar
      Fix folly/test:singleton_test - Singleton.SharedPtrUsage · b422f6b5
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D4856138
      
      fbshipit-source-id: 19eee4f8c4108ef168d82d5e9b1f2d65ff9b03bd
      b422f6b5
    • Christopher Dykes's avatar
      Refactor FOLLY_GCC_DISABLE_WARNING to play nice with clang-format · e15da103
      Christopher Dykes authored
      Summary: Currently clang-format cannot be run on any file using the macro because it breaks it. By putting the warning name in a string clang-format no longer breaks it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4856945
      
      fbshipit-source-id: ebd2d223dd97f66224e9e2912610057e36287dae
      e15da103
  3. 08 Apr, 2017 6 commits
    • Yedidya Feldblum's avatar
      All template params for PriorityMPMCQueue · 1f52e58c
      Yedidya Feldblum authored
      Summary:
      [Folly] All template params for `PriorityMPMCQueue`.
      
      Mimic the suite of template params of `MPMCQueue`.
      
      Reviewed By: magedm
      
      Differential Revision: D4857179
      
      fbshipit-source-id: 3d441099c46ea1223155bd3f4cc819595814c47b
      1f52e58c
    • Christopher Dykes's avatar
      Fix include ordering for OpenSSLPtrTypes.h · 3e09d2ba
      Christopher Dykes authored
      Summary: When including OpenSSL on Windows, the portability header must be included before including any OpenSSL headers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4856376
      
      fbshipit-source-id: a8e6533b2ba3c003314ae2426605031fa67be05f
      3e09d2ba
    • Christopher Dykes's avatar
      Qualify a couple local constexpr values as 'static' to allow use from within non-capturing lambdas · 3e0c28fd
      Christopher Dykes authored
      Summary: MSVC doesn't allow non-static locals to be accessed within a non-capturing lambda, and some were introduced into the json code.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4856242
      
      fbshipit-source-id: b2db36ca37a79a41237d39cc7e7b839a5416922f
      3e0c28fd
    • Giuseppe Ottaviano's avatar
      Fix leak in EliasFanoCodingTest · 92693aaf
      Giuseppe Ottaviano authored
      Summary: `EliasFanoCompressedList` requires explicit freeing.
      
      Reviewed By: lbrandy, philippv, yfeldblum, luciang
      
      Differential Revision: D4855200
      
      fbshipit-source-id: ccee44b6371ae743ef15a72af9b691d5b56e37c2
      92693aaf
    • Louis Brandy's avatar
      ReadMostlySharedPtrTest, subtle test bug caught by -fsanitize-address-use-after-scope · 5c04f9ac
      Louis Brandy authored
      Summary: Because these `atomic<int>` are referenced in the destructor of the `ReadMostlyMainPtr`, they must be declared before it, otherwise they are destroyed before it i.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4854964
      
      fbshipit-source-id: 625a8f890bba166b682ca13558f8bcde86edcc75
      5c04f9ac
    • Louis Brandy's avatar
      fix EvictingCacheMap test bug found w/ -fsanitize-address-use-after-scope · 6ea7629b
      Louis Brandy authored
      Summary: This test actually stores references to `sum` in objects it puts into the `EvictingCacheMap`. Those references get accessed in the destructor of the objects, which is the destructor of the `EvictingCacheMap`. That means the `sum` variable must outlive (and be declared -before-) the `EvictingCacheMap` it's testing.
      
      Reviewed By: yfeldblum, meyering
      
      Differential Revision: D4854619
      
      fbshipit-source-id: b0a3109278f48d10b4cd0c52a12cb2064f4a00c5
      6ea7629b
  4. 07 Apr, 2017 2 commits
    • Anirudh Ramachandran's avatar
      Fix leak in HMAC_CTX_free compat API · 9620aea0
      Anirudh Ramachandran authored
      Summary:
      D4406876 replaced EVP_MD_CTX and HMAC_CTX on the stack with heap-allocated
      versions. We omitted the _cleanup functions thinking those didn't actually free
      anything, but turns out HMAC_CTX_cleanup internally calls EVP_MD_CTX_cleanup
      which OPENSSL_frees a bunch of stuff.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4850388
      
      fbshipit-source-id: 4ef1413a4105f3638140e4d12aeae64afe43f099
      9620aea0
    • Phil Willoughby's avatar
      Fix a logic error in StringKeyedTest · 905ba447
      Phil Willoughby authored
      Summary: Make sure that the last use of `s6` is sequenced before it is moved-from.
      
      Reviewed By: nbronson
      
      Differential Revision: D4850480
      
      fbshipit-source-id: 5272c14475ae2c62bc613cfd54f5df482b19d3dc
      905ba447
  5. 06 Apr, 2017 4 commits
    • Alan Frindell's avatar
      Get rid of try/catch in messageAvailable, which is now noexcept · 3a7d377d
      Alan Frindell authored
      Summary: The problem with catching the exception here is stack information is lost.  Just let it std::terminate if it throws
      
      Reviewed By: ikobzar
      
      Differential Revision: D4831909
      
      fbshipit-source-id: 42139bd7caee0fedff13328d52fa3be1c517e730
      3a7d377d
    • Andrii Grynenko's avatar
      Require registrationComplete() not only in dbg builds · 1b6b202c
      Andrii Grynenko authored
      Summary: Improve error message and change DFATAL to FATAL.
      
      Reviewed By: yfeldblum, meyering
      
      Differential Revision: D4837840
      
      fbshipit-source-id: 54ae53c9356fc2e85266b037996aa7b2bae3d4e4
      1b6b202c
    • Phil Willoughby's avatar
      Update StringKeyed... benchmarks to tell the whole story · dc235503
      Phil Willoughby authored
      Summary:
      Benchmark each type with its native key type and with its non-native key type.
      This allows you to make a more-informed decision about which to use based on
      the types you have available at insertion/lookup time.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4826527
      
      fbshipit-source-id: ee4ef5255d2bdd955e9deb30dc4c28be183cee07
      dc235503
    • Maged Michael's avatar
      IndexedMemPool: Fix race condition on size_ that can cause the destructor to... · bba519bf
      Maged Michael authored
      IndexedMemPool: Fix race condition on size_ that can cause the destructor to access nonexistent slots
      
      Summary:
      Contention on allocation when there is exactly one slot remaining can cause size_ to exceed actualCapacity_.
      Without taking the min of size_ and actualCapacity_ the destructor may try to destroy out-of-bound slots.
      
      Added a test to test/IndexedMemPoolTest.cpp that failed before the fix and passes after the fix.
      
      Reviewed By: nbronson
      
      Differential Revision: D4837251
      
      fbshipit-source-id: a887487727f17eaf2ba66345f40fc91d2fe3bc00
      bba519bf
  6. 05 Apr, 2017 3 commits
    • Alan Frindell's avatar
      Make NotificationQueue::Consumer::messageAvailable noexcept · 674533ad
      Alan Frindell authored
      Summary: There's a comment in that code that states that it *it* noexcept, and that is common for most folly async io callbacks.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4831800
      
      fbshipit-source-id: 78894ad72504b9dfe540c14b8d7bbb29247aaf87
      674533ad
    • Subodh Iyengar's avatar
      Add trimAtMost functions · 120cc11d
      Subodh Iyengar authored
      Summary:
      Add trimAtMost start and trimAtMost end.
      These are useful functions to have if you
      don't care about trimming an exact amount.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4658087
      
      fbshipit-source-id: f7dd62c0f4837503e59cdec75fdad433be20306c
      120cc11d
    • Christopher Dykes's avatar
      Disable EnvUtil::setAsCurrentEnvironment() on platforms without clearenv() · 2d2d3d3f
      Christopher Dykes authored
      Summary:
      Implementing `clearenv()` correctly on multiple OS's without relying on underlying implementation details is significantly more complicated, and this is preventing being able to build on OSX.
      This function isn't actually used anywhere currently.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4832473
      
      fbshipit-source-id: a80aabb5a223264746ab45e3138d065bce5fe99c
      2d2d3d3f
  7. 04 Apr, 2017 6 commits
    • Eli Lindsey's avatar
      use folly singleton relaxed init on android · d6cd4a4a
      Eli Lindsey authored
      Summary: fixing D4825412
      
      Reviewed By: lbrandy
      
      Differential Revision: D4826815
      
      fbshipit-source-id: 94691ff293dad53b16e7a2f139c1df490a61e565
      d6cd4a4a
    • Maxim Georgiev's avatar
      Make some AsyncTest methods virtual to allow mocking them using gtest/gmock · 96791c45
      Maxim Georgiev authored
      Summary: GMock can't mock class methods that are not virtual. This way classes relying on the non-virtual methods of AsyncSocket can't be efficiently tested using gtest/gmock.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4806838
      
      fbshipit-source-id: fde852b75f7ac1d468c177e317c516cb0dc333b5
      96791c45
    • Sven Over's avatar
      Function.h: remove FOLLY_MSVC_DISABLE_WARNING · 22180318
      Sven Over authored
      Summary:
      We recently removed declarations of Function constructors and
      assignment operators that took non-const Function references. They
      were necessary at the time to make sure that the templated
      constructor that can take any invokable object did not get
      selected for copying Functions from non-const lvalues. This,
      however, is now provided by some std::enable_if construct.
      
      Reviewed By: ericniebler
      
      Differential Revision: D4818736
      
      fbshipit-source-id: 08197721beef009f6ae482b576df78ec6999d132
      22180318
    • Anirudh Ramachandran's avatar
      Support building with OpenSSL 1.1.0 and BoringSSL · cff341f9
      Anirudh Ramachandran authored
      Summary:
      More work to get wangle compiling. wangle/facebook/http pulls in
      proxygen libs and that's another pain altogether, so this only makes the rest of
      wangle build with 1.1.0 and BoringSSL
      
      Depends on D4406876
      
      Reviewed By: ngoyal
      
      Differential Revision: D4767060
      
      fbshipit-source-id: bd6bc6959d04028c84360e434f6bbdb2cde2faac
      cff341f9
    • Anirudh Ramachandran's avatar
      OpenSSL 1.1.0 compatibility · 95c8e072
      Anirudh Ramachandran authored
      Summary: Add more layers to support compiling with OpenSSL 1.1.0
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4406876
      
      fbshipit-source-id: 8eff7e4f8e096605fc9e1093ef533b5afe0ee539
      95c8e072
    • Andrii Grynenko's avatar
      Don't allow singleton use w/o registrationComplete() · 7d0d018f
      Andrii Grynenko authored
      Summary: This is same as D4249032, but for now this is only enabled in dbg and dev builds. I'm planning to bump this to FATAL later, once we fix know problematic main()s.
      
      Reviewed By: lbrandy, yfeldblum
      
      Differential Revision: D4821763
      
      fbshipit-source-id: 5f7930f8cbcb10275d23a89848f1ec8ee34a8020
      7d0d018f
  8. 03 Apr, 2017 5 commits
    • Nick Terrell's avatar
      Remove use of generic lambdas · 0fdbb3df
      Nick Terrell authored
      Summary:
      The use of generic lambdas caused compiler errors with gcc 4.8.2.
      Fixes https://github.com/facebook/folly/issues/569.
      
      Reviewed By: Orvid, yfeldblum
      
      Differential Revision: D4821115
      
      fbshipit-source-id: 8372ee7695a3d0a1df0d033623618a923c261737
      0fdbb3df
    • Harrison Klaperman's avatar
      Fix broken ManualExecutor · 6e183a44
      Harrison Klaperman authored
      Summary:
      The priority queue in the manual executor implementation is backwards. This means that scheduled things run in reverse order, and a later thing will block an earlier thing if you advance to a timestamp in between the two.
      
      This diff fixes the problem and adds tests to confirm the fix. These tests fail on the old implementation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4739101
      
      fbshipit-source-id: 6e429828460df5b3c656580568a9ae1eb4009527
      6e183a44
    • Christopher Dykes's avatar
      Don't use macros for FBVector::insert · 30df0947
      Christopher Dykes authored
      Summary: Macros are not the best solution anymore.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4270626
      
      fbshipit-source-id: 8acbd5b778d4effcfb587655b4397737bef0d379
      30df0947
    • Dan Melnic's avatar
      Remove/make private the default ***Holder constructor to allow compile time... · a130b23a
      Dan Melnic authored
      Remove/make private the default ***Holder constructor to allow compile time detection of ***Holder(mutexPtr_) constructs
      
      Summary: Avoid unintended C++ stuff - this is not the same as the "fleeting rvalue" - this change might break the build but I will fix it
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4814104
      
      fbshipit-source-id: 058a0eac44893c573062fcf5665d4fd022ee64a0
      a130b23a
    • Dave Watson's avatar
      atomic_shared_ptr · bd068648
      Dave Watson authored
      Summary:
      A (almost) lock-free atomic_shared_ptr, matching the proposed concurrency TS interface.
      
      See notes at top of file
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D4716098
      
      fbshipit-source-id: b9ca2443ba9e227ebb6f40807128073c6e14222a
      bd068648
  9. 01 Apr, 2017 2 commits
    • Giuseppe Ottaviano's avatar
      Optimize JSON escaping of ASCII strings · 2f0cabfb
      Giuseppe Ottaviano authored
      Summary:
      `escapeString` is very slow even when there's very little to nothing to escape. This diff adds a fast path to copy sequences of bytes that don't need escaping.
      It also optimizes appending escape sequences: `string::push_back` is slow because it has to do a capacity check for every character.
      
      Before:
      ```
        ============================================================================
        folly/test/JsonOtherTest.cpp                    relative  time/iter  iters/s
        ============================================================================
        jsonSerialize                                              818.55ns    1.22M
        jsonSerializeWithNonAsciiEncoding                            1.35us  738.06K
        jsonSerializeWithUtf8Validation                              1.42us  705.60K
        jsonSerializeAsciiWithUtf8Validation                         3.27us  306.06K
        parseSmallStringWithUtf                                      1.91us  522.38K
        parseNormalString                                            1.51us  660.27K
        parseBigString                                             384.44ns    2.60M
        toJson                                                     480.54ns    2.08M
        ============================================================================
      ```
      
      After:
      ```
        ============================================================================
        folly/test/JsonOtherTest.cpp                    relative  time/iter  iters/s
        ============================================================================
        jsonSerialize                                              781.69ns    1.28M
        jsonSerializeWithNonAsciiEncoding                          847.68ns    1.18M
        jsonSerializeWithUtf8Validation                            928.68ns    1.08M
        jsonSerializeAsciiWithUtf8Validation                       199.85ns    5.00M
        parseSmallStringWithUtf                                      1.93us  518.39K
        parseNormalString                                            1.45us  689.11K
        parseBigString                                             378.66ns    2.64M
        toJson                                                     446.38ns    2.24M
        ============================================================================
      ```
      
      All string escaping benchmarks are slightly faster, and ASCII-only with no escapes is 8x faster.
      
      Reviewed By: luciang, evilmucedin, yfeldblum
      
      Differential Revision: D4793233
      
      fbshipit-source-id: c40d07708bd787799c8c00f9f23a417b862ee9ae
      2f0cabfb
    • Mainak Mandal's avatar
      fix memory leak in case of large number of retries · 8e16a2eb
      Mainak Mandal authored
      Summary: Infinite retries is something that is often needed for read-modify-write like workflows. The current implementation was creating a nested chain of implicit promises. This manifests as a memory leak after some time. Worse yet, even if it succeeds, it will take a long time to churn thru the chain of promises.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4770335
      
      fbshipit-source-id: 44b8d6df1084de4514b66919a9838cf2322d6dce
      8e16a2eb