1. 11 Dec, 2014 5 commits
    • James Sedgwick's avatar
      test for OutputBufferingHandler · 899edcb7
      James Sedgwick authored
      Summary:
      MLE: my first custom matcher
      
      revealed some include issues, also fixed
      
      Test Plan: guess
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1686223
      
      Signature: t1:1686223:1416334120:41bce88d56dd9ca107f3ddc3927c6be9419370cf
      899edcb7
    • James Sedgwick's avatar
      modifiable channel pipelines · 40923559
      James Sedgwick authored
      Summary:
      Basically the same interface as before, but you must specify the read and write types for the ends of pipeline. Implementation is cleaner as well; there's fewer levels of indirection
      
      This dynamic casts shit all over the place and is less typesafe then the previous iteration, but I think with some carefully placed static_asserts, could be just as safe (in the case where you don't do any modification, anyway)
      
      Right now you can only add to the front or back of the pipeline but the way it's set up you could add any number of mutations, including ones that are triggered by handlers. But this should (might?) be enough for Tunnel, which was the motivation.
      
      Test Plan: basic test compiles, thrift2 diff still works with a one line change
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@, bmatheny
      
      FB internal diff: D1661169
      
      Tasks: 5002299
      
      Signature: t1:1661169:1416521727:1f126279796c0b09d1905b9f7dbc48a9e5540271
      40923559
    • Alexey Spiridonov's avatar
      Add process group leader option · 8a5fcb4f
      Alexey Spiridonov authored
      Summary: Now a subprocess can be reliably made a group leader -- good for job control.
      
      Test Plan:
      unit test, checked that the pgid test worked in bash, too (only OKAY_XXX is printed)
      
      ==> XXX.sh <==
      #!/bin/sh
      test $(cut -d ' ' -f 5 /proc/$$/stat) == $$ && echo OKAY_XXX
      ./YYY.sh
      
      ==> YYY.sh <==
      #!/bin/sh
      test $(cut -d ' ' -f 5 /proc/$$/stat) == $$ && echo OKAY_YYY
      ./ZZZ.sh
      
      ==> ZZZ.sh <==
      #!/bin/sh
      test $(cut -d ' ' -f 5 /proc/$$/stat) == $$ && echo OKAY_ZZZ
      
      Reviewed By: simpkins@fb.com
      
      Subscribers: net-systems@, njormrod, folly-diffs@, simpkins
      
      FB internal diff: D1492526
      
      Signature: t1:1492526:1416528620:3cf98b1c1e334a7d551b2c2f3e76b1c70f07ad7c
      8a5fcb4f
    • Nicholas Ormrod's avatar
      Fix build break · 136dd179
      Nicholas Ormrod authored
      Summary: Diff that had @override-unit-failures broke the build
      
      Test Plan: fbconfig -r folly && fbmake dbg && fbmake runtests
      
      Reviewed By: robbert@fb.com
      
      Subscribers: sdwilsh, njormrod, folly-diffs@
      
      FB internal diff: D1694388
      
      Tasks: 5662947
      
      Signature: t1:1694388:1416510278:d50f4896814a34d73d55be292961f5ecd74b1bb4
      
      Blame Revision: D1680735
      136dd179
    • James Sedgwick's avatar
      merge event base tests · 1fbc2522
      James Sedgwick authored
      Summary: someone made another event base test while the big set still lived in thrift. merge it now that the old tests have been moved.
      
      Test Plan: fbconfig folly/io/async/test && fbmake runtests --extended-tests
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1690764
      
      Signature: t1:1690764:1416413748:f3ae64d509432844bb2e1b689a75d66825269d15
      1fbc2522
  2. 20 Nov, 2014 3 commits
    • Dave Watson's avatar
      Bump version to 17:0 · 2c2d5777
      Dave Watson authored
      2c2d5777
    • Dave Watson's avatar
      folly/io/async documentation · a1279abd
      Dave Watson authored
      Summary: Documentation brain-dump.  The sources already have pretty good doxygen-style comments, but could use a good high-level overview.
      
      Test Plan: Reviewers get to edit
      
      Reviewed By: jsedgwick@fb.com, afrind@fb.com, dcsommer@fb.com, alandau@fb.com
      
      Subscribers: fugalh, subodh, kmdent, seanc, vloh, sjenkins, kparton, doug, net-systems@, njormrod, folly-diffs@, sgolemon, alikhtarov, andrii, tudorb
      
      FB internal diff: D1690976
      
      Tasks: 5648428
      
      Signature: t1:1690976:1416419706:3894976c32904f040d518b9a4ce26ccb40d7ed80
      a1279abd
    • Andrei Bajenov's avatar
      HHWheelTimer - fix scheduling timeouts within callbacks · c593b651
      Andrei Bajenov authored
      Summary:
      This one is a little tricky, but it explains what happened in t5388156. Basically what we observed in the stack traces is that the HHWheelTimer count_ is 0, but there is still a timeout scheduled on the AsyncTimeout.
      
      How I can see this happening is the following:
      - SASL times out
      - We fall back to insecure mode in the callback and schedule a send of a real message to the server. Here we schedule another timeout on the same HHWheelTimer object. Since count_ is 0 at this point, we schedule a timeout in AsyncTimeout.
      - Now the initial SASL timeout was late, so the HHWheelTimer is in a catchup state. This means that it's possible for the callback on the timeout that was just scheduled to fire on the same "tick".
      - This callback invokes SR's callbacks which try to detach the event base from the channel. But it can't detach because we have something scheduled on the AsyncTimeout.
      - We crash.
      
      Test Plan:
      - will wait for contbuild
      - Something like this repros the problem: https://phabricator.fb.com/P17220063. Note I hacked the catchup part to get it to work. Now running loadgen with security = permitted causes the crash.
      
      // hphp tests are stalled, have to do this...
      
      Reviewed By: mshneer@fb.com
      
      Subscribers: bmatheny, mshneer, sandeepkk, trunkagent, njormrod, folly-diffs@, alandau, mhorowitz, srenfro, hitesh, wstefancik
      
      FB internal diff: D1680735
      
      Tasks: 5388156
      
      Signature: t1:1680735:1416252123:e76668860ccda9380a87996b4fa3de957e129404
      c593b651
  3. 19 Nov, 2014 27 commits
    • Dave Watson's avatar
      Bump version to 16:0 · ed0a5787
      Dave Watson authored
      ed0a5787
    • Dave Watson's avatar
      OS merges · 5b34fdc3
      Dave Watson authored
      Summary:
      All pretty trivial:
      
      https://github.com/facebook/folly/issues/99
      https://github.com/facebook/folly/issues/98
      https://github.com/facebook/folly/issues/45
      
      Test Plan: Will watch jenkins fbthrift build
      
      Reviewed By: dcsommer@fb.com
      
      Subscribers: doug, njormrod, folly-diffs@
      
      FB internal diff: D1669952
      
      Signature: t1:1669952:1415643677:906234f0a89f38645b0072d3c88762d8fa2729dc
      5b34fdc3
    • Dave Watson's avatar
      server bootstrap · 1a568d03
      Dave Watson authored
      Summary:
      ServerBootstrap a la netty.
      
      This should be enough for some refactoring of thrift server and proxygen servers - but there are still lots of TODOs left to do
      
      Test Plan:
      Unittests included
      
      Depends on D1638358
      
      Reviewed By: jsedgwick@fb.com
      
      Subscribers: trunkagent, doug, fugalh, alandau, bmatheny, mshneer, jsedgwick, afrind, dcsommer
      
      FB internal diff: D1649521
      
      Tasks: 5488516
      
      Signature: t1:1649521:1416256073:fc003fd471bdfd137160dd6d7befd933ee8addd2
      1a568d03
    • Daniel Sommermann's avatar
      Run the HHWheelTimer and EventBase tests · e059c8a7
      Daniel Sommermann authored
      Summary: Fix the TARGETS from the refactor
      
      Test Plan: ran it locally
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: doug, njormrod, folly-diffs@
      
      FB internal diff: D1689151
      
      Signature: t1:1689151:1416353673:3d3575b10f963e9f558954b8f3eba8bf48cdaa74
      e059c8a7
    • Edward Chin's avatar
      add custom getLoad() for multifeed leaf · 51c927b8
      Edward Chin authored
      Summary:
      getLoad() is called in servicerouter loadbalancing when a load_counter is not specified.  I added a custom getLoad() for leaf and made it so that different metrics can be tested without code pushes.
      
      Changes:
      1) Overloaded PriorityThreadManager::getCodel() so you can specify a PRIORITY.  aggr->leaf thrift calls are marked as HIGH priority.
      2) The value of FLAGS_load_metric determines what metric the custom getLoad() will use (codel, max requests, or fallback to ThriftServer::getLoad()).
      3) Smc listener for FLAGS_load_metric.
      4) Removed server->setIsUnevenLoad(false) since there isn't reason this need to be set, and activeRequests_ and getPendingCount() are not tracked when isUnevenLoad_ is false.
      
      Test Plan: Run leaf and check that smc listener works.  Custom getLoad() won't be called until t5625774 is resolved.
      
      Reviewed By: hitesh@fb.com
      
      Subscribers: njormrod, folly-diffs@, trunkagent, varunk, fugalh, alandau, nkgupta, bmatheny, jaredg, xie, mshneer, yguo
      
      FB internal diff: D1685215
      
      Signature: t1:1685215:1416339297:0d1f8cb0cec27242d95f0067337d80149b0a720e
      51c927b8
    • Dave Watson's avatar
      Clean up runBeforeLoop API · 998b419a
      Dave Watson authored
      Summary: Clean up API per stepan's comments in D1641057: runBeforeLoop callbacks should be run before the if block, so runInLoop calls will work.
      
      Test Plan: added unittest
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, doug, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1679773
      
      Signature: t1:1679773:1415916488:f20dd98bf40dd4cb19a4b11875dc0c9fa3e7870e
      
      Blame Revision: D1641057
      998b419a
    • Daniel Sommermann's avatar
      Move some tests to folly · 5e80856a
      Daniel Sommermann authored
      Summary:
      These lived in fbthrift previously, but they should move with the
      main code too.
      
      Test Plan: unit tests
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: doug, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1683229
      
      Signature: t1:1683229:1416010730:36fb7e4c9916ae7a9b5972cd476f82014c5f4c78
      5e80856a
    • James Sedgwick's avatar
      top-level via() · 6d8f063d
      James Sedgwick authored
      Summary: as discussed
      
      Test Plan: compiles :)
      
      Reviewed By: steveo@fb.com
      
      Subscribers: fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1687921
      
      Signature: t1:1687921:1416331366:4e58a69daf39797e0d456ba86a463a9da2fd0369
      6d8f063d
    • subodh's avatar
      Improve initialization of openssl · df3064cf
      subodh authored
      Summary:
      SSLContext takes it upon itself to
      perform initialization of openssl along with
      cleaning it up.
      
      However in applications where there are multiple
      libraries using openssl, cleanup is not really
      desirable. Thus the application should own init
      and cleanup of openssl, rather than SSLContext.
      
      This is bad because openssl's init apis are not thread
      safe.
      
      This diff modifies SSLContext with 3 changes to
      make this possible in the context of apps:
      
      1. Add macro SSLCONTEXT_NO_REFCOUNT, for apps to be
      able to disable refcounting
      2. Move all steps of init into initializeOpenSSL.
      As a result, apps can choose when to call
      SSLContext::intitializeOpenSSL and if it has
      been called before, openssl will not be reinitialized.
      3. Move randomize as a static method to make it a part
      of the initialization process.
      
      Test Plan: Unit tests.
      
      Reviewed By: ranjeeth@fb.com
      
      Subscribers: ranjeeth, folly-diffs@, ssl-diffs@, njormrod, seanc, trunkagent, dihde
      
      FB internal diff: D1686397
      
      Signature: t1:1686397:1416270565:de805794d65af1c164ed334ff7ba93fe60b2b78a
      df3064cf
    • Nicholas Ormrod's avatar
      Fix build break · 832ecb9f
      Nicholas Ormrod authored
      Summary:
      Change counting index to unsigned to avoid unsigned-signed
      comparison errors.
      
      @build-break
      
      Test Plan:
      fbconfig -r folly && fbmake dbg
      fbmake runtests wangle
      
      Reviewed By: robbert@fb.com, davejwatson@fb.com
      
      Subscribers: sdwilsh, fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1686315
      
      Signature: t1:1686315:1416267974:d8f6075550b9d611790263338dd4f49e7ef451cc
      
      Blame Revision: D1595200
      832ecb9f
    • James Sedgwick's avatar
      Indefinite observers and inline observers · 55ee7359
      James Sedgwick authored
      Summary:
      provides new APIs observe(ObserverPtr<T>) and observe(Observer<T>*) that
      are not associated with a subscription. The latter method avoids allocations at the cost of disowning responsiblity for object lifetimes.
      
      It could be used for batch-allocating filter chains, for instance. I hacked up some recursive templates that would make that easy to do, but
      haven't included them. I'd rather see the first use case and then decide whether to let users set them up themselves or to provide an
      abstraction that makes it easier.
      
      Test Plan: unit
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: folly-diffs@, fugalh, njormrod
      
      FB internal diff: D1595200
      
      Tasks: 5002278
      
      Signature: t1:1595200:1416266578:95c0532af42443fd83e2f94d30790c3c0831ce65
      55ee7359
    • James Sedgwick's avatar
      OutputBufferingHandler · c3ee57ef
      James Sedgwick authored
      Summary:
      see D1618704 and D1604575
      Really need to make a decision about making a push for EventBaseManager everywhere. Getting/setting EBs when there's only ever one seems so silly, but in (e.g.) tests where one-off EBs are used without using the EBM, stuff like this will break.
      
      Test Plan: definitely compiles and sorta works, will write unit tests if the dust settles
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: folly-diffs@, trunkagent, fugalh, njormrod
      
      FB internal diff: D1618727
      c3ee57ef
    • Alex Landau's avatar
      CompactProtocol: readVarint optimizations · 923576ab
      Alex Landau authored
      Summary:
      * Unroll readVarint() - no loops in the fast path
      * Split Cursor::skip() into fast and slow paths
      
      Test Plan:
      ```
      ------ old ------   ------ new ------
      Benchmark                               time/iter  iters/s  time/iter  iters/s        win
      =========================================================================================
      CompactProtocol_read_Empty                13.21ns   75.69M    13.21ns   75.71M      0.03%
      CompactProtocol_read_SmallInt             29.95ns   33.39M    28.96ns   34.53M      3.41%
      CompactProtocol_read_BigInt               67.83ns   14.74M    36.77ns   27.19M     84.46%
      CompactProtocol_read_SmallString          55.72ns   17.95M    54.04ns   18.50M      3.06%
      CompactProtocol_read_BigString           342.93ns    2.92M   332.18ns    3.01M      3.08%
      CompactProtocol_read_BigBinary           186.18ns    5.37M   181.45ns    5.51M      2.61%
      CompactProtocol_read_LargeBinary         190.65ns    5.25M   184.85ns    5.41M      3.05%
      CompactProtocol_read_Mixed               101.97ns    9.81M    97.06ns   10.30M      4.99%
      CompactProtocol_read_SmallListInt        148.09ns    6.75M   139.52ns    7.17M      6.22%
      CompactProtocol_read_BigListInt           71.69us   13.95K    63.34us   15.79K     13.19%
      CompactProtocol_read_BigListMixed          1.26ms   790.67     1.18ms   845.66      6.95%
      CompactProtocol_read_LargeListMixed      139.80ms     7.15   134.68ms     7.42      3.78%
      ```
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1681244
      
      Signature: t1:1681244:1416265579:f630c53f9c31788f847d0af72198bbd9e5ea43f1
      923576ab
    • James Sedgwick's avatar
      implicit constructor exception_wrapper(std::exception) · a575384b
      James Sedgwick authored
      Summary: this should address some of the wordiness issues with exception_wrapper, i.e. always having to use make_exception_wrapper
      
      Test Plan: wrote a little test to make sure everything compiles (or doesn't) as expected, not worth committing
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1679460
      
      Signature: t1:1679460:1416265170:5cd72d95dd855cd4e594dbbc49d0c53d012fbc99
      a575384b
    • James Sedgwick's avatar
      fix potential race/memory corruption in IOThreadPoolExecutor · 0a14b4cc
      James Sedgwick authored
      Summary:
      In unusual but possible circumstances, the EventBase and thus pending tasks will outlive the pool, so we shouldn't keep references of any kind to the pool in the task.
      The only reference we were keeping was used to access the task stats rx subject. Store the subject as a shared ptr and give a copy of the ptr to the Thread object, which is itself
      owned by a shared ptr and captured by every task. I thought this had to do with the thread local leak in mentioned in the test plan of D1682860 but this patch doesn't actually fix that :(
      Thankfully, while task surfing I saw @phillip's awesome D1682698. Patching that in fixes the leak! Woo. Either way, this is more correct.
      
      Test Plan: unit under clang/asan
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@, philipp
      
      FB internal diff: D1683221
      
      Tasks: 5336655
      
      Signature: t1:1683221:1416264933:946d29b5a3eb22ed08812f2adefb7284b1899e4e
      0a14b4cc
    • James Sedgwick's avatar
      priority CPU thread pool · fe22c76c
      James Sedgwick authored
      Summary:
      just extend CPUThreadPoolExecutor to use a queue that is itself composed of N mpmc queues, one per priority
      
      the verbosity is starting to kill me, i had thought before of truncating Executor of all these pool types and now I'm definitely going to do that unless someone fights me.
      
      Test Plan: added unit; maybe i'm not being clever enough as i couldn't think of many ways to test this reliably so there's just a basic preemption test
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@, bmatheny
      
      FB internal diff: D1676452
      
      Tasks: 5002392
      
      Signature: t1:1676452:1416263990:cdf5d44e4a50a6180ba547a3ed4c0c24d4ffdd8f
      fe22c76c
    • Dave Watson's avatar
      Fix format bug · 146fda29
      Dave Watson authored
      Summary: Fix addition bug instead of string concat
      
      Test Plan: ?? It compiles?  The only call paths are when syscalls fail, it would be a lot of work to stub them out
      
      Reviewed By: mshneer@fb.com
      
      Subscribers: trunkagent, doug, njormrod, folly-diffs@
      
      FB internal diff: D1679713
      
      Tasks: 5604354
      
      Signature: t1:1679713:1415925209:ed05d3d1ce3e7e8db32c4afc86c5f24748d9c65b
      146fda29
    • Dave Watson's avatar
      Move Acceptor to wangle · dd280141
      Dave Watson authored
      Summary:
      Initial pass at moving acceptor to wangle.  Involves moving most of the config stuff from proxygen/lib/services, and *all* of the ssl stuff from proxygen/lib/ssl.
      
      Only minor changes:
      * Acceptor can be overriden to use thrift socket types, so I don't have to change TTransportException everywhere just yet
      * proxygen::Exception to std::runtime_exception in a few spots - looks like it is entirely bad config exceptions, so it should be okay
      * Just used std::chrono directly instead of stuff in Time.h (which is just typedefs and simple helpers)
      
      Test Plan:
      used in D1539327
      
      fbconfig -r proxygen/httpserver; fbmake runtests
      
      Probably other projects are broken, will iterate to fix
      
      None of the failling tests look related
      
      Reviewed By: dcsommer@fb.com
      
      Subscribers: oleksandr, netego-diffs@, hphp-diffs@, ps, trunkagent, doug, fugalh, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1638358
      
      Tasks: 5002353
      
      Signature: t1:1638358:1414526683:87a405e3c24711078707c00b62a50b0e960bf126
      dd280141
    • Philip Pronin's avatar
      fix potential memory leak in ThreadLocal · 81fa7fd7
      Philip Pronin authored
      Summary:
      See this LSan abort: https://phabricator.fb.com/P17233565.
      
      Destructor of the object stored in `folly::ThreadLocal` itself may be using
      `folly::ThreadLocal` with the same tag, with the current implementation these
      objects may escape cleanup happening on thread exit.
      
      Test Plan:
      _build/opt/folly/test/thread_local_test --gtest_filter=ThreadLocalPtr.CreateOnThreadExit
      
      Reviewed By: lucian@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1682698
      
      Tasks: 5596043
      
      Signature: t1:1682698:1416006810:100aaa5c17cecceeea568165d552d9d7907f38d0
      81fa7fd7
    • Alex Landau's avatar
      CompactProtocol: more improvements · 22b02d5f
      Alex Landau authored
      Summary:
      Add a specialized Cursor method that reads exactly 1 byte, in
      addition to the existing one that reads into a buffer. Use it when
      reading varints and standalone bytes in a CompactProtocol struct.
      
      Test Plan:
      ```
      ------ old ------   ------ new ------
      Benchmark                               time/iter  iters/s  time/iter  iters/s        win
      =========================================================================================
      CompactProtocol_read_Empty                18.68ns   53.54M    13.21ns   75.69M     41.37%
      CompactProtocol_read_SmallInt             42.60ns   23.47M    29.95ns   33.39M     42.27%
      CompactProtocol_read_BigInt               83.62ns   11.96M    68.40ns   14.62M     22.24%
      CompactProtocol_read_SmallString          67.33ns   14.85M    55.62ns   17.98M     21.08%
      CompactProtocol_read_BigString           353.83ns    2.83M   330.19ns    3.03M      7.07%
      CompactProtocol_read_BigBinary           190.82ns    5.24M   182.90ns    5.47M      4.39%
      CompactProtocol_read_LargeBinary         200.95ns    4.98M   187.00ns    5.35M      7.43%
      CompactProtocol_read_Mixed               137.42ns    7.28M   102.98ns    9.71M     33.38%
      CompactProtocol_read_SmallListInt        203.98ns    4.90M   146.68ns    6.82M     39.18%
      CompactProtocol_read_BigListInt          120.50us    8.30K    71.56us   13.97K     68.31%
      CompactProtocol_read_BigListMixed          1.62ms   617.07     1.26ms   795.60     28.93%
      CompactProtocol_read_LargeListMixed      177.50ms     5.63   140.73ms     7.11     26.29%
      ```
      
      Reviewed By: haijunz@fb.com
      
      Subscribers: trunkagent, alandau, bmatheny, njormrod, mshneer, folly-diffs@
      
      FB internal diff: D1678077
      
      Signature: t1:1678077:1415923409:22accee6b62b6e2bf471f3758a290f71978a8c4e
      22b02d5f
    • Andrii Grynenko's avatar
      folly::Singleton-based McrouterManager · 096bde27
      Andrii Grynenko authored
      Summary: Introduces a Singleton which keeps a map persistence_id => mcrouter_t*. Makes mcrouter instance not know if it's managed by McrouterManager.
      
      Test Plan: unit tests
      
      Reviewed By: pavlo@fb.com
      
      Subscribers: trunkagent, alikhtarov, njormrod, folly-diffs@
      
      FB internal diff: D1673274
      
      Signature: t1:1673274:1415735863:c990a6a526f9525c68cc23892d690a9b3cb94ace
      096bde27
    • Hans Fugal's avatar
      Have EventBase implement wangle::Executor · f22220e5
      Hans Fugal authored
      Summary:
      It already does the work (`runInEventBaseThread`) but it will now be convenient to pass an `EventBase` where wangle wants an `Executor`.
      
      Had to rip off the `boost::noncopyable` from `wangle::Executor` which is an interface and does not require non-copyability so that didn't really belong there in the first place I think. (Without this change, you get an obscure compiler error because of the double-inheritance from `boost::noncopyable`).
      
      Test Plan: Things build, tests pass
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: jsedgwick, trunkagent, fugalh, exa, njormrod, folly-diffs@, andrii
      
      FB internal diff: D1671500
      
      Signature: t1:1671500:1415727572:a7dba33c669ca122aecaee3c700f9e53e54838d1
      f22220e5
    • Nick Burrett's avatar
      folly::EventBase: wrap libevent calls to prevent race-condition · 3c34f066
      Nick Burrett authored
      Summary:
      Patch D1585087 exposes two flaws in EventBase().  It introduces IO
      worker threads to the ThriftServer which are constructed/destructed in
      parallel.
      
      Within the construction phase, a new EventBase() is instantiated for
      each thread and unwound in destruction.
      
      When using the BaseControllerTask (in Python), the following sequence
      is observed:
      
      a = event_init() [ThriftServer]
      b = event_init() [IO worker 1]
      c = event_init() [IO worker 2]
      ...
      event_base_free(c)
      event_base_free(b)
      event_base_free(a)  -> segfault
      
      1. event_init() should only ever be called once.  It internally
      modifies a global variable in libevent, current_base to match the
      return value.  event_base_free() will set current_base back to NULL if
      the passed in arg matches current_base.   Therefore subsequent calls
      must use event_base_new().
      
      2. Since current_base is a global and EventBase() is called by multiple
      threads, it is important to guard with a mutex.  The guard itself also
      exposed the bug because:
      
      a = event_init()  [current_base = a]
      b = event_init()  [current_base = b]
      ...
      event_base_free(b) [b == current_base -> current_base = NULL]
      
      So current_base ends up prematurely set to NULL.
      
      Test Plan:
      Run dba/core/daemons/dbstatus/dbstatus_tests.lpar, which no longer
      segfaults
      
      Reviewed By: jsedgwick@fb.com, davejwatson@fb.com
      
      Subscribers: dihde, evanelias, trunkagent, njormrod, ncoffield, lachlan, folly-diffs@
      
      FB internal diff: D1663654
      
      Tasks: 5545819
      
      Signature: t1:1663654:1415732265:d51c4c4cae99c1ac371460bf18d26d4f917a3c52
      
      Blame Revision: D1585087
      3c34f066
    • Alecs King's avatar
      Use folly::IPAddress::hash instead of gethostid · 05e80bad
      Alecs King authored
      Summary: find a non-loopback ipv4 or ipv6 address and feed it to folly::IPAddress::hash
      
      Test Plan:
      1)
      fbconfig -r mcrouter
      fbmake runtests
      
      2)
      compare hostids on different hosts
      
      Reviewed By: pavlo@fb.com
      
      Subscribers: njormrod, folly-diffs@, trunkagent, ps, bmatheny, alikhtarov
      
      FB internal diff: D1668944
      
      Tasks: 5557721
      
      Signature: t1:1668944:1415736928:fb4b042a575c0b00f52780f3abf54bf7630b3a97
      05e80bad
    • Dave Watson's avatar
      Clean up RequestContext · 84e83ecc
      Dave Watson authored
      Summary: Using a ThreadLocal cleans up the code quite a bit.  Also reuse the shared_ptr in create instead of creating a new one saves an allocation
      
      Test Plan:
      fbconfig thrift/lib/cpp/test:RequestContextTest; fbmake runtests
      
      fbconfig common/services/cpp/test:trace_test; fbmake runtests
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, doug, alandau, bmatheny, njormrod, mshneer, folly-diffs@, vloh
      
      FB internal diff: D1663960
      
      Signature: t1:1663960:1415390250:36d9b772016d2a12d804e98edbc1725af882e507
      84e83ecc
    • Dave Watson's avatar
      OS merges · fc7801ad
      Dave Watson authored
      Summary:
      All pretty trivial:
      
      https://github.com/facebook/folly/issues/99
      https://github.com/facebook/folly/issues/98
      https://github.com/facebook/folly/issues/45
      
      Test Plan: Will watch jenkins fbthrift build
      
      Reviewed By: dcsommer@fb.com
      
      Subscribers: doug, njormrod, folly-diffs@
      
      FB internal diff: D1669952
      
      Signature: t1:1669952:1415643677:906234f0a89f38645b0072d3c88762d8fa2729dc
      fc7801ad
    • Dmitry Panin's avatar
      Add optional parameter pruneHook to EvictingCacheMap::set(..) · 0318bad6
      Dmitry Panin authored
      Summary:
      Inside `set()` we can do pruning, but it will happen
      with default pruneHook.
      Adding it as an optional param makes API more convenient.
      (Instead, the users of API could just call `setPruneHook(pruneHook)` before `set`,
      and then `setPruneHook(nullptr)` afterwards -- but it looks too ugly)
      
      Test Plan:
      ```
      fbconfig -r folly/ && fbmake runtests
      ```
      passes:
      ```
      Summary (total time 60.11s):
      PASS: 1758
      FAIL: 0
      SKIP: 0
      FATAL: 0
      TIMEOUT: 0
      ```
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: trunkagent, agartrell, njormrod, folly-diffs@
      
      FB internal diff: D1665690
      
      Tasks: 5551091
      
      Signature: t1:1665690:1415391406:e4d2a956f9212aed70ab518159dbb19553764ce4
      0318bad6
  4. 08 Nov, 2014 5 commits
    • Pavlo Kushnir's avatar
      Bump version to 15:0 · 81e0e450
      Pavlo Kushnir authored
      81e0e450
    • Nicholas Ormrod's avatar
      Fix folly lint errors · d9b08663
      Nicholas Ormrod authored
      Summary:
      Fix EOF whitespace
      for file in `find folly -type f` ; do if [ -z "`tail -n1 $file`" ] ; then sed -i '$d' $file ; fi ; done
      
      Test Plan: unit tests
      
      Reviewed By: robbert@fb.com
      
      Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@
      
      FB internal diff: D1644130
      
      Tasks: 5486739
      
      Signature: t1:1644130:1414715392:b6c783851aa030ad1148f84a98139a5dca207da0
      d9b08663
    • Misha Shneerson's avatar
      isDetachable for HHWheelTimer · a082ba98
      Misha Shneerson authored
      Summary: title
      
      Test Plan: unit tests
      
      Reviewed By: andrei.bajenov@fb.com
      
      Subscribers: trunkagent, mcduff, hitesh, alandau, bmatheny, njormrod, mshneer, folly-diffs@, andreib, davejwatson
      
      FB internal diff: D1666499
      
      Tasks: 5563183
      
      Signature: t1:1666499:1415347256:d58c8bbe952385c1c96f7f8cc6ae7f02216c56bb
      a082ba98
    • Dave Watson's avatar
      Move SSL socket to folly · ff9b70f3
      Dave Watson authored
      Summary: One of the last thrift -> folly moves.  The only change was the exception types - there are small wrapper classes in thrift/lib/cpp/async left to convert from AsyncSocketException to TTransportException.
      
      Test Plan: run unit tests
      
      Reviewed By: dcsommer@fb.com
      
      Subscribers: jdperlow, trunkagent, doug, bmatheny, ssl-diffs@, njormrod, mshneer, folly-diffs@, fugalh, jsedgwick, andrewcox, alandau
      
      FB internal diff: D1632425
      
      Signature: t1:1632425:1414526483:339ae107bacb073bdd8cf0942fd0f6b70990feb4
      ff9b70f3
    • Tom Jackson's avatar
      Remove volatile from MemoryMappingTest · a91ed7e3
      Tom Jackson authored
      Summary: Not needed, I don't know why I put them there before.
      
      Test Plan: Run the unit test
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1665689
      
      Tasks: 5487902
      
      Signature: t1:1665689:1415323144:0998e7f700a3b40652615a36c3b9c9f661fbdadf
      a91ed7e3