1. 09 Nov, 2015 3 commits
    • Shijin Kong's avatar
      change CHECK to LOG(ERROR) when pipe read error on NotificationQueue · e56f9393
      Shijin Kong authored
      Summary: The check was originally added to track down cpu pinning issue. In reality the check did get triggered, so change to soft error to calm the crazy nag bot. what's wrong with you.
      We need to see the soft error log to find out what the error is.
      
      Reviewed By: mzlee
      
      Differential Revision: D2632752
      
      fb-gh-sync-id: 87c11b186f97f0eb4a6c5ac13a1117b280198673
      e56f9393
    • Alexey Spiridonov's avatar
      Add a tag type for in-place construction · 7c4e381e
      Alexey Spiridonov authored
      Summary: Without this tag type, it's impossible to use `Synchronized` with types like:
      
      ```
      struct A {
        A(int, const char*);
        A(const A&) = delete;
        A& operator=(const A&) = delete;
        A(A&&) = delete;
        A& operator=(A&&) = delete;
      };
      ```
      
      In-place construction solves this problem. Usage:
      
      ```
      Synchronized a(construct_in_place, 5, "c");
      ```
      
      Reviewed By: nbronson
      
      Differential Revision: D2610071
      
      fb-gh-sync-id: 251fe8f8f6a2d7484dda64cf04dcacb998145230
      7c4e381e
    • Chad Parry's avatar
      Make sure there are no outstanding timers in the destructor · a93b1f39
      Chad Parry authored
      Summary: This is the solution for our `HHWheelTimer` crashes, as suggested in D2617966#25.
      
      djwatson also mentioned that maybe there should be some logging in the destructor if there are outstanding callbacks. I couldn't think of anything that would add to the `assert` that already exists in `destroy`. I'm open to suggestions though.
      
      Reviewed By: djwatson
      
      Differential Revision: D2628154
      
      fb-gh-sync-id: f3db6e9384517c9bf3cbb60af8c1e711703a07fa
      a93b1f39
  2. 08 Nov, 2015 1 commit
    • Igor Sugak's avatar
      folly/portability: add clang version check · 408597e5
      Igor Sugak authored
      Summary: Define `__CLANG_PREREQ` macro to check version of clang.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2630325
      
      fb-gh-sync-id: 3d666e554e8ddfc2c1fecd439aaf93f015829025
      408597e5
  3. 06 Nov, 2015 2 commits
    • Chad Parry's avatar
      Callbacks should ref the HHWheelTimer · cb65a6b2
      Chad Parry authored
      Summary: Callbacks sometimes outlive the `HHWheelTimer` that they reference. Then the `Callback` tries to reference the dead `HHWheelTimer` and it could either misbehave or crash. This was caught reliably by ASAN tests.
      
      Since `HHWheelTimer` already supports intrusive ref counting, the solution is to acquire a reference within the `Callback`.
      
      Reviewed By: djwatson
      
      Differential Revision: D2617966
      
      fb-gh-sync-id: 02be9ffc5851c269d5933288a17ad394b33ac2dd
      cb65a6b2
    • Jon Maltiel Swenson's avatar
      Cancel timeout only if not run · 06b04cb1
      Jon Maltiel Swenson authored
      Summary: Do not cancel TimeoutHandler timeout if the timeout has already run.
      
      Reviewed By: spalamarchuk
      
      Differential Revision: D2622280
      
      fb-gh-sync-id: 27d83b44ab225e2859695f4e5f21cef934824a35
      06b04cb1
  4. 05 Nov, 2015 3 commits
    • Haijun Zhu's avatar
      codemod setMaxNumMessagesInQueue to setMaxNumPendingConnectionsPerWorker · 131db120
      Haijun Zhu authored
      Summary: This name's meaning is very obscure, this method actually sets the
      queue size of each acceptor and if all acceptor's queues are full the
      connection will be dropped. Change it to a more meaningful name.
      
      Reviewed By: alandau
      
      Differential Revision: D2613681
      
      fb-gh-sync-id: baa374cdf0a87c460df3dd5687e3d755b55f4b4f
      131db120
    • Jon Maltiel Swenson's avatar
      Activate server timeout after write success · a166df21
      Jon Maltiel Swenson authored
      Summary: Start server timeout after socket write succeeds in mcrouter.  Add neceessary Fibers logic to enable this behavior.
      
      Reviewed By: pavlo-fb
      
      Differential Revision: D2613344
      
      fb-gh-sync-id: 1bc0fbe8b325a3e91cd010f89104b83ebf183679
      a166df21
    • Viswanath Sivakumar's avatar
      Set interrupt handler correctly on SharedPromise · 8cb94e9b
      Viswanath Sivakumar authored
      Summary: If SharedPromise::getFuture() is invoked after a call to setInterruptHandler,
      then the interrupt handler isn't set on the newly created promise. This diff
      fixes that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2610289
      
      fb-gh-sync-id: bf8fce9e881b83ccac17d13c6788ec2afd0b0153
      8cb94e9b
  5. 04 Nov, 2015 4 commits
    • Subodh Iyengar's avatar
      Add ability to get application protocol from AsyncTransportWrapper · 8f06296e
      Subodh Iyengar authored
      Summary: Allows AsyncTransportWrapper's to supply the underlying application
      protocol being used, for example using NPN for SSL or some other
      generic protocol indication mechanism.
      
      Reviewed By: ranjeeth
      
      Differential Revision: D2614179
      
      fb-gh-sync-id: 2079782bb7d44f898fb14c7df15077209b022424
      8f06296e
    • Zhen (Growth) Li's avatar
      switch the IndexType and Allocator in AtomicUnorderedInsertMap template · 46bf40d1
      Zhen (Growth) Li authored
      Summary: Our use case need to have the IndexType Configurable, but in this diff D2583752, lint error shows
        Code from folly::detail is logically private, please avoid use outside of folly.
      In order to fix this lint error, I switch the IndexType and Allocator in the AtomicUnorderedInsertMap template.
      
      Reviewed By: nbronson
      
      Differential Revision: D2610921
      
      fb-gh-sync-id: ae81b41e7c8c971f26c61b8c67dabeadff379584
      46bf40d1
    • Subodh Iyengar's avatar
      Allow underlying transport to be accessible from AsyncTransportWrapper · 8f29e483
      Subodh Iyengar authored
      Summary: Allow underlying transport to be accessible from AsyncTransportWrapper.
      There are some code paths where we need access to the real transport from
      the AsyncTransportWrapper. This allows us to retrieve the underlying transport
      and have clients like HTTPSession use it.
      
      Reviewed By: afrind
      
      Differential Revision: D2609200
      
      fb-gh-sync-id: 2b317d1825a005bb64468f83c64bc3f1c9bdfe2c
      8f29e483
    • Louis Brandy's avatar
      make folly slightly more c++-modules friendly · 7a78293e
      Louis Brandy authored
      Summary: .. by including what you use.
      
      These are a handful of headers that are depended on via viral inclusion. Include them directly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2601172
      
      fb-gh-sync-id: 215e87263325d085fbcb651f83f429f47d14fc1b
      7a78293e
  6. 03 Nov, 2015 2 commits
    • Louis Brandy's avatar
      qualify std::move in StringKeyedTest · fb450d12
      Louis Brandy authored
      Summary: Prefer `std::move` to `move` for clarity's sake.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2601138
      
      fb-gh-sync-id: 64a9e58a83da9c8416a0be5c45a292c6b1342664
      fb450d12
    • Anton Likhtarov's avatar
      Disallow nullptr literal in StringPiece constructor · 82ba5835
      Anton Likhtarov authored
      Summary: This disallows implicitly constructing a StringPiece from a literal nullptr at compile time
      (without this change, nullptr would cause a segfault in strlen()).
      
      Reviewed By: meyering, andriigrynenko
      
      Differential Revision: D2603597
      
      fb-gh-sync-id: cafbc45945bacc72a7c89310b99aa62d19a3ff9f
      82ba5835
  7. 31 Oct, 2015 1 commit
    • Andrew Gallagher's avatar
      Fix multi-line comment warnings · 89e6ee60
      Andrew Gallagher authored
      Summary: Fix warnings triggered by `-Wcomment`.
      
      Reviewed By: ajtulloch
      
      Differential Revision: D2603992
      
      fb-gh-sync-id: aae721f7c236d7d8b8bff2c077a481fc2affcf71
      89e6ee60
  8. 30 Oct, 2015 2 commits
  9. 29 Oct, 2015 4 commits
  10. 28 Oct, 2015 2 commits
    • Blake Matheny's avatar
      Suppress -Wshadow for SYNCHRONIZED · f3199c1a
      Blake Matheny authored
      Summary: SYNCHRONIZED warns with -Wshadow due to `for (auto&
      FB_ARG_1(__VA_ARGS__) =`. This diff just suppresses that warning.
      
      Reviewed By: djwatson
      
      Differential Revision: D2587348
      
      fb-gh-sync-id: 3a2e39fb6ce28da014950ca94e4b62ea80deb65f
      f3199c1a
    • Beny Luo's avatar
      Fix clang issue on NotificationQueue::size · 8281c7fa
      Beny Luo authored
      Summary: The implicit conversion loses integer precision: 'size_type' (aka 'unsigned
      long') to 'int'.
      
      Reviewed By: mzlee
      
      Differential Revision: D2585883
      
      fb-gh-sync-id: 1fc7c84b66c8f19cc36b798dd198730764e19b28
      8281c7fa
  11. 27 Oct, 2015 2 commits
    • Shaft Wu's avatar
      Track callback life cycle for HHWheelTimer and EventBase · 47f0d384
      Shaft Wu authored
      Summary: Further race is presented in HHWheelTimer and EventBase, since changing them to track callback life cycle is more involving, I am hacking around it to prove the concept. With the *fix*, no reproduce of the segmentation fault anymore.
      
      This is for proving the concept, code will be cleaned up if we agree this is reasonable direction to pursue.
      
      Reviewed By: fugalh
      
      Differential Revision: D2577715
      
      fb-gh-sync-id: e0bb0317268e6f02a54fc70454e63959fba70c10
      47f0d384
    • Jun Li's avatar
      Expose pending messages in queue stats in AsyncServerSocket · 28c5ca58
      Jun Li authored
      Summary: Expose pending messages in accept queue in AsyncServerSocket.
      
      Set default accept message queue size to 1024.
      
      Reviewed By: djwatson
      
      Differential Revision: D2525161
      
      fb-gh-sync-id: a69ea0ee77729e4a8300bde3e3c07840f2d5d3cb
      28c5ca58
  12. 26 Oct, 2015 5 commits
    • Lucian Grijincu's avatar
      folly: hash: specialize hash_combine_generic by size_t size · 59527d6a
      Lucian Grijincu authored
      Reviewed By: yangliu
      
      Differential Revision: D2578043
      
      fb-gh-sync-id: cec8f21219655a495b99d0b6b99f0925615bc068
      59527d6a
    • Florent Thoumie's avatar
      Add new toBinary() function to IPAddress. · fa9cc998
      Florent Thoumie authored
      Summary: This is pretty much the reverse operation from the fromBinary() constructor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2578680
      
      fb-gh-sync-id: d8c4e53fe8bc0f5373ebb0b4f7ee498659c1b003
      fa9cc998
    • Yedidya Feldblum's avatar
      Style nits for folly/test/FingerprintBenchmark.cpp · e56b41ec
      Yedidya Feldblum authored
      Summary: [Folly] Style nits for `folly/test/FingerprintBenchmark.cpp`.
      
      Reviewed By: Gownta
      
      Differential Revision: D2579463
      
      fb-gh-sync-id: 135bc3ef43708cb024f78c59672811159d2163e0
      e56b41ec
    • Mohammad Husain's avatar
      Rename two callback function names of ConnectionEventCallback · 22f86ef7
      Mohammad Husain authored
      Summary: Renaming `EnqueuedForAccept` and `DequeuedByAccept` to
      `EnqueuedForAcceptor` and `DequeuedByAcceptor` respectively to make it clear
      that the connection is queued for the Acceptor not to call `accept` on.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2554578
      
      fb-gh-sync-id: 072a9ff122658827d1e89f2bef79ad565dad7974
      22f86ef7
    • Shijin Kong's avatar
      return read error on non EAGAIN errno · 209397bd
      Shijin Kong authored
      Summary: Tested over weekend with D2571554. There was no EXC_RESOURCE/CPU crash when read errrors were returned on ENOTCONN. EAGAIN seems innocent as the spin detector was disabled on testing group.
      
      Patch folly. I can add #ifdef __APPLE__ around the errno checking code but this should be good practice for non apple code as well.
      
      I will remove debugging code in fbios master in another diff.
      
      Reviewed By: djwatson
      
      Differential Revision: D2580819
      
      fb-gh-sync-id: 9162a3deba01af8b07cd2b336d7da3da040c67a9
      209397bd
  13. 24 Oct, 2015 1 commit
    • Nathan Bronson's avatar
      fix AtomicUnorderedInsertMap load factor computation · 6b17defc
      Nathan Bronson authored
      Summary: AtomicUnorderedInsertMap's constructor takes a maxLoadFactor argument,
      which is given its default argument of 0.8f in all of our code.
      The clipping function that was supposed to prevent load factors
      greater than one was inverted, resulting in all of our code using a
      maxLoadFactor of 1 instead of 0.8.  This diff fixes the computation,
      as well as changing all of the use sites so that the actual memory
      allocated by existing clients does not change.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2575238
      
      fb-gh-sync-id: bb9dd8de53114236b259631d175d62af098391cf
      6b17defc
  14. 23 Oct, 2015 3 commits
    • Jon Maltiel Swenson's avatar
      Fibers allocation/deallocation benchmarks · bc857f03
      Jon Maltiel Swenson authored
      Summary: Add a couple benchmarks measuring allocation/deallocation latency.  One benchmark measures an allocate-deallocate repeated pattern, the other measures the allocation of a large chunk of fibers.
      
      We'll use these benchmarks later on after we modify the allocation/deallocation behavior of fibers.
      
      Reviewed By: pavlo-fb
      
      Differential Revision: D2573064
      
      fb-gh-sync-id: 414eb93d6223e42c187c03214a47dfb533491bab
      bc857f03
    • Bartosz Nitka's avatar
      Option to fallback to double when int precision is not enough. · a3bfe5b0
      Bartosz Nitka authored
      Summary: Some libraries like Haskell's `Data.Aeson` can produce arbitrarily
      big numbers with arbitrary precision.
      The json standard doesn't specify the ranges for numeric types.
      For interoperability, we should allow the user to parse the numbers with
      some loss of precision.
      
      Reviewed By: luciang
      
      Differential Revision: D2565140
      
      fb-gh-sync-id: b1a9a46e298bf13cc89d7e79ce28705e9e251a7f
      a3bfe5b0
    • Nathan Bronson's avatar
      templatize AtomicUnorderedInsertMap's internals to allow big maps · d0889c8c
      Nathan Bronson authored
      Summary: AtomicUnorderedInsertMap used 32 bit index values internally.  2 bits
      were stolen, limiting the capacity to 2^30.  This diff makes the internal
      index type a template parameter, so you can make really big maps if you
      want (at the expense of bigger map overhead).  The easiest way is to
      substitute AtomicUnorderedInsertMap64.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2574338
      
      fb-gh-sync-id: a74994b6da1046a149c2e7763c3dc19e35d9840b
      d0889c8c
  15. 22 Oct, 2015 3 commits
    • Alan Frindell's avatar
      Fix infinite loop in Cursor::readTerminatedString · 69f3c942
      Alan Frindell authored
      Summary: readTerminatedString could infinite loop if the terminator does not appear in the contained IOBuf chain and maxLength > chain.computeChainLength.  I'm throwing out_of_range here because that more closely mirrors what the other read() functions do.
      
      Reviewed By: siyengar
      
      Differential Revision: D2571039
      
      fb-gh-sync-id: 1db22089562d8767920d66a0a1b091b02de6571f
      69f3c942
    • Giuseppe Ottaviano's avatar
      Clang support for constexpr StringPiece constructor · d1027eb2
      Giuseppe Ottaviano authored
      Summary: Clang's `strlen` is not `constexpr`, but `__builtin_strlen` is, so we can have an unconditional `constexpr` `StringPiece` constructor.
      
      Reviewed By: luciang, yfeldblum
      
      Differential Revision: D2561782
      
      fb-gh-sync-id: 51e76a0d50355cc5ead1148ba2389b640a6888de
      d1027eb2
    • Yaacov Akiba Slama's avatar
      Fix gcc 5.2 compilation when _GLIBCXX_USE_CXX11_ABI is not 0 · 50b33d29
      Yaacov Akiba Slama authored
      Summary: Tested in debian stretch when used in hhvm which can now run drupal 7.
      The compilation error is also fixed by #214 but this fix maintains
       forward declarations of basic_string and list.
      Closes https://github.com/facebook/folly/pull/329
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2533880
      
      fb-gh-sync-id: 85e18eeeba9efa1b4150217ba526b32b5573e15e
      50b33d29
  16. 21 Oct, 2015 2 commits
    • Philip Pronin's avatar
      fix "iocb" reporting in AsyncIO · c1a6582f
      Philip Pronin authored
      Summary: A few fields were swapped, and we had unintentionall fallthrough in
      switch.
      
      Reviewed By: luciang
      
      Differential Revision: D2565884
      
      fb-gh-sync-id: 8ad71c090c5120e99c672f785aaefdef03469ee2
      c1a6582f
    • Rameshkumar Shihora's avatar
      Move FingerprintBenchmark to Folly · 861d07a5
      Rameshkumar Shihora authored
      Summary: FingerprintBenchmark was in an internal directory before, but it belongs alongside the Fingerprint code.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2534646
      
      fb-gh-sync-id: d8ded3a5a9d33f60e9674ea71dc87a2d8d19a51b
      861d07a5