1. 08 Jan, 2016 1 commit
    • Giuseppe Ottaviano's avatar
      Fix two fbstring operator+ overloads · 81295897
      Giuseppe Ottaviano authored
      Summary: `insert()` returns `fbstring` in most cases, but `iterator` (that is, `value_type*`) when the first argument is an iterator. Two overloads of `operator+` used `insert` as if it returned `fbstring`, which by chance works anyway unless the resulting string contains a `'\0'` (plus it does an extra string copy). This diff fixes the bug.
      
      Reviewed By: philippv, luciang, Gownta
      
      Differential Revision: D2813713
      
      fb-gh-sync-id: 015188b72813da2dabe23980f50f00832d62aa14
      81295897
  2. 06 Jan, 2016 1 commit
    • David Callahan's avatar
      parse args for -json flag · 5d7bf822
      David Callahan authored
      Reviewed By: yfeldblum
      
      Differential Revision: D2803911
      
      fb-gh-sync-id: 65023cae7fd8e06c30fed100826b4b834ee2e9b1
      5d7bf822
  3. 05 Jan, 2016 4 commits
    • Gustavo Serra Scalet's avatar
      Enable GroupVarint on PPC64 · 061b5de8
      Gustavo Serra Scalet authored
      Summary:
      This PR is necessary for both Folly and HHVM to compile on PPC64 (https://github.com/PPC64/hhvm) and other platforms that are not compatible with SSE instructions.
      
      It also removes GroupVarint32 tables generator dependency on x86 platform.
      Closes https://github.com/facebook/folly/pull/339
      
      Reviewed By: mxw
      
      Differential Revision: D2760156
      
      fb-gh-sync-id: b4e93b54b62d6f68ccf684d34840678f677bf276
      061b5de8
    • David Callahan's avatar
      parse args for -json flag · a0430d4a
      David Callahan authored
      Reviewed By: lbrandy
      
      Differential Revision: D2803778
      
      fb-gh-sync-id: 0cb21413bb1c78d256b4408322f8d585f53cb0ac
      a0430d4a
    • Neel Goyal's avatar
      Add canAdvance to cursor and tests · 1c77ef4f
      Neel Goyal authored
      Summary:
      Determine if the cursor can advance N bytes. This is useful if
      applications want to check before reading so an exception isn't thrown.
      It tries to walk the minimal amount of links needed in the chain.
      
      I had a task that could have used this, though caching totalLength and
      macro magic ended up being the implementation chosen. I think this just
      adds to the cursor API.
      
      Reviewed By: djwatson
      
      Differential Revision: D2728498
      
      fb-gh-sync-id: 8657653b82a48828cccab143653dc169ef715702
      1c77ef4f
    • Michael Lee's avatar
      Switch back to SYS_gettid, and fix · 3f93d783
      Michael Lee authored
      Summary:
      SYS_gettid is different on Linux vs. OSX.  `__NR_gettid` is
      only sometimes present and `SYS_gettid` is only sometimes present, but
      we can pick one name and just follow that one.
      
      Reviewed By: dcolascione
      
      Differential Revision: D2800515
      
      fb-gh-sync-id: 4245de4b9184ac4233ade9da297409c1031869a3
      3f93d783
  4. 04 Jan, 2016 1 commit
    • Michael Lee's avatar
      Clean up folly tests. · 43db7ae3
      Michael Lee authored
      Summary: Clean up and remove unecessary gflags use.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2795904
      
      fb-gh-sync-id: 99cccb4dc32a051b3d552b72cbc9243e20ba8127
      43db7ae3
  5. 30 Dec, 2015 1 commit
    • Giuseppe Ottaviano's avatar
      Close AsyncServerSocket sockets in reverse order · 99a7f383
      Giuseppe Ottaviano authored
      Summary:
      When a large number of processes concurrently bind and close `AsyncServerSocket`s with `port=0` (for example in tests) binding the IPv4 socket on the same port bound with the IPv6 socket can currently fail, because sockets are closed in the same order as they are opened, which makes the following scenario possible:
      
      ```
      P0: close IPv6 port
      P1: open IPv6 port (succeed)
      P1: open IPv4 port (FAIL)
      P0: close IPv4 port
      ```
      
      This diff reverses the closing order, and also fixes a couple of outdated comments.
      
      Reviewed By: philippv
      
      Differential Revision: D2795920
      
      fb-gh-sync-id: 0b5157a56dfed84aed4a590c103050a2727847b3
      99a7f383
  6. 28 Dec, 2015 1 commit
  7. 24 Dec, 2015 2 commits
    • Dominik Gabi's avatar
      wrapper for nullable attribute · 396329db
      Dominik Gabi authored
      Reviewed By: yfeldblum
      
      Differential Revision: D2784472
      
      fb-gh-sync-id: 84c7426cc82edabb04c662fa699764ffc0864b7e
      396329db
    • Dominik Gabi's avatar
      clang attribute wrappers · 6896ff9d
      Dominik Gabi authored
      Summary: adding GCC compatible wrappers for clang attributes to folly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2706913
      
      fb-gh-sync-id: 17db34089d48a6a01c20904321a47ff98141c2fe
      6896ff9d
  8. 23 Dec, 2015 4 commits
    • Michael Lee's avatar
      Change `SYS_gettid` to __NR_gettid instead · 2a0cb937
      Michael Lee authored
      Summary: SYS_gettid is not available on all platforms, but __NR_gettid should be.
      
      Reviewed By: dcolascione
      
      Differential Revision: D2787003
      
      fb-gh-sync-id: ee024437ac95281a3573e2440653847f6f7d1738
      2a0cb937
    • Giuseppe Ottaviano's avatar
      Fix test Dynamic.ArrayReassignment with Clang 3.7 · 015ca678
      Giuseppe Ottaviano authored
      Summary:
      `dynamic` is one of the few unfortunate recursive types that have a constructor of the form `T(initializer_list<T>)`. After the Defect Report 95 (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467) a statement `T t = {v};` where `v` is of type `T` invokes the copy constructor instead of the initializer list constructor. Clang 3.7 implements the new behavior, and GCC probably will soon.
      This diff only fixes a test where the ambiguous syntax is used, but a better solution would be preferable.
      
      Reviewed By: philippv
      
      Differential Revision: D2786455
      
      fb-gh-sync-id: 7fa5235e4041cbc8dd3ce685b5a0c23c343f78d2
      015ca678
    • Mike Kolupaev's avatar
      Added missing instantiation for HistogramBuckets::computeTotalCount() · 3740c290
      Mike Kolupaev authored
      Summary:
      D2078239 added a template method to HistogramBuckets but didn't add an instantiation for it, similar to getPercentileBucketIdx() and getPercentileEstimate() (see comment in Instantiations.cpp). This diff adds it, making `computeTotalCount()` usable without including `Histogram-defs.h`.
      
      Also removes the weird `const` in return type.
      
      Reviewed By: simpkins
      
      Differential Revision: D2783534
      
      fb-gh-sync-id: 9226489820116e0cbcb1f6a631b389439558061e
      3740c290
    • Michael Lee's avatar
      Remove extra FLAGS_seed definition · 6e8dcd61
      Michael Lee authored
      Summary: This is not used within the file.  Cleaning up.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2784500
      
      fb-gh-sync-id: 60270cb20c40b79f988c5536fa00e0a0f1d08e46
      6e8dcd61
  9. 21 Dec, 2015 1 commit
    • Michael Lee's avatar
      Move ThreadLocal.h into the implementation · 49e4875c
      Michael Lee authored
      Summary: Move ThreadLocal.h out of Random.h so we don't over include.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2770085
      
      fb-gh-sync-id: e6934d606236c2b5cdde728639f372641ee716dc
      49e4875c
  10. 18 Dec, 2015 1 commit
  11. 17 Dec, 2015 3 commits
    • Andrii Grynenko's avatar
      Fix EventBaseLoopController destruction races · 60345760
      Andrii Grynenko authored
      Summary:
      Existing scheduleThreadSafe implementation had 2 potential races on destruction:
      1. (very unlikely) insertHead is complete, but fiber loop is already running on another thread, so it finishes processing all of the fibers, destroys FiberManager or EventBase or both. By the time we get to scheduleThreadSafe EventBaseLoopController is already destoyed
      2. (more likely) scheduleThreadSafe is complete, but FiberManager loop which is already running, picks complete fiber, finishes the processing. After that FiberManager may be destoyed. So when EventBase actually executes the callback FiberManager is already dead.
      
      This solution fixes both races. Holding the alive shared_ptr when completing sheduleThreadSafe assures EventBase can't be destoyed until its completed (or it won't try to schedule anything after EventBase was destroyed). Locking alive weak_ptr in the EventBase loop callback ensures FiberManager and thus EventBaseLoopController were not destroyed yet (they can be destoyed only by the same thread which is running EventBase loop).
      
      Reviewed By: spalamarchuk
      
      Differential Revision: D2763206
      
      fb-gh-sync-id: 1972d6c0c11aa931747ebdaed4029a209130f69c
      60345760
    • Michael Lee's avatar
      Allow override for unaligned reads in SpookyHashV2 · 66dd2aa1
      Michael Lee authored
      Summary: Add configuration for disabling unaligned reads in SpookyHashV2
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2750885
      
      fb-gh-sync-id: 9f48dcdfd5af05478a38e354f6fa0332b1332c14
      66dd2aa1
    • Bin Liu's avatar
      Put optimized memcpy into folly · 1ec38b40
      Bin Liu authored
      Summary: There is an optimized assembler version of memcpy that is showing 1.5% gain on TAO, add it to folly
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2218473
      
      fb-gh-sync-id: d5ac7f5ab30ff6febe7e94b017766c68dbd8934d
      1ec38b40
  12. 15 Dec, 2015 4 commits
    • Lovro Puzar's avatar
      Support gzip in folly/io:compression · f05cdbc1
      Lovro Puzar authored
      Summary: gzip files can be easier to work with operationally than raw zlib thanks to gzip+gunzip.  zlib supports adding/stripping the gzip header; expose that through a new CodecType.
      
      Reviewed By: chipturner
      
      Differential Revision: D2759554
      
      fb-gh-sync-id: 67e0f5f88e087d363db1c349cabb909fb3f00417
      f05cdbc1
    • Neel Goyal's avatar
      Update SSLContext to use folly::Random and discrete_distribution · fbb8a926
      Neel Goyal authored
      Summary:
      Change next pick logic to use `std::discrete_distribution`.  Use folly::Random::DefaultGenerator as the generator.
      Update the TARGETS to have sslcontext depend on random (which was the build break in D2741855)
      
      Reviewed By: siyengar
      
      Differential Revision: D2749166
      
      fb-gh-sync-id: 7a6b400173b1e8c69a961f9e75e97d4777d5467a
      fbb8a926
    • Yang Chi's avatar
      Add a per-socket buffer callback · 4a46ffa2
      Yang Chi authored
      Summary: this is way simpler than D2623385 + D2709121. There will be a followup diff to clean the existing per-write call BufferCallback. The new one is on per-socket basis, much straightforward. I will only setup this in HTTPUpstreamSession.
      
      Reviewed By: afrind
      
      Differential Revision: D2723493
      
      fb-gh-sync-id: 6b1c21a719281b9693330b6a4074f7149d7c342a
      4a46ffa2
    • Yang Chi's avatar
      Remove per-write buffer callback from AsyncSocket · 76fcf389
      Yang Chi authored
      Summary: Remove per-write buffer callback from AsyncSocket
      
      Reviewed By: afrind
      
      Differential Revision: D2733142
      
      fb-gh-sync-id: 91214a8c833bbd479bf049c2bb72d660e0c30f50
      76fcf389
  13. 11 Dec, 2015 3 commits
    • Louis Brandy's avatar
      folly::dynamic::operator= for std::initializer_list · 34de70e2
      Louis Brandy authored
      Summary:
      If we're going to have a constructor for it, we should have operator=.
      
      Otherwise, gcc-4.9 goes via the copy constructor effectively "ignoring" the attempted nesting for e.g..
      
      ```
      d = { other_dynamic };  // Should be ARRAY containing dynamic
      ```
      
      NOTE: this only fixes gcc-4.9, there's still issues in clang.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2745180
      
      fb-gh-sync-id: 667787c788fc7c131d8a34c608c355f5b875be50
      34de70e2
    • Andrii Grynenko's avatar
      Fix RefCountTest and RCURefCount race · bf8a9074
      Andrii Grynenko authored
      Reviewed By: alikhtarov
      
      Differential Revision: D2741459
      
      fb-gh-sync-id: c4bd068cf735ae25364edba40960096fb35e8c43
      bf8a9074
    • Philip Pronin's avatar
      setup signal handler with SA_ONSTACK · dee3186e
      Philip Pronin authored
      Summary:
      By default signal handlers are run on the signaled thread's stack.
      In case of stack overflow running the `SIGSEGV` signal handler on
      the same stack leads to another `SIGSEGV` and crashes the program
      Use `SA_ONSTACK`, so alternate stack is used (only if configured via
      `sigaltstack`).
      
      Reviewed By: luciang
      
      Differential Revision: D2747021
      
      fb-gh-sync-id: 48388acd6147e2919412ec32acfca1ca76f22a16
      dee3186e
  14. 10 Dec, 2015 6 commits
    • Yedidya Feldblum's avatar
      Use SharedMutex as the default mutex type in Synchronized · d8ebd43d
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `SharedMutex` as the default mutex type in `Synchronized`.
      
      `folly::SharedMutex` is, overall, a faster mutex than `boost::shared_mutex`. Let's upgrade.
      
      Reviewed By: nbronson
      
      Differential Revision: D2743132
      
      fb-gh-sync-id: e36881495e8e1002cd481607e05e555c5da19b9a
      d8ebd43d
    • Neel Goyal's avatar
      D2741855 broke my wangle. Reverting · 17d04308
      Neel Goyal authored
      Summary: Revert D2741855
      
      Reviewed By: mzlee
      
      Differential Revision: D2744015
      
      fb-gh-sync-id: b1e9b0a5ab95cb988d2b5c08c86139452b092465
      17d04308
    • Barney Moss's avatar
      Unit test showing array assignment problem on gcc 4.9 · 97c7b417
      Barney Moss authored
      Summary: Unit test showing array assignment problem on gcc 4.9
      
      Reviewed By: lbrandy
      
      Differential Revision: D2739900
      
      fb-gh-sync-id: 6b0fde956672b8248fbd4e620fd112195c45c646
      97c7b417
    • Andrii Grynenko's avatar
      Add ReadMostlySharedPtr and TLRefCount to Makefile.am · 91499a64
      Andrii Grynenko authored
      Reviewed By: pavlo-fb
      
      Differential Revision: D2743230
      
      fb-gh-sync-id: 4a52d1758a43fd103318bbe0913776340eaa6af7
      91499a64
    • Arjen Roodselaar's avatar
      Fix automake build · acd1f142
      Arjen Roodselaar authored
      Summary: There is slight drift in external deps between the TARGETS and automake files, keeping tests from linking in the 'make check' step when building folly outside of fbcode.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2740482
      
      fb-gh-sync-id: ae6243f9bb112a7d2680017b3d577a1f23ef4f60
      acd1f142
    • Neel Goyal's avatar
      Update SSLContext to use discrete_distribution · 92c9ccb6
      Neel Goyal authored
      Summary: Update the protocol pick logic to use discrete_distribution
      
      Reviewed By: siyengar
      
      Differential Revision: D2741855
      
      fb-gh-sync-id: 244bd087124a7a9584a1108fe8f8150093275878
      92c9ccb6
  15. 09 Dec, 2015 3 commits
    • Andrii Grynenko's avatar
      Switch folly::Singleton to ReadMostlySharedPtr · 71c140ed
      Andrii Grynenko authored
      Summary:
      This also introduces a new try_get_fast() API which returns ReadMostlySharedPtr.
      We should eventually migrate all users onto this API.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D2706745
      
      fb-gh-sync-id: d558d705f431fc6147334c188fd0c6156644ba5c
      71c140ed
    • Alan Frindell's avatar
      Add support for ALPN · 7e6064c6
      Alan Frindell authored
      Summary: With openssl-1.0.2 and later add support for ALPN.  Clients can request NPN only, but the default is to support either (client will send ALPN list, server will send NPN advertisement if ALPN is not negotiated).
      
      Reviewed By: siyengar
      
      Differential Revision: D2710441
      
      fb-gh-sync-id: a8efe69e1869bbecb4ed9e0a513448fcfdb21ca6
      7e6064c6
    • Shijin Kong's avatar
      notification queue read -> readNoInt · 7137cffd
      Shijin Kong authored
      Summary: EINTR should be retried
      
      Reviewed By: afrind
      
      Differential Revision: D2735879
      
      fb-gh-sync-id: 6f25cd26e29ab8e7e13a3d63f24bf2d104c14809
      7137cffd
  16. 08 Dec, 2015 4 commits
    • Chad Parry's avatar
      Avoid cost of cancelAll · 750d49c8
      Chad Parry authored
      Summary:
      This is an experimental diff that may improve the performance of `HHWheelTimer::cancelAll`. If there are no timers to cancel, then it can bail early.
      
      Since perflab is unlikely to be conclusive, and since this diff looks like a strict improvement, I'll proceed with landing it.
      
      Reviewed By: djwatson
      
      Differential Revision: D2735297
      
      fb-gh-sync-id: 9f5a811ee6d9fa9434576e9abd3ef3443a7579b7
      750d49c8
    • Andrii Grynenko's avatar
      Fix TLRefCount race around thread local destruction and fix RefCount unit test · 5ff51e97
      Andrii Grynenko authored
      Reviewed By: pavlo-fb
      
      Differential Revision: D2708425
      
      fb-gh-sync-id: 665d077210503df4f4e8aa8f88ce5b9b277582f3
      5ff51e97
    • Chip Turner's avatar
      Update zstd to 0.4.2 · 623cc983
      Chip Turner authored
      Summary: New version.
      
      Reviewed By: cyan
      
      Differential Revision: D2730844
      
      fb-gh-sync-id: 4305bdfba2e8d25eba295bbf3f13a140c0d04a1c
      623cc983
    • Neel Goyal's avatar
      Mark some methods virtual on SSL Context. · 7fc28369
      Neel Goyal authored
      Summary:
      Mark some methods as virtual.  This makes writing some
      better unit tests on the associated task possible.
      
      Reviewed By: siyengar
      
      Differential Revision: D2730126
      
      fb-gh-sync-id: f79f7632e873cb218bb49883d9b53beea7bb96e7
      7fc28369