1. 29 Jul, 2016 1 commit
    • Yuri Putivsky's avatar
      takeOwnershipOfPipes method releases memory · ff76c329
      Yuri Putivsky authored
      Summary: takeOwnershipOfPipes should left zero heap memory allocated in folly:Subprocess class instance.
      
      Reviewed By: snarkmaster
      
      Differential Revision: D3638503
      
      fbshipit-source-id: aac7b10bd7399c44868f32c01164f4123892598f
      ff76c329
  2. 27 Jul, 2016 3 commits
    • Adam Simpkins's avatar
      add an unlock() method to Synchronized<T>::LockedPtr · 38237272
      Adam Simpkins authored
      Summary:
      Add an unlock() method to Synchronized LockedPtr objects.  This will make it
      easier to replace current users of the UNSYNCHRONIZED macro.
      
      Of the handful of places currently using UNSYNCHRONIZED, many of them want to
      simply release the lock before logging a message and returning.  However,
      UNSYNCHRONIZED is a poor choice for this, since it will re-acquire the lock on
      scope exit.  In these situations where the function returns from inside an
      UNSYNCHRONIZED block the code unnecessarily re-acquires the lock just to
      immediately release it.  The unlock() method will provide a cleaner mechanism
      for these call sites to simply drop the lock early before returning.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3547652
      
      fbshipit-source-id: 4d28fe9f3aad0d7348e918d1a3d6c705bfec242b
      38237272
    • Christopher Dykes's avatar
      Don't shift an int left while assigning it to a size_t · 5d90c138
      Christopher Dykes authored
      Summary:
      MSVC gives warnings if you shift a 32-bit value left but then assign it to a 64-bit variable. This just makes it a 64-bit shift instead.
      If we really wanted, this doesn't need to be a size_t to begin with, but it already is, so just leave it alone.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3622935
      
      fbshipit-source-id: 25931e6df644df8a2160aa80fd5de21cd9c06159
      5d90c138
    • Wez Furlong's avatar
      folly: fix AtomicUnorderedMap compilation on macOS · 84e863f6
      Wez Furlong authored
      Summary:
      MAP_POPULATE is not defined on this system.  Instead we will `madvise` the kernel
      that we will need it so that it will populate the mapping.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3584325
      
      fbshipit-source-id: ece52f3d55c475bcd41367f4e9744d6f41001cd5
      84e863f6
  3. 26 Jul, 2016 16 commits
    • Christopher Dykes's avatar
      Support PicoSpinLock on MSVC · 369761f0
      Christopher Dykes authored
      Summary:
      It was using inline assembly in order to get atomic single-bit operations, so add a variant for MSVC that uses intrinsics.
      MSVC is also weird in-that it doesn't have a 16-bit variant of these, so use an atomic OR and AND to achieve the required effect.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3623220
      
      fbshipit-source-id: b4ff985ef2ed7787115f4d20de6f244123410dc8
      369761f0
    • Christopher Dykes's avatar
      Consistently reference an internal struct as a struct · d67d48ea
      Christopher Dykes authored
      Summary: That way the mismatch warning can stay as an error.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3613761
      
      fbshipit-source-id: 6e0ee42c658d95786f578f6500aba113c00d8f77
      d67d48ea
    • Christopher Dykes's avatar
      Fix the weak linking of JEMalloc under MSVC · cdcb98c4
      Christopher Dykes authored
      Summary: While the previous version did compile, it wouldn't actually work at link time.
      
      Reviewed By: meyering
      
      Differential Revision: D3614424
      
      fbshipit-source-id: 578677b65edca720330319594e1163d214e1400d
      cdcb98c4
    • Christopher Dykes's avatar
      Don't run the thread local tests requiring dlopen on Windows · 76551ae8
      Christopher Dykes authored
      Summary: When I initially added the surrounding `#ifdef` I failed at where I put my `#endif`, as I left the shared library test enabled. This disables it for Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3622769
      
      fbshipit-source-id: f263201239095bbef076300d5f40649ebee1173c
      76551ae8
    • Christopher Dykes's avatar
      Get MSVC able to construct an Indestructible · a955532d
      Christopher Dykes authored
      Summary: It didn't like using `decltype(args)`, which wasn't really necessary as we already have it's type.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3623424
      
      fbshipit-source-id: 994c23cbf486d427c6dd0fe4c6f768e51ea15ad1
      a955532d
    • Christopher Dykes's avatar
      Only try to use the membarrier on Linux · c6476cb3
      Christopher Dykes authored
      Summary: It doesn't exist anywhere else, and `syscall` isn't even defined on Windows, so this completely failed to compile before.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3623382
      
      fbshipit-source-id: 302093ddc96d6465e0dcc1883747229a7fb25a84
      c6476cb3
    • Christopher Dykes's avatar
      Add folly::assume_unreachable · 6d9473d8
      Christopher Dykes authored
      Summary: So that the `[[noreturn]]` attribute can be applied.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3614122
      
      fbshipit-source-id: 4b95cb553e85c85c277c00b8165671dcc75afac8
      6d9473d8
    • Christopher Dykes's avatar
      Make RangeEnumerator C++17 compliant (Generalizing the Range-Based For Loop) · 9982d892
      Christopher Dykes authored
      Summary:
      Specifically the loosening of the definition of a range where-by the end of an iterator may be represented by a different type than the beginning of the range.
      Oh, and it also fixes compilation on MSVC, which didn't like the decltype being used to determine the iterator type.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3613993
      
      fbshipit-source-id: 2940a15d0f93c5b6310d0b1896f5d12ca9aec639
      9982d892
    • Michael Lee's avatar
      Add a dummy FlagSaver class. · d150b5b7
      Michael Lee authored
      Summary: Add a declaration to mock out FlagSaver on platforms that don't support gflags.
      
      Reviewed By: ivmaykov, yfeldblum
      
      Differential Revision: D3620421
      
      fbshipit-source-id: c1047f34f384f34276b18f53e966a65cdd5c8075
      d150b5b7
    • Andrii Grynenko's avatar
      Support custom loop runner for EventBaseLoopController · 808e54f2
      Andrii Grynenko authored
      Summary: This allows having some logic executed before and after FiberManager loop (e.g. grabbing a Python GIL).
      
      Reviewed By: A5he
      
      Differential Revision: D3616752
      
      fbshipit-source-id: 3be35d54ced458328816d583133457a44a863acd
      808e54f2
    • Yang Chi's avatar
      A BufferCallback was created but never deleted in AsyncSocketTest2 · 22008a54
      Yang Chi authored
      Summary: This crashes unit test with asan, since we never deletes it.
      
      Reviewed By: djwatson
      
      Differential Revision: D3622847
      
      fbshipit-source-id: f7ea7c4f464843353b24a59adefd5d66b95bc169
      22008a54
    • Yang Chi's avatar
      No need to go through the list when you just want the size · bad11d29
      Yang Chi authored
      Summary: cb is an unused variable, and i got error in android. It seems like we don't need to go through the list to increase count.
      
      Differential Revision: D3622772
      
      fbshipit-source-id: fe1f81a1fcad5bacad052e14b7b0b370beb3f3e5
      bad11d29
    • Christopher Dykes's avatar
      Handle MSVC's preprocessor oddities in the SharedMutex test · 66950202
      Christopher Dykes authored
      Summary: MSVC needs a bit more glue to expand the varargs.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3614681
      
      fbshipit-source-id: 901d8c5138b1d2d28434c51bdff31f6d21f26681
      66950202
    • Christopher Dykes's avatar
      Include sys/types.h portability header in Enumerate · 0b57311a
      Christopher Dykes authored
      Summary: Because it's using `ssize_t`, which MSVC defines weirdly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3614050
      
      fbshipit-source-id: 422621ea0dc92b374fa6dfc32a5391c1093d039e
      0b57311a
    • Neel Goyal's avatar
      Refactor socket peeker · 5bb10c1e
      Neel Goyal authored
      Summary:
      Refactor the socket peeker into its
      own class so that it can be used in
      other places as well, for example
      for peeking at plaintext traffic.
      
      Reviewed By: knekritz
      
      Differential Revision: D3521899
      
      fbshipit-source-id: fcd5615dd5d7cd1ddece4c624efbdecfbbc88a09
      5bb10c1e
    • Misha Shneerson's avatar
      Fix gcpu regression associated with 1ms tick in HHWheelTimer · b197869b
      Misha Shneerson authored
      Summary:
      We should go back to 10ms granularity.
      Because regressions -
      https://www.facebook.com/groups/wfi/permalink/1107102889338325/
      
      Reviewed By: haijunz
      
      Differential Revision: D3616784
      
      fbshipit-source-id: dc1d7ff5195ae836df4a334a9ac5c41164c0627b
      b197869b
  4. 24 Jul, 2016 3 commits
    • Giuseppe Ottaviano's avatar
      Fix typo in SharedMutex comment · 0a19e938
      Giuseppe Ottaviano authored
      Reviewed By: yfeldblum
      
      Differential Revision: D3611881
      
      fbshipit-source-id: 3991c18cc2956e9d0b50a20e6daf913ec58ee501
      0a19e938
    • Giuseppe Ottaviano's avatar
      Fix a namespace issue · 39dbe579
      Giuseppe Ottaviano authored
      Reviewed By: dkgi
      
      Differential Revision: D3586189
      
      fbshipit-source-id: ce817233a0293e19400b5689c283531be6302c10
      39dbe579
    • Qinfan Wu's avatar
      Add helper functions for mallctl · e25cc6ea
      Qinfan Wu authored
      Summary: As more code is using mallctl, it's worth making these helper functions available everywhere.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3576190
      
      fbshipit-source-id: 968e80e00f2ed93542e117c24861c21745b63f20
      e25cc6ea
  5. 23 Jul, 2016 1 commit
    • Yedidya Feldblum's avatar
      Move RequestContext definitions to source files · 4fde7096
      Yedidya Feldblum authored
      Summary:
      [Folly] Move `RequestContext` definitions to source files.
      
      Keeping headers lightweight can help with build times.
      
      Reviewed By: djwatson
      
      Differential Revision: D3609809
      
      fbshipit-source-id: 20608e3ff764c86c24355a328da1dcca9a08fce4
      4fde7096
  6. 22 Jul, 2016 11 commits
    • Melanie Subbiah's avatar
      RequestContext changes to facilitate thread tracing · 6645b95d
      Melanie Subbiah authored
      Summary: In order to trigger trace points when a new thread begins/finishes executing, I added functionality to call onSet and onUnset methods on all RequestData objects whenever setContext is called. The main question: will this approach cost us too much overhead?
      
      Reviewed By: djwatson
      
      Differential Revision: D3604948
      
      fbshipit-source-id: 3b704ca0f2b713458427aa49be12f776939057f8
      6645b95d
    • Mark Isaacson's avatar
      Fix ASAN exposed heap-use-after-free · 066a868c
      Mark Isaacson authored
      Summary: This code very obviously wrote past the end of the buffer when the length was 1. Furthermore, it was just downright broken for all values. The author obviously meant to type * instead of +. I took the time to verify that the algorithm is actually correct, while I was working on this. My proof is in the test plan.
      
      Reviewed By: yfeldblum, meyering
      
      Differential Revision: D3603255
      
      fbshipit-source-id: 5f2a0011ff5401a70ba03993eab6e53e29d87c1c
      066a868c
    • Christopher Dykes's avatar
      Rename GetTickCount to GetClockTickCount · 0dacfa47
      Christopher Dykes authored
      Summary: Because Windows already defines a funtion named `GetTickCount` with a different signature.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601877
      
      fbshipit-source-id: fa0fb422156a3dc71e149e02a000ccdf3479eea5
      0dacfa47
    • Christopher Dykes's avatar
      Update FB_ONE_OR_NONE in Preproc.h to work with MSVC · ccb2bd7f
      Christopher Dykes authored
      Summary: There was an MSVC section, but it's much simpler to just use the glue to solve the issue instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601184
      
      fbshipit-source-id: f95bd3dfc4b244e1bce21997f44de2970575ad7f
      ccb2bd7f
    • Christopher Dykes's avatar
      Always use the 64-bit conversion function in ConvBenchmark.cpp · 38b106f1
      Christopher Dykes authored
      Summary: A `long` on MSVC is only 4 bytes, so the `static_assert` will fail. Remove the static assert and use the `long long` version instead. Do the same for the unsigned version.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601064
      
      fbshipit-source-id: 70c5f4bca597ba05c3729f5d15feeea3cc8fde57
      38b106f1
    • Christopher Dykes's avatar
      Include the Builtins portability header in Bits.h · eeb9d4e9
      Christopher Dykes authored
      Summary: Because we need it for MSVC.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601138
      
      fbshipit-source-id: 4d2ba3f9c972717745289686b025d2763f9ef30d
      eeb9d4e9
    • Christopher Dykes's avatar
      Include the sys/types.h portability header · c2cea839
      Christopher Dykes authored
      Summary: As the comment in the file says, this has to be included in a weird order due to issues on Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3601008
      
      fbshipit-source-id: fca4b6d906eb0d1f001c28197987165cd075752d
      c2cea839
    • Christopher Dykes's avatar
      Use decltype to get the type of a non-static local · 7b8c8076
      Christopher Dykes authored
      Summary: As the `sizeof()` is being evaluated in a static context, MSVC doesn't let you reference non-static locals. Solve the issue by getting the type of the local via `decltype` instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600845
      
      fbshipit-source-id: 825d93ced8f09d9f4bf0dcf02142f47a0ec32605
      7b8c8076
    • Christopher Dykes's avatar
      Don't typedef types to the same name in different namespaces · 9b2bbca7
      Christopher Dykes authored
      Summary:
      This was causing MSVC to complain due to `DSched` already being declared in `BatonTestHelpers.h` as `::folly::DSched`, but it's then typedef'd again in `BatonTest.cpp`, this time as `::DSched`. MSVC complains about the duplicate definitions even though they resolve to the same type, so kill the one in the source file and keep the one in the header.
      The same is the case with `GroupVarint32Decoder` and `GroupVarint64Decoder`, which are both declared in `GroupVarint.h` and then again, this time in an anon namespace, in `GroupVarintTest.cpp`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600948
      
      fbshipit-source-id: 401790aa918289fe4a34dd5af683f8c6ca50d847
      9b2bbca7
    • Wez Furlong's avatar
      folly: fixup folly::Random FixedSeed test expectations on macOS · 138f44b3
      Wez Furlong authored
      Summary:
      uniform_int_distribution is implemented differently on this system and
      always returns the generated number from our constant random number generator.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3585418
      
      fbshipit-source-id: 754076599ba77b49c17f03bb0c92264a3bed4ab0
      138f44b3
    • Christopher Dykes's avatar
      Don't use ?: · c2691bc6
      Christopher Dykes authored
      Summary:
      Because it doesn't exist in the C++ standard.
      
      This switches them to the explicitly expanded form, which is in the spec.
      It also removes a few that were doing absolutely nothing. (MSVC still complained about the division by zero)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479260
      
      fbshipit-source-id: 5386e27057beeb4b228f5d6be4e1cf9941cf3176
      c2691bc6
  7. 21 Jul, 2016 3 commits
    • Christopher Dykes's avatar
      Support StlVectorTest for MSVC · bfe4b109
      Christopher Dykes authored
      Summary:
      Sure, it's big, but it compiles.
      
      There are a few different changes to make this happen, the first is to deal with quite a few places where MSVC was complaining about the implicit coersion of template and noexcept parameters to bool.
      Next, the gating that disabled this for 4.7 is now gone.
      MSVC's runtime expected `difference_type` to be defined on our custom allocator, so it now is.
      `ReadTSC()` was changed to use MSVC's intrinsic for this.
      And finally, the named variadic parameters to macros were switched to normal variadic macro params, as MSVC doesn't support named ones.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479761
      
      fbshipit-source-id: 703a5ef942ffc9b63381d13fc3960ac6f2780aa0
      bfe4b109
    • Christopher Dykes's avatar
      Mark a couple of local constants as static constexpr · cbef1e2d
      Christopher Dykes authored
      Summary: Because they aren't captured, and thus aren't accessible, in the callback used further on in the function.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600874
      
      fbshipit-source-id: 699b3d4caa0a310b1ccc7810d670671850f4366b
      cbef1e2d
    • Christopher Dykes's avatar
      Disable a test of ThreadLocal across forks for Windows · e21b7273
      Christopher Dykes authored
      Summary: We don't have `fork()` to begin with, so disable the test and the includes it required if we're compiling on Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3600600
      
      fbshipit-source-id: 5399705753b456139105f4ac757190e1ba1765f2
      e21b7273
  8. 20 Jul, 2016 2 commits
    • Yedidya Feldblum's avatar
      allocate_sys_buffer · e28213bf
      Yedidya Feldblum authored
      Summary:
      [Folly] `allocate_sys_buffer`.
      
      For when a `malloc`'d buffer is required, with an associated deleter that calls `free`.
      
      Reviewed By: JonCoens
      
      Differential Revision: D3590516
      
      fbshipit-source-id: 644f4b5d5e8f19dbc8f29efe3e93517fba0ad72f
      e28213bf
    • Mingtian Yin's avatar
      Record whether cached certificate was used · df8ec793
      Mingtian Yin authored
      Summary: Record whether cached certificate was used
      
      Reviewed By: anirudhvr
      
      Differential Revision: D3582807
      
      fbshipit-source-id: 246107ce383ff31718ee7dcccf8bbea459b559a8
      df8ec793