1. 16 Jun, 2017 6 commits
    • Christopher Dykes's avatar
      Remove the relative comparison operators on LogLevel · ff607e1b
      Christopher Dykes authored
      Summary: MSVC, GCC, and Clang define the relative comparison operators by default on `enum class` values, however under MSVC defining them explicitly causes the compiler to fail to resolve which operator to use, so just remove them entirely, as they aren't needed.
      
      Reviewed By: simpkins
      
      Differential Revision: D5259835
      
      fbshipit-source-id: 1b91db5de0fc47320daabfdd7132ae910887ff0f
      ff607e1b
    • Christopher Dykes's avatar
      Don't declare caught exceptions when not actually used · ab9a4d71
      Christopher Dykes authored
      Summary: There are a couple of places where the caught exception was being given a name that was never used, generating a warning under MSVC.
      
      Reviewed By: simpkins
      
      Differential Revision: D5260131
      
      fbshipit-source-id: f82c6bd1266f6a4c916594ec3ac94edc9a2e48fe
      ab9a4d71
    • Christopher Dykes's avatar
      Don't try to use _CrtDbgReport in the logging framework · cd02eca6
      Christopher Dykes authored
      Summary: Glog doesn't try to, so there's no real reason to try and be smart. Just do the same thing as every other platform for now until we have reason to do otherwise.
      
      Reviewed By: simpkins
      
      Differential Revision: D5259435
      
      fbshipit-source-id: dcdf55f51f2e13945afd351cb45e9c1a22f56218
      cd02eca6
    • Christopher Dykes's avatar
      Ensure LogWriter::writeMessage(std::string&&) is in the overload set of ImmediateFileWriter · 19859f96
      Christopher Dykes authored
      Summary: As MSVC correctly warns via C4266, the overload sets of functions in base classes are not part of the overload set in derived classes where you've declared an overload (or override) unless you've explicitly imported it.
      
      Reviewed By: simpkins
      
      Differential Revision: D5260056
      
      fbshipit-source-id: bbbeeea3c13201a3a6eba6e62cfa5a49a9470d43
      19859f96
    • Christopher Dykes's avatar
      Include the time portability header in GlogStyleFormatter.cpp · 2bb2c015
      Christopher Dykes authored
      Summary: It is needed on Windows for the `localtime_r` function.
      
      Reviewed By: simpkins
      
      Differential Revision: D5259944
      
      fbshipit-source-id: e380ecf42252ecabec168cf87668ace3ff4c0a9f
      2bb2c015
    • Christopher Dykes's avatar
      Explicitly initialize the base class of LogStream · a219d071
      Christopher Dykes authored
      Summary:
      The standard does not define that `std::ostream` should have a default constructor, so this was invalid and was an error on Windows.
      This explicitly initializes the base class by passing a `nullptr`.
      
      Reviewed By: simpkins
      
      Differential Revision: D5259690
      
      fbshipit-source-id: b8914d73ff2682e1a4447b8338860259778b2247
      a219d071
  2. 15 Jun, 2017 13 commits
    • Andrii Grynenko's avatar
      Fix Observable to not trigger unneccessary refresh if the value didn't change · 3e010905
      Andrii Grynenko authored
      Differential Revision: D5251218
      
      fbshipit-source-id: 1ceb37dd727e8ac2fd842e2c437cdaa9017221c8
      3e010905
    • Adam Simpkins's avatar
      fix issues with the open source tests · 5dd16dc0
      Adam Simpkins authored
      Summary:
      Fix build problems in the open source Makefiles that cause issues when running
      `make check`
      
      - The test subdirectory needs to be processed before experimental, since some
        tests in experimental/ depend on libfollytestmain from test/
      - The stats/test Makefile had an incorrectly copy-and-pasted line for
        libgtest_la_SOURCES but didn't actually build a libgtest.la library.
      - The test/ Makefile defined thread_id_test but forgot to add it to TESTS so
        that it would actually be run as part of "make check"
      
      Reviewed By: Orvid
      
      Differential Revision: D5249132
      
      fbshipit-source-id: 5a71e1f72a39d5407b843a5876891c67238ec006
      5dd16dc0
    • Adam Simpkins's avatar
      logging: add initialization convenience functions · f47a8a52
      Adam Simpkins authored
      Summary:
      Add a logging/Init.h header file with a couple convenience functions for
      initializing log levels and log handlers.
      
      This is pretty basic for now, but simplifies usage for small programs that just
      want to easily initialize the logging library.
      
      Reviewed By: wez
      
      Differential Revision: D5083106
      
      fbshipit-source-id: 73c1fd00df2eaf506b9c1485d6afd12570412a0f
      f47a8a52
    • Adam Simpkins's avatar
      logging: add GlogStyleFormatter · 48b88f01
      Adam Simpkins authored
      Summary:
      Add a LogFormatter implementation that logs messages using a similar format to
      the glog library.
      
      Reviewed By: wez
      
      Differential Revision: D5083108
      
      fbshipit-source-id: 75f0a6b78ce5406b4557d6c4394f033d5e019f71
      48b88f01
    • Adam Simpkins's avatar
      logging: add AsyncFileWriter · 82b71ca3
      Adam Simpkins authored
      Summary:
      Add an AsyncFileWriter class that implements the LogWriter interface using a
      separate I/O thread to write the log messages to a file descriptor.
      
      This LogWriter implementation ensures that normal process threads will never
      block due to logging I/O.  By default it will buffer up to 1MB of data.  If
      log messages are generated faster than they can be written to the file, log
      messages will be discarded once the buffer limit is exceeded.  The LogWriter
      will emit a message into the file recording how many messages were discarded
      where the dropped messages should have been.
      
      The downside of this class is that unwritten log messages still in the buffer
      will be lost when the program crashes.
      
      Reviewed By: wez
      
      Differential Revision: D5083107
      
      fbshipit-source-id: c67226f4d0726675d480b03eae83a29c5c3431b2
      82b71ca3
    • Adam Simpkins's avatar
      logging: add ImmediateFileWriter · cb238d29
      Adam Simpkins authored
      Summary:
      Add an ImmediateFileWriter class that implements the LogWriter interface by
      immediately writing data it receives to a file descriptor.
      
      This LogWriter implementation can be used by users that want to ensure log
      messages are immediately flushed to a file as soon as they are written, at the
      expense of possibly having logging I/O block their normal process threads.
      
      Reviewed By: wez
      
      Differential Revision: D5083105
      
      fbshipit-source-id: 15cd071834e1784fe50e1d6d6ce403b9bc907047
      cb238d29
    • Adam Simpkins's avatar
      logging: add a LoggerDB::internalWarning() function · 78307e3f
      Adam Simpkins authored
      Summary:
      A few places in the logging code need to report issues when something goes
      wrong in the logging code itself.  This adds a new LoggerDB::internalWarning()
      method for use in these places.
      
      This provides a default implementation that logs these warnings with
      _CrtDbgReport() on Windows, and writes to stderr on non-Windows platforms.
      The default implementation can also be overridden for programs that want some
      alternative behavior.
      
      Reviewed By: wez
      
      Differential Revision: D5157731
      
      fbshipit-source-id: e27f5587d58b3941fca8d5b38c8c3edbcb75d7f3
      78307e3f
    • Adam Simpkins's avatar
      logging: add new RateLimiter helper class · dc37f8ea
      Adam Simpkins authored
      Summary:
      Add a new RateLimiter API to the logging library, to support rate limiting
      messages in the future.  I have included a single IntervalRateLimiter
      implementation in this diff.  In the future we can add more implementations if
      necessary, to mimic the functionality available with our older logging code, to
      make it easier for users to convert to the new framework.
      
      Note that RateLimiter is inside a `folly::logging` namespace, unlike most of
      the other code in the logging library that lives directly in the `folly`
      namespace.  I intentionally chose this since RateLimiter is a fairly generic
      class name, and I wanted to distinguish it from other possible generic class
      names in folly.  On the other hand, most of the other class names already start
      with `Log`, so there seems to be no need to put them in a `logging` namespace.
      
      Nothing is using this new API yet, but I will use it for some internal logging
      APIs in an upcoming diff.  Later on I also plan to use it to implement
      per-LogCategory rate limiting, and possibly per-LogHandler rate limiting.
      
      Reviewed By: wez
      
      Differential Revision: D5162805
      
      fbshipit-source-id: 9b81c2f4544006cd392152a768296bce0c5daaa1
      dc37f8ea
    • Adam Simpkins's avatar
      logging: add LogFormatter and LogWriter interfaces · 9578ff20
      Adam Simpkins authored
      Summary:
      This simplifies the LogHandler interface to a single generic `handleMessage()`,
      and adds a `StandardLogHandler` implementation that defers to separate
      `LogFormatter` and `LogWriter` objects.
      
      The `LogFormatter` class is responsible for serializing the `LogMessage` object
      into a string, and `LogWriter` is responsible for then doing something with
      the serialized string.
      
      This will make it possible in the future to have separate `LogWriter`
      implementations that all share the same log formatting code.  For example, this
      will allow separate `LogWriter` implementations for performing file I/O
      immediately versus performing I/O asynchronously in a separate thread.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5083103
      
      fbshipit-source-id: e3f5ece25e260c825d49a5eb30e942973d6b68bf
      9578ff20
    • Adam Simpkins's avatar
      logging: add XLOG() and XLOGF() logging macros · 9e55caa8
      Adam Simpkins authored
      Summary:
      This adds new `XLOG()` and `XLOGF()` macros to the logging library.  These are
      similar to `FB_LOG()` and `FB_LOGF()`, but do not require a Logger argument.
      Instead, the log category is picked automatically based on the current file
      name.  The basic algorithm for picking the category name is to replace
      directory separators with '.', and to strip off the filename extension.
      
      For instance, all `XLOG()` statements in `src/foo/bar.cpp` will log to the
      category `src.foo.bar`.  This also works correctly in header files: `XLOG()`
      statements in `src/foo/mylib.h` will log to `src.foo.mylib`
      
      This should generally result in a good log category hierarchy without the user
      having to spend additional time picking category names--we simply re-use the
      decisions that they already made for their directory layout.
      
      In general I expect the `XLOG()` macros to be convenient enough that users will
      use `XLOG()` in almost all cases rather than using `FB_LOG()`.
      
      The log category name used by `XLOG()` statements can be overridden using
      `XLOG_SET_CATEGORY()`, but this only works in .cpp files, not in header files.
      
      Reviewed By: wez
      
      Differential Revision: D4920257
      
      fbshipit-source-id: 7ffafd9a4c87e6fb5eb35d86e0eb86ef1ed5be95
      9e55caa8
    • Maged Michael's avatar
      Add thread caching of hazard pointers. Benchmarks. Minor fixes, optimizations, and refactoring. · 1d83c51f
      Maged Michael authored
      Summary:
      Added support for thread caching of hazard pointers.
      Added thread caching benchmarks.
      Removed function call from hazptr_domain constexpr constructor.
      Optimizations of memory order and code refactoring.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D5249070
      
      fbshipit-source-id: 487fb23abccde228c3c726de4ac8e9f07bfa9498
      1d83c51f
    • Neel Goyal's avatar
      Fix a memory leak in 1.1.0 related to initial_ctx · 4ecd9abf
      Neel Goyal authored
      Summary: We would always up_ref the ctx before setting it as the initial_ctx.  This causes a leak in 1.1.0 since the initial_ctx isn't set in this version of OpenSSL.  We'll move the up_ref for the initial_ctx into the OpenSSLUtils helper.
      
      Reviewed By: anirudhvr
      
      Differential Revision: D5227823
      
      fbshipit-source-id: b4490b317bd4dc8752a8d7e244fd153100a52aa6
      4ecd9abf
    • James Sedgwick's avatar
      fix rest of non-portable includes · 3bade5df
      James Sedgwick authored
      Summary: According to internal linter
      
      Reviewed By: Orvid
      
      Differential Revision: D5051010
      
      fbshipit-source-id: febdeca05ac1cf3ad82617169f90912a445cf173
      3bade5df
  3. 14 Jun, 2017 1 commit
    • Jonathan Kron's avatar
      Fixing opt-asan/ubsan fail for folly contbuild · 5086391b
      Jonathan Kron authored
      Summary: Flag caused compilation error on unused param, asserts optimized out in opt-asan/ubsan builds.  Replaced with DCHECK as per meyering's advice.
      
      Reviewed By: meyering
      
      Differential Revision: D5246089
      
      fbshipit-source-id: dc0abda91f900dd98af31410f4667c52404997f5
      5086391b
  4. 13 Jun, 2017 7 commits
    • Nick Terrell's avatar
      Add fuzz testing · 626f5abb
      Nick Terrell authored
      Summary: `ZSTD_decompress()` doesn't verify the uncompressed length in the frame as I thought, so throw an exception instead of `DCHECK()`.
      
      Reviewed By: meyering
      
      Differential Revision: D5234576
      
      fbshipit-source-id: f72cf085a7267de32ce13553ce7ebbfe3b8a3f05
      626f5abb
    • Sven Over's avatar
      remove misleading comment in Partial.h · 26ca775e
      Sven Over authored
      Summary:
      The removed comment cites a gcc compiler bug as a reason to spell
      out the return type of the three operator() methods. While that
      compiler bug can lead to compiler errors in some situations,
      it is not the only reason why we need the return type arrow
      notation.
      
      If the compiler tries to instantiate operator() with a set of
      parameters that the embedded function does not accept, then the
      substitution failure is inside decltype, which is not a compiler
      error (SFINAE) but just means that the Partial class doesn't define
      operator() for that parameter signature. Without decltype, the body
      of operator() is ill-formed and that is a compiler error.
      
      Reviewed By: meyering
      
      Differential Revision: D5236537
      
      fbshipit-source-id: 7daa0fbcf128a2c7c5c36532a5402deba394e1b8
      26ca775e
    • Nick Terrell's avatar
      Add toFullyQualifiedAppend() methods · 5203b6ba
      Nick Terrell authored
      Summary: A common use case for `IPAddress::toFullyQualified()` is to print a `<ip>:<port>` string. It is faster to reserve enough space for both beforehand than create 2 strings.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5224454
      
      fbshipit-source-id: 4536f89a9d51d39dd9fd970c753ecb8ecced5d22
      5203b6ba
    • Nick Terrell's avatar
      Fix decompression of truncated data · 9883bc37
      Nick Terrell authored
      Summary: During decompression, when the data is truncated, `StreamCodec::doUncompress()` loops forever, since it doesn't check forward progress. `Bzip2Codec` does the same.
      
      Reviewed By: chipturner
      
      Differential Revision: D5233052
      
      fbshipit-source-id: 8797a7f06d9afa494eea292a8a5dc980c7571bd0
      9883bc37
    • Adam Simpkins's avatar
      logging: if folly::format() fails, also log the arguments · ba74a196
      Adam Simpkins authored
      Summary:
      If the folly::sformat() call fails in an FB_LOGF() statement, make a
      best-effort attempt to log the format arguments as well, in addition to the
      format string.  For each argument, folly::to<std::string>() is use if it is
      supported for this argument.
      
      This will help ensure that the arguments that were being logged aren't lost
      even if the format string was incorrect.
      
      Reviewed By: WillerZ
      
      Differential Revision: D5082978
      
      fbshipit-source-id: 0d56030e639cd7e8f2242bb43646ab4248c6a877
      ba74a196
    • Adam Simpkins's avatar
      logging: add support for streaming operators · dc2c2837
      Adam Simpkins authored
      Summary:
      Update the logging library so that FB_LOG() and FB_LOGF() also accept
      streaming style arguments:
      
        FB_LOG(logger) << "logs can be written like this now: " << 1234;
        FB_LOG(logger, "both styles can be used") << " together";
        FB_LOGF(logger, "test: {}, {}", 1234, 5678) << " and with FB_LOGF() too";
      
      Streaming support does make the upcoming XLOG() macros more complicated to
      implement, since the macro has to expand to a single ternary `?` expression.
      However I was able to come up with a solution that works and has minimal
      overhead.
      
      Reviewed By: wez
      
      Differential Revision: D5082979
      
      fbshipit-source-id: 11734e39c02ad28aceb44bbfbd137d781caa30cf
      dc2c2837
    • Adam Simpkins's avatar
      add a new logging library · e9c1c043
      Adam Simpkins authored
      Summary:
      This begins adding a new logging library for efficient, hierarchical logging.
      
      This includes the basic library framework, plus a README file with a brief
      overview and the motivation for creating a new logging library.
      
      Reviewed By: wez
      
      Differential Revision: D4911867
      
      fbshipit-source-id: 359623e11feeaa547f3ac2c369bf806ee6996554
      e9c1c043
  5. 12 Jun, 2017 1 commit
  6. 10 Jun, 2017 3 commits
    • Tianjiao Yin's avatar
      fix FutexTest · c27b2745
      Tianjiao Yin authored
      Summary: 2_ms seems too short. I am not sure whether it's feasible to check whether thread is waiting for an address. We could wait for longer to reduce false alarm.
      
      Reviewed By: nbronson
      
      Differential Revision: D5220819
      
      fbshipit-source-id: 42f31206e9cb7f9addaa049d0e7cd995f6735f6c
      c27b2745
    • Yedidya Feldblum's avatar
      Let SubprocessError inherit std::runtime_error · ee87051b
      Yedidya Feldblum authored
      Summary:
      [Folly] Let `SubprocessError` inherit `std::runtime_error`.
      
      As an added bonus, this gives it `std::runtime_error`'s refcounted string for cheap copies.
      
      Reviewed By: ericniebler
      
      Differential Revision: D5216758
      
      fbshipit-source-id: 43298e06f02cfd88abf2d73f7aa16117a6cb052b
      ee87051b
    • Christopher Dykes's avatar
      Reorganize the stats directory · d8ed7cbc
      Christopher Dykes authored
      Summary: The source and tests for the stats directory was spread across folly/detail and folly/test, move them into folly/stats directly instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5216810
      
      fbshipit-source-id: 00a8bb95a4f7830d0bc46b3f914f256a37833b78
      d8ed7cbc
  7. 09 Jun, 2017 7 commits
    • Victor Gao's avatar
      apply clang-tidy modernize-use-override · b367f0fa
      Victor Gao authored
      Summary: Use clang-tidy to mechanically add missing `override` and remove redundant `virtual`.
      
      Reviewed By: igorsugak
      
      Differential Revision: D5211868
      
      fbshipit-source-id: 6a85f7c4a543a4c9345ec5b0681a8853707343dc
      b367f0fa
    • Victor Gao's avatar
      apply clang-tidy modernize-use-override · 16723809
      Victor Gao authored
      Summary: Use clang-tidy to mechanically add missing `override` and remove redundant `virtual`.
      
      Reviewed By: igorsugak
      
      Differential Revision: D5211868
      
      fbshipit-source-id: 4118c4c72f8ec3485507f69679f7e852b3eaeb73
      16723809
    • Yedidya Feldblum's avatar
      Saner test exception in ExceptionWrapperTest.cpp · 6da8593f
      Yedidya Feldblum authored
      Summary:
      [Folly] Saner test exception in `ExceptionWrapperTest.cpp`.
      
      Make construction do the work and make `what()` free.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D5216707
      
      fbshipit-source-id: bfb4c2473a61ff7da7a3a01adc85facae30d6586
      6da8593f
    • Anirudh Ramachandran's avatar
      Some more OpenSSL 1.1.0 compat APIs · d3e8b83f
      Anirudh Ramachandran authored
      Summary: Add a few more compatibility wrappers for pre-1.1.0 APIs
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5194164
      
      fbshipit-source-id: ae8db08c31370eca729df2927798b6f4d99ee70c
      d3e8b83f
    • Yedidya Feldblum's avatar
      Apply clang-format to folly/gen/ (template decls) · adb8559d
      Yedidya Feldblum authored
      Summary: [Folly] Apply `clang-format` to `folly/gen/` (template decls).
      
      Reviewed By: Orvid
      
      Differential Revision: D5216229
      
      fbshipit-source-id: 1659f1944ccde4de39bccd189bb6490395cf29c2
      adb8559d
    • Christopher Dykes's avatar
      Fix OpenSSLUtils to not include headers the wrong way · 1b0c0d91
      Christopher Dykes authored
      Summary: This is entirely the wrong way to include these headers, and is being included within an anon namespace so just wrong.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5215065
      
      fbshipit-source-id: 499df58c0202f7a1d4482eaa6a0e8b2e1535c763
      1b0c0d91
    • Yedidya Feldblum's avatar
      Apply clang-format to folly/experimental/exception_tracer/ (headers) · f34d96eb
      Yedidya Feldblum authored
      Summary:
      [Folly] Apply `clang-format` to `folly/experimental/exception_tracer/` (headers).
      
      With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over the listed directory becomes a no-op.
      
      Reviewed By: Orvid
      
      Differential Revision: D5215212
      
      fbshipit-source-id: 5570f02c238b1874adbc2ff4150f465c947ad0e6
      f34d96eb
  8. 08 Jun, 2017 2 commits
    • Yedidya Feldblum's avatar
      Apply clang-format to folly/fibers/ · 811c6c33
      Yedidya Feldblum authored
      Summary:
      [Folly] Apply `clang-format` to `folly/fibers/`
      
      With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over `folly/fibers/` becomes a no-op.
      
      Reviewed By: igorsugak
      
      Differential Revision: D5178118
      
      fbshipit-source-id: ae65ff1902666ba9106e18f916bb1d10e6406bf4
      811c6c33
    • Christopher Dykes's avatar
      Switch unguarded #pragmas to use portability macros · 146c24b7
      Christopher Dykes authored
      Summary: Otherwise downstream Windows users have to explicitly disable MSVC's warnings about unknown pragmas.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5211415
      
      fbshipit-source-id: 42871e03895010818c7e1cb6e57c1885970e98c2
      146c24b7