1. 07 Dec, 2016 2 commits
    • Nathan Bronson's avatar
      increase writeLen for tests that want to trigger buffering · a4e480b2
      Nathan Bronson authored
      Summary:
      Freshly opened TCP sockets can have a send buffer size bigger
      than wmem_default, because connection parameters are cached in the
      route cache.  Some of the async socket tests assumed that writing 8M of
      data was enough to guarantee blocking behavior, but since wmem_max is
      20M on our systems the resulting tests are flaky.
      
      Reviewed By: marcinpe
      
      Differential Revision: D4292201
      
      fbshipit-source-id: ba5d606d080330e455eee2b17bcae6cf546bf981
      a4e480b2
    • Dan Schatzberg's avatar
      Add EvictingCacheMap MoveConstructor · 9b816e89
      Dan Schatzberg authored
      Summary:
      Add the default move constructor and move operator
      to EvictingCacheMap so it can be moved.
      
      Reviewed By: markisaa, luciang
      
      Differential Revision: D4287472
      
      fbshipit-source-id: 130e9d5467d6da14ba95a9e769cf8e8d541a704c
      9b816e89
  2. 06 Dec, 2016 5 commits
    • Andrii Grynenko's avatar
      Increase fiber stack size if UBSAN is enabled · 99994d0a
      Andrii Grynenko authored
      Summary: UBSAN instrumentation results in more stack being used. Applying the same logic we already have for ASAN there.
      
      Reviewed By: igorsugak
      
      Differential Revision: D4287455
      
      fbshipit-source-id: 1a224cb5a3654c23b15fa298bf80476234a1418c
      99994d0a
    • Michael Lee's avatar
      Remove unecessary iostream include · bc779ac3
      Michael Lee authored
      Summary: MacAddress only needs to include ostream and the test header does not need iostream.
      
      Differential Revision: D4286405
      
      fbshipit-source-id: e64fdd4e8428c62279ed7c185188f3dfc14096d3
      bc779ac3
    • Michael Lee's avatar
      More iostream removal. · abf585dc
      Michael Lee authored
      Summary:
      We do not need it and it adds a static initialization
      
      This is the last extra one in liger. The other places actually need iostream to print things
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4286095
      
      fbshipit-source-id: 44a827e48e9fb9106626e784592eb194dff83bf6
      abf585dc
    • Christopher Dykes's avatar
      Make bm_min_iters a 32-bit flag · 75d32465
      Christopher Dykes authored
      Summary:
      The benchmark API only supports `unsigned int` as the iteration number, so this being 64-bit means it has to be truncated for no reason.
      This change gets us closer to being able to enable MSVC's implicit truncation warnings.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4281264
      
      fbshipit-source-id: 27397e3f23bace20f3cc457665ea6f21bf994da5
      75d32465
    • Misha Shneerson's avatar
      fix gbd debugging script · cad41641
      Misha Shneerson authored
      Summary:
      I was getting an error when running commands in
      https://our.intern.facebook.com/intern/dex/fibers/gdb/
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D4283229
      
      fbshipit-source-id: fe45847d0ec6cadfbce6fe9818066cce3e275a46
      cad41641
  3. 05 Dec, 2016 2 commits
  4. 04 Dec, 2016 1 commit
    • Amir Shalem's avatar
      Fix potential double close() on exception · fae84c77
      Amir Shalem authored
      Summary:
      Fix potential double close() on exception when SO_REUSEPORT fails.
      The fd will be closed twice, once by close() and second by the scope guard above.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4272300
      
      fbshipit-source-id: a163be822d7522cadb9dc3c3eddca10df453de14
      fae84c77
  5. 03 Dec, 2016 1 commit
    • Christopher Dykes's avatar
      Get ConcurrentSkipList functional · 42c52025
      Christopher Dykes authored
      Summary:
      MSVC was getting thoroughly confused while trying to eval the constexpr function, so switch it to a template instead.
      MSVC was also failing to wrap it's head around what a NodeRecycler is, so delay its resolution via typename.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3478755
      
      fbshipit-source-id: f687f4538fb12ef8eee525557f4cc988a09e714d
      42c52025
  6. 02 Dec, 2016 2 commits
    • Christopher Dykes's avatar
      Begin making folly compile cleanly with a few of MSVC's sign mismatch warnings enabled · 047e9e39
      Christopher Dykes authored
      Summary:
      This makes the changes required to allow folly to compile cleanly with the sign/unsigned mismatch warnings 4388 and 4389, as well as with warnings 4804 and 4805, which are about comparisons between scalars and bool.
      Most of the changes in this are to `DCHECK_*` calls which are translated to a templated call which does the comparison internally based on the inferred type of the argument, which for a literal `0` is `int`, causing the warnings to get generated when the comparison is done.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4253427
      
      fbshipit-source-id: cd17973a78e948a62c886a2959f9abf40a69f9f5
      047e9e39
    • Scott Michelson's avatar
      support getting timer from eventbase · 853adb4f
      Scott Michelson authored
      Summary: This brings the EventBase functionality of getting a timer for the eventbase into the virtual interface
      
      Differential Revision: D4264135
      
      fbshipit-source-id: e5526610eca808e1d7b549a7cd6cd7b2c65d3ce1
      853adb4f
  7. 01 Dec, 2016 5 commits
    • Adam Simpkins's avatar
      add a new writeFileAtomic() function · 3e107c2e
      Adam Simpkins authored
      Summary:
      Add a utility function to more safely set a file's contents by writing to a
      temporary file first, then renaming the temporary file into place.  On Linux
      systems where renames are atomic, this ensures that the operation either
      succeeds or that the old file state is left unchanged on failure.
      
      Note that unlike most of the other APIs in FileUtil.h, I intentionally made
      writeFileAtomic() throw an exception on failure.  This is implemented using a
      lower-level writeFileAtomicNoThrow() version.  Callers who care about the
      exception overhead can use the lower level version instead.  (Exception
      overhead should be relatively low compared to the file I/O operations, though,
      so I suspect most users will prefer the throwing APIs.)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4253964
      
      fbshipit-source-id: 5301e2791b82c6f90b63bb509b0411841c266705
      3e107c2e
    • Yedidya Feldblum's avatar
      Future<typename>::getTryVia · c1bd7145
      Yedidya Feldblum authored
      Summary:
      [Folly] `Future<typename>::getTryVia`.
      
      We have `waitVia` and `getVia` and `getTry`, but `getTryVia` was missing.
      
      Reviewed By: fugalh
      
      Differential Revision: D4254972
      
      fbshipit-source-id: 403e1a3496ad5dfc93c4c55ab75a83bcc89e6c64
      c1bd7145
    • Subodh Iyengar's avatar
      Fix assertion in unit test · 7c8f000f
      Subodh Iyengar authored
      Summary:
      Fix test for AsyncSSLSocket. When a timeout
      occurs during a handshake it's possible that
      invokeConnectError is called with sslState_ ==
      CONNECTING. This just removes the assertion in
      this case. This doesnt affect prod code, only
      tests
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4252677
      
      fbshipit-source-id: 4db3a94ae28aa140546554c087bedcee7f06d201
      7c8f000f
    • Andrii Grynenko's avatar
      Use singleton EventBasePool in ServiceRouter · 930da054
      Andrii Grynenko authored
      Summary:
      Switching ServiceRouter code to use VirtualEventBase instead of EventBase allows us to have same thread-pool shared between multiple ServiceRouter instances.
      
      In future this allows us to replace EventBasePoolImpl with some generic thread-pool implementation (e.g. IOThreadPoolExecutor). It also makes it trivial to have ServiceRouter run on a any existing thread-pool if necessary.
      
      Reviewed By: smichelson
      
      Differential Revision: D3935283
      
      fbshipit-source-id: 3275bbace15a0df8b06d12c970ccc098a631658d
      930da054
    • Andrii Grynenko's avatar
      Use SingletonThreadLocal in folly::Random · 895c8a62
      Andrii Grynenko authored
      Summary: folly::SingletonThreadLocal should be used for all thread-local singletons to avoid SDOF.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4253009
      
      fbshipit-source-id: 5b4ca57a7a77b7b54c94630a2a29d13b84a3af27
      895c8a62
  8. 30 Nov, 2016 3 commits
    • Christopher Dykes's avatar
      Start fixing implicit truncations · 4dd1dd68
      Christopher Dykes authored
      Summary:
      Truncations should be explicit, but for some reason, MSVC seems to be the only compiler that will warn you when you implicitly truncate integer or float values.
      This allows Folly to be compiled with warnings 4018, 4242, 4244 and 4305 enabled.
      Technically 4018 is a sign mismatch warning, but there was only one place it was being triggered so I included it anyways. The other 3 are warnings for implicit truncation.
      
      There is one other implicit truncation warning that currently triggers in Folly, 4267, but there are a lot more places where that triggers so I'll do that in a separate diff.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4249471
      
      fbshipit-source-id: e18a93d85856c998576934a6229c9edd1638a54e
      4dd1dd68
    • Teng Qin's avatar
      Add optional Tracepoint for RequestContext switch · ea209427
      Teng Qin authored
      Summary: Using newly added `StaticTracepoint.h`, add a Tracepoint for `RequestContext` switch that could be enabled by compiler flag.
      
      Reviewed By: drarmstr
      
      Differential Revision: D4238658
      
      fbshipit-source-id: 043a035ba8251b48d7b29d63a2219ad2edda164f
      ea209427
    • Eric Niebler's avatar
      Add constexpr to the simple folly::Range accessors (begin, end, data, empty, etc) · f972b1ee
      Eric Niebler authored
      Summary: More constexpr is better!
      
      Reviewed By: yfeldblum, luciang, ot
      
      Differential Revision: D4244996
      
      fbshipit-source-id: 30a9b726c115a92bb18538d7f18e50eccb0a1ef6
      f972b1ee
  9. 29 Nov, 2016 5 commits
    • Tiho Tarnavski's avatar
      Fix incorrect bytesWritten computation in AsyncSocket · 59a501cf
      Tiho Tarnavski authored
      Summary: If a write request is buffered after a partial write, then bytes written is not updated after subsequent write operations (`performWrite`) for the buffered write request (`BytesWriteRequest`). This results in a wrong value for totalBytesWritten_, which is reported in the error callback in case the write request fails.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4205743
      
      fbshipit-source-id: f77ca55ccfdceda1008c45e72ec093b00bf250e4
      59a501cf
    • Andrii Grynenko's avatar
      Disallow folly::Singletons before main() · ee43735c
      Andrii Grynenko authored
      Summary:
      Make folly::Singleton fail if singleton is requested before registrationComplete. By doing this we disallow any folly::Singleton to be created before main().
      
      Strict mode is still disabled for Python and Hs.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4121322
      
      fbshipit-source-id: b66c23e24f6a7324cd12ddb77cad960e0950a1aa
      ee43735c
    • Guo Xiao's avatar
      Escape backticks in shell script · 9c5b3564
      Guo Xiao authored
      Summary: Closes https://github.com/facebook/folly/pull/520
      
      Reviewed By: pixelb
      
      Differential Revision: D4243347
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: cae0b36abdc7807afc188220f7f421f2a3bbc973
      9c5b3564
    • Nick Terrell's avatar
      Support old LZ4 versions · b82fb4f7
      Nick Terrell authored
      Summary: D4194834 broke the OSS build.  Ubuntu 14.4 has r114 in its repo, so support it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4224129
      
      fbshipit-source-id: c85e95716ee1a08b33455bfe6fc9f7712d226edf
      b82fb4f7
    • Christopher Dykes's avatar
      Use std::terminate rather than throwing in a noexcept function · 82e1b579
      Christopher Dykes authored
      Summary: Because MSVC isn't happy about it and generates a warning with a lot of context.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4242688
      
      fbshipit-source-id: b1e26c9e3b58e7bac0e00ab8959358010fa610e8
      82e1b579
  10. 28 Nov, 2016 2 commits
    • r8k's avatar
      fix bootstrap on osx · 5d8ea982
      r8k authored
      Summary:
      * include all dependencies
       * update `autoconf` & `configure` with correct params
       * include `make` & `make install` in the bootstrap for a better user experience
       * fixes #332
      Closes https://github.com/facebook/folly/pull/513
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4177362
      
      Pulled By: Orvid
      
      fbshipit-source-id: c62d6633c382fca57bb06db08724a7355b71bdb3
      5d8ea982
    • Yedidya Feldblum's avatar
      Canonicalize some aspects of the folly/experimental/hazptr test · 7d70d8d6
      Yedidya Feldblum authored
      Summary:
      [Folly] Canonicalize some aspects of the `folly/experimental/hazptr` test.
      
      * Remove the custom `main()` and use the provided weak symbol, either from `folly/test/common/TestMain.cpp` or from `gtest` depending on the build.
      * Extract some common setup/teardown (just debug logging in this case) to a test fixture.
      
      Reviewed By: Orvid
      
      Differential Revision: D4234154
      
      fbshipit-source-id: 25613cba0ad6c9147714d98150e013fba1a64d46
      7d70d8d6
  11. 27 Nov, 2016 1 commit
    • Phil Willoughby's avatar
      Fix termination output on GCC · c520b4fa
      Phil Willoughby authored
      Summary:
      Thanks nbronson for suggesting this fix. I don't see why this should make any
      difference (and nor does clang) but the important thing is that it works now.
      
      Reviewed By: nbronson
      
      Differential Revision: D4212670
      
      fbshipit-source-id: 08b4313d736f237039a807fbc458d4d581a2ef35
      c520b4fa
  12. 25 Nov, 2016 3 commits
    • Christopher Dykes's avatar
      Allow the use of an emulated futex for EventCount · 46e46627
      Christopher Dykes authored
      Summary:
      Otherwise it won't work under MSVC where we don't have Futexes.
      This is achieved by using the Futex API already used elsewhere in Folly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4233517
      
      fbshipit-source-id: d6ae6a34b2287cf485f8e4a316445a2ba746d1a7
      46e46627
    • Christopher Dykes's avatar
      Revert D4214296: [Folly] Include init/Init.cpp · 6d58adc5
      Christopher Dykes authored
      Summary: This reverts commit 636ed5ae8ad36a323054efaad96d3756f1b7b9d0
      
      Differential Revision: D4214296
      
      fbshipit-source-id: 41fe55a8fcbf41cce44fee7ba65eda5aadbf97b3
      6d58adc5
    • Subodh Iyengar's avatar
      Fix TFO refused case · 16dc0043
      Subodh Iyengar authored
      Summary:
      When TFO falls back, it's possible that
      the fallback can also error out.
      
      We handle this correctly in AsyncSocket,
      however because AsyncSSLSocket is so
      inter-twined with AsyncSocket, we missed
      the case of error as well.
      
      This changes it so that a connect error on
      fallback will cause a handshake error
      
      Differential Revision: D4226477
      
      fbshipit-source-id: c6e845e4a907bfef1e6ad1b4118db47184d047e0
      16dc0043
  13. 24 Nov, 2016 1 commit
    • Yedidya Feldblum's avatar
      Suppress deprecation warnings in related tests · 26c4e8d2
      Yedidya Feldblum authored
      Summary:
      [Folly] Suppress deprecation warnings in related tests.
      
      When a test specifically exercises a marked-deprecated library or a marked-deprecated part of a library, we do not need to see the deprecation warnings - they are noise.
      
      Specifically, `Singleton` and `Subprocess` have tested but marked-deprecated APIs, so we suppress deprecation warnings in those specific test suites.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D4230826
      
      fbshipit-source-id: 937b078029cde492906088caa3a9e5eee449bc12
      26c4e8d2
  14. 23 Nov, 2016 4 commits
    • Christopher Dykes's avatar
      Don't expect .native() to return a string · 4abc2aa0
      Christopher Dykes authored
      Summary: It's called `.native()` for a reason, and returns a `wstring` on windows, so call `string()` instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4229254
      
      fbshipit-source-id: d5f9658b41f45fd719ca3e878a2e61c9dce24f10
      4abc2aa0
    • Teng Qin's avatar
      Add USDT header file to folly · f405f9de
      Teng Qin authored
      Summary:
      Derived from `sdt.h` in [[ https://sourceware.org/systemtap/ | SystemTap ]]
      Performed changes and clean-ups including:
      - Get rid of the `sdt-config.h`.
      - Get rid of "Running in Assembler" code.
      - Replace the `DTRACE_PROBE_1, ... DTRACE_PROBE_N` Macro family with a single Macro using the "count Macro arguments" trick
      - Get rid of argument signed-ness calculation. A **lot** of painful code were there only for this, and it has no real usage except for displaying purposes.
      - Re-structure the helper methods (Macros) so that the logic of the code is a bit more readable.
      - Add some comments so that it would be easier for users and future developers to understand what this header file is actually doing.
      - Update license banner.
      
      Reviewed By: meyering
      
      Differential Revision: D3792966
      
      fbshipit-source-id: 564a1011f7946d30be78191f334e072d94fa264e
      f405f9de
    • Christopher Dykes's avatar
      Close sockets properly in the portability headers · 215636b2
      Christopher Dykes authored
      Summary:
      Even when linked against the dynamic runtime.
      In truth, the old way was far cleaner, but we do need to be able to close the file descriptors as there is a hard global limit set by the CRT when it's compiled of 8k file descriptors.
      This closes it by applying a flag that prevents calls to `CloseHandle` from actually closing the handle, then we call `_close` to get the file descriptor itself closed, then we can call `_closesocket` to close the socket and handle.
      This is complicated by the fact that attempting to close a handle that you've marked as being prevented from being closed will trigger an SEH exception, but only if you have a debugger attached. That means that, for anything closing sockets to be debuggable, we have to handle that exception (as a no-op) and then get to have fun trying to get `STATUS_HANDLE_NOT_CLOSABLE`, which for some absurd reason, is only defined as part of the driver developer kit's headers. Some fun ensued where VS was nice enough to point out that the bcrypt headers also defines `NTSTATUS`, and doesn't require building as a driver to use it. For that reason we borrow its definition of `NTSTATUS` rather than declaring it ourselves.
      We also have to prevent the main windows headers from defining the base SEH exceptions, because those will be redefined by `ntstatus.h` otherwise :(
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4222625
      
      fbshipit-source-id: 6ed7e91b7a735b5506eb189e452983cd8cace34b
      215636b2
    • Christopher Dykes's avatar
      Suppress some aborts in debug mode when using already closed file descriptors · e6d69248
      Christopher Dykes authored
      Summary: The helper exists because MSVC is a pain in this regard, so use it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4224037
      
      fbshipit-source-id: 6c6415877785f13ea91618a3042f2470dccd08c1
      e6d69248
  15. 22 Nov, 2016 3 commits
    • Stepan Palamarchuk's avatar
      Fix fibers gdb utils script · d5f5bc4f
      Stepan Palamarchuk authored
      Summary:
      There was a recent change in boost compatibility that changed fibers internals and thus broke this script.
      This diff fixes gdb script to properly print stack trace for fibers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4214575
      
      fbshipit-source-id: 4bf69e9b297c7539a2b2b71093998c30d6a2d81c
      d5f5bc4f
    • Lovro Puzar's avatar
      Tweak zstd autoconf check so the build works with older zstd · 4432fc24
      Lovro Puzar authored
      Summary: Ubuntu 16.10 has a package for zstd 0.5.1 which is too old to be used by folly.  With this change autoconf will check that one of the newer functions is present, disable zstd if not.
      
      Reviewed By: Orvid, philippv
      
      Differential Revision: D4219964
      
      fbshipit-source-id: 1e64dfb62f81f7e61b097cb7d4fd3810da476625
      4432fc24
    • Christopher Dykes's avatar
      Correctly bind to the wildcard address in AsyncServerSocket::bind · e2a71713
      Christopher Dykes authored
      Summary: Because Windows disagrees with everything else about how to specify that you want the wildcard address. It's done with an empty string on Windows, but `nullptr` everywhere else.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4216970
      
      fbshipit-source-id: b5dc136946d9677a96be3252e44d383a6abca800
      e2a71713