1. 22 Mar, 2017 2 commits
    • Brian Smith's avatar
      Add additional points to configure help output · 3c0df746
      Brian Smith authored
      Summary: Sometimes tools need to output a little more help context before or after help.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4719112
      
      fbshipit-source-id: e6f59312d722e0669053644d862c81758855b538
      3c0df746
    • Christopher Dykes's avatar
      Use the gflags portability header · 69bd8deb
      Christopher Dykes authored
      Summary: The gflags portability header should always be used in Folly. There were a couple of places gflags was being used directly. This fixes that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4748674
      
      fbshipit-source-id: ba3c0564a39f870f1f5f9371e32d06eb84591ba7
      69bd8deb
  2. 21 Mar, 2017 5 commits
    • Nathan Bronson's avatar
      fix sorted_vector_{set,map} insert with bad hint · 13ded99f
      Nathan Bronson authored
      Summary:
      sorted_vector_{set,map} can silently drop insert if the hinted
      insertion position is too small.  This diff fixes it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4747319
      
      fbshipit-source-id: 31e399d07a0b77b700edf034dc723cb997dc8e16
      13ded99f
    • Nick Terrell's avatar
      Add IOBuf::cloneCoalesced() · 630673be
      Nick Terrell authored
      Summary:
      `LZ4Codec::doCompress()` and `doUncompress()` need to coalesce a `const IOBuf*`, so they `clone()` and then `coalesce()`.
      It is more efficient to do this in one step, as shown by the benchmarks.
      
      Reviewed By: yfeldblum, simpkins
      
      Differential Revision: D4727802
      
      fbshipit-source-id: f8d5f6187f2ee804301232b3c75b848330169fc5
      630673be
    • Andrii Grynenko's avatar
      Don't allow singleton use w/o registrationComplete() · 68d5fb06
      Andrii Grynenko authored
      Summary: Submitting mostly to see what breaks.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4249032
      
      fbshipit-source-id: d4e3fdfd57750c8dcabdb4c01ab3b528c4818624
      68d5fb06
    • Christopher Dykes's avatar
      Re-enable a couple of tests under MSVC · d51aa234
      Christopher Dykes authored
      Summary: VS 2017 is here and the bugs these were hitting have been fixed, so re-enable them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4742829
      
      fbshipit-source-id: 898e7cfea9de9ffa813c562c12e0e18e0577c8c3
      d51aa234
    • Maxim Georgiev's avatar
      In AsyncSocketTest.SendMessageFlags test use folly::test::TemporaryFile object... · 3ffa8cf0
      Maxim Georgiev authored
      In AsyncSocketTest.SendMessageFlags test use folly::test::TemporaryFile object instead of directly creating a file with O_TMPFILE flag
      
      Summary: O_TMPFILE flag is not available on older Linux systems (supported starting Linux 3.11). Got complains about it on GitHub (https://fburl.com/9d848m7i) Will use folly::test::TemporaryFile instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4729733
      
      fbshipit-source-id: 903563825c5b939e35c61725da559e33d21212c4
      3ffa8cf0
  3. 20 Mar, 2017 3 commits
    • Louis Brandy's avatar
      call static function directly · b727acf4
      Louis Brandy authored
      Summary: This code looks really weird and is otherwise confusing.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D4730812
      
      fbshipit-source-id: d9f4e73145e81f085ce959a76cdb568d3ae4eb52
      b727acf4
    • Christopher Dykes's avatar
      Give observer manager threads a name · f244bdc6
      Christopher Dykes authored
      Summary: Re-landing D4618623 after it had to be reverted due to it's use of `FixedString`, which had broken GCC 4.8. `FixedString` should now be compiling correctly on GCC 4.8 so this should be fine now.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4727022
      
      fbshipit-source-id: f85c6952fd82e6cd6042f8055ef54d9422f8b0f9
      f244bdc6
    • Jason Fried's avatar
      Folly Futures to Python Asyncio Futures Bridge · 1d3ca26b
      Jason Fried authored
      Summary:
      folly/python/futures.h provides some helper functions for bridging folly::future to asyncio.Future.
      
      folly/python/NotificationQueueExecutor.h is a Driveable executor that has a fileno() method that can be monitored using (select, epoll) to determine if the drive method should be called.
      
      folly/python/executor.pyx is an implementation of a "driver" for the NotificationQueueExecutor from the python asyncio side. It tracks also keeps track of asyncio eventloops to Executor mappings.
      
      the getExecutor() from folly/python/futures.h uses that mapping to return the correct executor for this python thread.
      
      Reviewed By: andriigrynenko, yfeldblum
      
      Differential Revision: D4687029
      
      fbshipit-source-id: e79314606ffa18cb6933fe6b749991bfea646cde
      1d3ca26b
  4. 19 Mar, 2017 1 commit
    • Jim Meyering's avatar
      folly/test/TimeseriesTest.cpp: avoid shadowing warnings · 5d9dbb73
      Jim Meyering authored
      Summary:
      Fix warnings exposed by gcc's -Wshadow-compatible-local.
      Rename lambda parameter "ts" to "timeSeries".
      
      This avoids the following errors:
      
        folly/test/TimeseriesTest.cpp:802:27: error: declaration of 'ts' shadows a previous local [-Werror=shadow-compatible-local]
        folly/test/TimeseriesTest.cpp:809:31: error: shadowed declaration is here [-Werror=shadow-compatible-local]
      
      Reviewed By: yfeldblum, liuxuli
      
      Differential Revision: D4735180
      
      fbshipit-source-id: 59b3fecf4031b3c6615e5b764fbc4ea04754eb50
      5d9dbb73
  5. 18 Mar, 2017 1 commit
  6. 17 Mar, 2017 2 commits
    • Brian Smith's avatar
      Put the full help before the options · aee35091
      Brian Smith authored
      Summary: This is more in line with "traditional" output from cli tools on *nix.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4719055
      
      fbshipit-source-id: 2389a4a2a49f18d4b3d0257f68036f73f8fbc49e
      aee35091
    • Andreas C. Osowski's avatar
      Add hash and equal_to implementations to folly::Uri · cb969f7a
      Andreas C. Osowski authored
      Summary:
      Adds a default inline implementation for `std::hash` and `std::equal_to` to `folly::Uri`.
      Both do the comparison / hash based upon the return value of `folly::Uri::toString`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4711506
      
      fbshipit-source-id: f4c2a9de8d4302fd315a9f31329cc8ba9f5e0409
      cb969f7a
  7. 16 Mar, 2017 2 commits
    • Michael Steinert's avatar
      Add support for OpenSSL 1.0 · ebebe68b
      Michael Steinert authored
      Summary:
      I'm working on a project where the target platform is tiny a bit out of
      date:
      
          $ openssl version
          OpenSSL 1.0.0-fips 29 Mar 2010
      
      For various "reasons" I'm not able to update it at this time, however I
      would like to use Proxygen (and hence Folly). This patch allows Folly to
      compile with the above version of OpenSSL.
      Closes https://github.com/facebook/folly/pull/562
      
      Reviewed By: Orvid
      
      Differential Revision: D4715116
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: be38ffb78f1e5cee971ce8cb81936b7f16efe050
      ebebe68b
    • JiaJie Ye's avatar
      Add getPeerAddress/getLocalAddress folly::SocketAddress() function · 3442c11d
      JiaJie Ye authored
      Summary: Add getPeerAddress/getLocalAddress folly::SocketAddress() function
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4706693
      
      fbshipit-source-id: 534e862f4168bc9e7bb02e41eac8e2ced6a02c59
      3442c11d
  8. 15 Mar, 2017 3 commits
    • Christopher Dykes's avatar
      Backport std::index_sequence and friends · 2843ff12
      Christopher Dykes authored
      Summary:
      To GCC 4.8, because it's not *quite* dead yet.
      
      This is needed to get FixedString working properly on GCC 4.8
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4646026
      
      fbshipit-source-id: 075df04e479bd2b11f6538da2ed3e78b59956621
      2843ff12
    • Michael Steinert's avatar
      Fix the pkg-config filter · 58d67ca5
      Michael Steinert authored
      Summary:
      I encountered a situation where "pkg-config --libs openssl" included
      some linker flags, i.e.
      
          $ pkg-config --libs openssl
          -Wl,-z,relro -lssl -lcrypto -ldl -lz
      
      This resulted in these linker flags being passed to sed. This change
      filters out the linker flags from the pkg-config output.
      Closes https://github.com/facebook/folly/pull/559
      
      Reviewed By: pixelb
      
      Differential Revision: D4700120
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 530d524caf965919418d19a1df53d2b418f67717
      58d67ca5
    • Felix Handte's avatar
      Add String Support to Compression Codec · a5093cb5
      Felix Handte authored
      Summary:
      This diff adds string-based compress and uncompress support to
      folly::io::Codec. By default, the string API is implemented by translating to
      and from IOBufs. Room is left for individual implementations to override that
      behavior and go straight to the underlying library.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4690770
      
      fbshipit-source-id: 7e2615da9add8328654505cdda6a2c79583b4558
      a5093cb5
  9. 14 Mar, 2017 3 commits
  10. 13 Mar, 2017 4 commits
    • Christopher Dykes's avatar
      Add a way to determine if a compression codec is supported at runtime · ce56a16a
      Christopher Dykes authored
      Summary: Folly supports being compiled without all of the compression libraries, so we need a way to determine at runtime what libraries Folly has been compiled to support.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4692556
      
      fbshipit-source-id: 0ec459db70a4b1d64f1e07c87a1f51ae584bccd0
      ce56a16a
    • Nick Terrell's avatar
      Fill buffer before allocating more · 03d240dc
      Nick Terrell authored
      Summary:
      Modify `QueueAppender::pushAtMost(const uint8_t*, size_t)` to fill the end of
      the current buffer before it allocates another.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4687832
      
      fbshipit-source-id: 7c21f4359da9f0cf26d9577abddfd640b0c877e9
      03d240dc
    • Tom Jackson's avatar
      get_ptr(mapOfMaps, key, key...) · a2353bc0
      Tom Jackson authored
      Summary:
      Since this is a not-uncommon pattern now:
      
      ```lang=cpp
      if (auto found1 = get_ptr(m, k1)) {
        if (auto found2 = get_ptr(*found, k2)) {
          return use(*found2);
        }
      }
      ```
      
      This diff enables:
      
      ```lang=cpp
      if (auto found = get_ptr(m, k1, k2)) {
        return use(*found);
      }
      
      ```
      
      Note that it works for const and non-const maps, returning a correspondingly mutable pointer.
      
      Reviewed By: luciang, yfeldblum
      
      Differential Revision: D3812701
      
      fbshipit-source-id: 77ace9f5dca6cdc4cae7e6dfb9e5fc1075b5b571
      a2353bc0
    • Phil Willoughby's avatar
      Update folly::Singleton documentation block · 13520418
      Phil Willoughby authored
      Summary:
      With more experience of using folly::Singleton in our code we have found new
      recommendations for how it should be used. This change updates the
      documentation block to include those recommendations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4688700
      
      fbshipit-source-id: 40350c2330084a28f1dc0744176d0ac8a0e64d39
      13520418
  11. 11 Mar, 2017 1 commit
  12. 10 Mar, 2017 7 commits
    • Maged Michael's avatar
      Fix data race in IndexedMemPool · 95310177
      Maged Michael authored
      Summary:
      IndexedMemPool uses regular memory for the global and local next links. There can be concurrent reads and writes of such links. In order to avoid C++ undefined behavior due to the data races, these links should be atomic. Relaxed loads and stores are sufficient for correctness.
      
      Depends on D4680286
      
      Reviewed By: nbronson
      
      Differential Revision: D4680317
      
      fbshipit-source-id: 27c0d888e08bd5d862aee4c6dc6ee393033b32e3
      95310177
    • Christopher Dykes's avatar
      Fix problems with clock_gettime and OSX < 10.12 + XCode 8 · 01919b98
      Christopher Dykes authored
      Summary: It's a pain, so rely on macros to figure a few things about the build configuration.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4229128
      
      fbshipit-source-id: 78b414c21cae6ba51ade2ab75b117cccad5c608c
      01919b98
    • Andrii Grynenko's avatar
      Use VirtualEventBase in mcrouter · b5b5c548
      Andrii Grynenko authored
      Summary:
      This switches mcrouter to use VirtualEventBase as the unified way of managing its threads. This allows multiple mcrouters to be run on the same thread-pool, without having to keep separate shutdown logic.
      
      As an immediate win - this eliminates any special shutdown logic from tcc and standalone mcrouter.
      
      Reviewed By: jmswen
      
      Differential Revision: D4570982
      
      fbshipit-source-id: 3974279005150e3e1db16230fde6b5951ae016b9
      b5b5c548
    • Kyle Nekritz's avatar
      Fix use after move in AsyncSSLSocket constructor. · d5c52464
      Kyle Nekritz authored
      Summary: The new AsyncSocket is already constructed at this point so just use the event base from it.
      
      Reviewed By: djwatson
      
      Differential Revision: D4689395
      
      fbshipit-source-id: aac898c1c6e6e0e0ffcb20b16bbf2b842cc31d54
      d5c52464
    • Maxim Georgiev's avatar
      Implementing a callback interface for folly::AsyncSocket allowing to supply an... · 8ecc23d9
      Maxim Georgiev authored
      Implementing a callback interface for folly::AsyncSocket allowing to supply an ancillary data buffer with msghdr structure to sendmsg() system call
      
      Summary: Implementing a callback interface for folly::AsyncSocket allowing to supply an ancillary data buffer with msghdr structure to sendmsg() system call.
      
      Reviewed By: afrind
      
      Differential Revision: D4422168
      
      fbshipit-source-id: 29a23b05f704aff796d368f4ac9514c49b7ce578
      8ecc23d9
    • Andrii Grynenko's avatar
      Remove runInLoop · d9bf016d
      Andrii Grynenko authored
      Summary: Existing runInLoop implementation was generally not safe (it did not capture the KeepAlive token). runInLoop() is mostly used in library code though, and often times it's ok not capture the KeepAlive token. It's better to just have the caller make the decision, rather then keep runInLoop() and make it always capture the KeepAlive token.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4684025
      
      fbshipit-source-id: 65907bbe9c774e2a7b92580d0c0387d346b495d5
      d9bf016d
    • Adam Simpkins's avatar
      teach gtest how to pretty-print StringPiece values · 499cf208
      Adam Simpkins authored
      Summary:
      Even though an ostream operator<<() is defined for StringPiece, gtest doesn't
      use it when printing StringPiece values in test failure messages.  Because
      StringPiece defines a nested iterator type gtest instead treats StringPiece as
      a container, and prints each of its elements (characters) one-by-one.  This is
      fairly awkward to read.
      
      This diff defines an explicit PrintTo() function for StringPiece in
      folly/test/TestUtils.h.  This makes gtest print StringPiece values nicely if
      you include TestUtils.h in your test sources.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4672257
      
      fbshipit-source-id: 4b39ccc116e5382c29c37c2abe879293d310faf5
      499cf208
  13. 09 Mar, 2017 2 commits
    • Maged Michael's avatar
      Detect data race in IndexedMemPool · 839b3f31
      Maged Michael authored
      Summary: IndexedMemPool uses regular memory for the global and local next links. There is a data race as there can be concurrent reads and writes of such links. Added a test for data races.
      
      Reviewed By: nbronson
      
      Differential Revision: D4680286
      
      fbshipit-source-id: 9ef3ed439b9df07d69afe570e516c146caa53a6c
      839b3f31
    • Kyle Nekritz's avatar
      Replace MSG_PEEK with a pre-received data interface. · fb9776fc
      Kyle Nekritz authored
      Summary: MSG_PEEK was difficult if not impossible to use well since we do not provide a way wait for more data to arrive. If you are using setPeek on AsyncSocket, and you do not receive the amount of data you want, you must either abandon your peek attempt, or spin around the event base waiting for more data. This diff replaces the peek interface on AsyncSocket with a pre-received data interface, allowing users to insert data back onto the front of connections after reading some data in another layer.
      
      Reviewed By: djwatson
      
      Differential Revision: D4626315
      
      fbshipit-source-id: c552e64f5b3ac9e40ea3358d65b4b9db848f5d74
      fb9776fc
  14. 08 Mar, 2017 4 commits
    • Andrii Grynenko's avatar
      Fixes to always call Singleton's registrationComplete()/initFacebook() · ad9b56c1
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D4671818
      
      fbshipit-source-id: 80154adfef238f0be62da12fb843e22de1ae65ca
      ad9b56c1
    • Christopher Dykes's avatar
      Mark non-captured constexpr variable as static · b41506c2
      Christopher Dykes authored
      Summary:
      GCC & Clang allow the use of a non-captured constexpr local within a lambda, MSVC does not.
      
      All 3 compilers allow this when the local has static storage.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4675147
      
      fbshipit-source-id: 3e07eb77731cbd3ebda6aee4b0b57ac19ac34de5
      b41506c2
    • Christopher Dykes's avatar
      Don't define MALLOCX_* if building with JEMalloc · 05d0e3ed
      Christopher Dykes authored
      Summary:
      With the way it is currently, if `jemalloc.h` is included after `folly/Malloc.h`, `jemalloc.h` ends up redefining these.
      This changes it to just include `jemalloc.h` if we know we're compiling with JEMalloc.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D4660285
      
      fbshipit-source-id: 814e36432676e89cf7ba2bc5247b7dde2bfdc14a
      05d0e3ed
    • Anirudh Ramachandran's avatar
      Fix mcrouter-oss build · 162ba310
      Anirudh Ramachandran authored
      Summary: D4624754 broke mcrouter-oss because that uses older OpenSSL (1.0.1).
      
      Reviewed By: yfeldblum, jmswen
      
      Differential Revision: D4670767
      
      fbshipit-source-id: f297c8d3e013525bb36bd059eb40c70f0c4c2dcc
      162ba310