1. 29 Oct, 2017 1 commit
    • Yedidya Feldblum's avatar
      Move folly/Assume.h · 2ee091de
      Yedidya Feldblum authored
      Summary: [Folly] Move `folly/Assume.h` to `folly/lang/`.
      
      Reviewed By: luciang, ot
      
      Differential Revision: D6181983
      
      fbshipit-source-id: 25564bb07daa1a6765651cd919b4778efb931446
      2ee091de
  2. 28 Oct, 2017 3 commits
    • Andrew Krieger's avatar
      Break out BitIterator into its own header · cbd3e7fb
      Andrew Krieger authored
      Summary:
      BitIterator is a standalone construct that has a heavy boost
      dependency, but not common usage. Breaking it out into its own header
      will help a lot of transitive dependendencies, because it is included
      in Hash.h which is included in a variety of other common headers.
      
      This reduces the number of transitively included headers by 248 (!)
      
      Reviewed By: yfeldblum, ot, luciang
      
      Differential Revision: D6178564
      
      fbshipit-source-id: 1380154b012615b7b8c73bc15ab0ac62f6b990d3
      cbd3e7fb
    • Yedidya Feldblum's avatar
      Move folly/detail/AtomicUtils.h · e89f46cd
      Yedidya Feldblum authored
      Summary: [Folly] Move `folly/detail/AtomicUtils.h` to `folly/synchronization/detail/`.
      
      Reviewed By: Orvid
      
      Differential Revision: D6180482
      
      fbshipit-source-id: 5671c149a59eea824db2935ffabcf85a2f78b690
      e89f46cd
    • Scott Michelson's avatar
      LOG_EVERY_N instead of every time · f72422cc
      Scott Michelson authored
      Summary: when queues fill, this starts blowing up, affecting server performance and making logs useless. It's useful to know queues are full, but we don't need the log every time we try to append
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6175784
      
      fbshipit-source-id: b4e6966087c4a6f9fba51d7f9193b9f41e13b899
      f72422cc
  3. 27 Oct, 2017 2 commits
    • Yedidya Feldblum's avatar
      Fix FunctionScheduler::resetFunctionTimer concurrency bug · d89c342a
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `FunctionScheduler::resetFunctionTimer` concurrency bug.
      
      The original code from the blamed diff code has a comment with this correct assessment of the bug:
      > TODO: This moves out of RepeatFunc object while folly:Function can potentially be executed. This might be unsafe.
      
      Namely, when the method is invoked with the id of a scheduled function which is concurrently being executed, the function object (including, say, lambda captures) will be moved while possibly being accessed. If the function object is small enough to be placed in-situ within `folly::Function` (48 bytes on x64), then that access to a moved-from object can happen. It might or might not, depending on the particular instance of the race in question. Or, worse, the access might be to a half-moved-from object!
      
      The new test case for `resetFunctionTimer` passes after the fix, but is guaranteed to fail before the fix because we manage to control the concurrency enough to force the bad version of the race to happen. In the test, we just capture a `std::shared_ptr` (we could have capatured, e.g., a `std::unique_ptr` or a long-enough `std::string`) and check that it is not empty - if it is moved from, it will be empty, and the test expectation will fail.
      
      Reviewed By: simpkins
      
      Differential Revision: D6158722
      
      fbshipit-source-id: 33a7ae699bb3b22089fddbebb6d922737668309d
      d89c342a
    • Yedidya Feldblum's avatar
      type_t, a generalization of void_t · 7ec1449d
      Yedidya Feldblum authored
      Summary: [Folly] `type_t`, a generalization of `void_t`.
      
      Reviewed By: ericniebler
      
      Differential Revision: D6082913
      
      fbshipit-source-id: f9557b5da1f6684b12d570b6c1bd52c102cb0703
      7ec1449d
  4. 26 Oct, 2017 5 commits
    • Christopher Dykes's avatar
      Just use a volatile static in Malloc.h · a15fcb1e
      Christopher Dykes authored
      Summary: As suggested late in the initial diff (D5840883), just mark it volatile, as it works under all supported platforms.
      
      Reviewed By: davidtgoldblatt, yfeldblum
      
      Differential Revision: D6155241
      
      fbshipit-source-id: 00c07a11dc7fc2e33c2d1f9a45fd28006eeff6f9
      a15fcb1e
    • Christopher Dykes's avatar
      Fix build with Windows SDK v10.0.16232 · 760b0714
      Christopher Dykes authored
      Summary:
      It defines `MSG_ERRQUEUE` which breaks things.
      
      There's a github PR to do this in a different way, but it's faster to just do it myself.
      
      Closes https://github.com/facebook/folly/pull/689
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6155606
      
      fbshipit-source-id: f1c6b247efc452b4005ad3b6d82fabfd5a92f49f
      760b0714
    • Dan Melnic's avatar
      Disable zerocopy if we're notified about deferred copies, add a... · 8f4003a8
      Dan Melnic authored
      Disable zerocopy if we're notified about deferred copies, add a isZeroCopyWriteInProgress method, replace pair with a proper struct
      
      Summary: Add zeroWriteDone callback
      
      Reviewed By: djwatson
      
      Differential Revision: D6097129
      
      fbshipit-source-id: b82a942557680c3a7a3be8f81ee6f2886e99e165
      8f4003a8
    • Yedidya Feldblum's avatar
      Expected coroutines support · 0e8c7e1c
      Yedidya Feldblum authored
      Summary:
      [Folly] `Expected` coroutines support.
      
      Copied from `Optional` coroutines support.
      
      Reviewed By: ericniebler, Orvid
      
      Differential Revision: D5923792
      
      fbshipit-source-id: 8661012c65762a0e540a4af2fd2fc237a8cb87a1
      0e8c7e1c
    • Kenny Yu's avatar
      folly: Fix data race in folly::Codel · 9fb1f368
      Kenny Yu authored
      Summary:
      Data race reported by TSAN:
      
      ```
      WARNING: ThreadSanitizer: data race (pid=608219)
        Read of size 1 at 0x7b5800000c29 by thread T314:
          #0 0x60b3441 in folly::Codel::overloaded(std::chrono::duration<long, std::ratio<1l, 1000000000l> >) ./folly/executors/Codel.cpp:76
          #1 0x5c1222 in apache::thrift::concurrency::ThreadManager::ImplT<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic, true, true> > >::Worker<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic, true, true> > >::run() ./thrift/lib/cpp/concurrency/ThreadManager.tcc:119
          #2 0x5d803e7 in apache::thrift::concurrency::PthreadThread::threadMain(void*) ./thrift/lib/cpp/concurrency/PosixThreadFactory.cpp:200
          #3 0x619739d in __tsan_thread_start_func crtstuff.c:?
      
        Previous write of size 1 at 0x7b5800000c29 by thread T315:
          #0 0x60b33e4 in folly::Codel::overloaded(std::chrono::duration<long, std::ratio<1l, 1000000000l> >) ??:?
          #1 0x5c1222 in apache::thrift::concurrency::ThreadManager::ImplT<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic, true, true> > >::Worker<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic, true, true> > >::run() ./thrift/lib/cpp/concurrency/ThreadManager.tcc:119
          #2 0x5d803e7 in apache::thrift::concurrency::PthreadThread::threadMain(void*) ./thrift/lib/cpp/concurrency/PosixThreadFactory.cpp:200
          #3 0x619739d in __tsan_thread_start_func crtstuff.c:?
      
        Location is heap block of size 768 at 0x7b5800000c00 allocated by main thread:
          #0 0x616ab83 in operator new(unsigned long) ??:?
          #1 0x53cb92 in __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<apache::thrift::concurrency::SimpleThreadManager<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic, true, true> > >, std::allocator<apache::thrift::concurrency::SimpleThreadManager<folly::LifoSemImpl<std::atomic, folly::Baton<std::atomic, true, true> > > >, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*)
          ...
      ```
      
      It looks like there are multiple threads reading and writing the `overloaded_` bool. To fix it, wrap it in a `std::atomic`.
      
      Reviewed By: yfeldblum, meyering
      
      Differential Revision: D6149766
      
      fbshipit-source-id: 605b29fa2f602d2ed2dfc22e46b739ef169f914e
      9fb1f368
  5. 25 Oct, 2017 4 commits
    • Luca Niccolini's avatar
      rework reads/writes · d4f016d5
      Luca Niccolini authored
      Summary:
      the current implementation had problems with scheduling reads and writes and
      it would sometimes get stuck when transfering large chunks of data
      
      here I am restructuring the code to look more like the one in HTTPSession
      
      session flow control is not implemented yet really, it's coming next
      
      Depends on: D6048238
      
      Reviewed By: afrind
      
      Differential Revision: D6048238
      
      fbshipit-source-id: ae601e771154a7f1a669a58a6e05c9e3720e7017
      d4f016d5
    • Marko Novakovic's avatar
      Supply an explicit default dtor impl · 43200974
      Marko Novakovic authored
      Reviewed By: yfeldblum
      
      Differential Revision: D6142252
      
      fbshipit-source-id: 9ac98585a92299ca5915982c65c7d2cfa68bf60f
      43200974
    • Yedidya Feldblum's avatar
      Flesh out Optional members swap, reset, emplace, has_value · 2ca10eee
      Yedidya Feldblum authored
      Summary:
      [Folly] Flesh out `Optional` members `swap`, `reset`, `emplace`, `has_value`.
      
      * `swap` as a member and deriving `noexcept`-ness to mimic `std::optional::swap`.
      * `reset` v.s. `clear` to mimic `std::optional::reset`.
      * `emplace` returning ref and overload taking initializer list to mimic `std::optional::emplace`.
      * `has_value` v.s. `hasValue` to mimic `std::optional::has_value`.
      
      Reviewed By: WillerZ
      
      Differential Revision: D6132775
      
      fbshipit-source-id: 34c58367b9dc63289e4b9721c5e79b1c41ba31e4
      2ca10eee
    • Yedidya Feldblum's avatar
      Simplify IsUniquePtrToSL in IOBuf.h · 2f5439e4
      Yedidya Feldblum authored
      Summary: [Folly] Simplify `IsUniquePtrToSL` in `IOBuf.h`.
      
      Reviewed By: Orvid
      
      Differential Revision: D6131231
      
      fbshipit-source-id: b054ef7ef9f313943a3ac1022ca6a23874a464df
      2f5439e4
  6. 24 Oct, 2017 4 commits
  7. 23 Oct, 2017 8 commits
  8. 22 Oct, 2017 1 commit
  9. 21 Oct, 2017 4 commits
  10. 20 Oct, 2017 3 commits
  11. 19 Oct, 2017 5 commits
    • Christopher Dykes's avatar
      Use nullptr rather than 0 for a null pointer · 0a609930
      Christopher Dykes authored
      Summary: This time aided by clang-tidy's modernize-use-nullptr check.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6102739
      
      fbshipit-source-id: aeb4bd0a8078d81cc88b766e0a034a37dd25fd1f
      0a609930
    • James Sedgwick's avatar
      move CallOnce to synchronization/ · 18172db6
      James Sedgwick authored
      Summary: as above
      
      Reviewed By: knekritz
      
      Differential Revision: D6088687
      
      fbshipit-source-id: 0efbb7f5fa33b5f553c0c2019658370fc6e8613f
      18172db6
    • Alex Yarmula's avatar
      Handle timekeeperSingleton being nullptr in within() · 084ff8d9
      Alex Yarmula authored
      Summary: When timekeeper singleton no longer exists during shutdown and folly::Singleton::try_get() can return nullptr, make sure nullptr is handled gracefully.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6101311
      
      fbshipit-source-id: fefeddfbd048d1a7632688bb3526db15b685dd72
      084ff8d9
    • Yedidya Feldblum's avatar
      Add InlineExecutor.cpp to Makefile.am · c7813369
      Yedidya Feldblum authored
      Summary: [Folly] Add `InlineExecutor.cpp` to `Makefile.am`.
      
      Reviewed By: Orvid
      
      Differential Revision: D6101859
      
      fbshipit-source-id: 4cd0f875dedb548189722fd719f4424d485e1b02
      c7813369
    • Yedidya Feldblum's avatar
      Fix fibers build on older boost · 70d3004b
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `folly/fibers/` build on older boost.
      
      Where `jump_fcontext` takes `intptr_t` rather than an actual pointer, and we warn about implicit conversions from pointers to integral types.
      
      Reviewed By: Orvid
      
      Differential Revision: D6098230
      
      fbshipit-source-id: 61bd7bdff5de728d3febe8b35c97d024ab6f236a
      70d3004b