fix some bugs in AsyncSSLSocketTest
authorAdam Simpkins <simpkins@fb.com>
Wed, 17 Jan 2018 18:05:22 +0000 (10:05 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 17 Jan 2018 18:20:41 +0000 (10:20 -0800)
commitbdd9360c598d80d524de6780cd5be65af56d98fd
tree1bf52d3b24dbafd7f72d52fc48b8509fcaf9e86c
parent7da4ef82aee382777bb50aadd4af14a482739d10
fix some bugs in AsyncSSLSocketTest

Summary:
A couple of the test functions in AsyncSSLSocketTest maintained two EventBase
objects and alternated looping between them.  In some cases it would call
EventBase::loopOnce() even when there was no work to do.  This call normally
blocks until an event is ready.  This happened to work when using libevent1,
but this appears mostly accidental: with libevent1 EVLOOP_ONCE causes the loop
to break out even after an "internal" I/O event; in libevent2 EVLOOP_ONCE only
breaks out after a non-internal event has occurred:
https://github.com/libevent/libevent/commit/0617a818204397790e5e4c9bcb9e91ae5ea7817a

In these tests it turns out that the internal EventBase NotificationQueue
always gets triggered the very first time loopOnce() is called, preventing
these tests from hanging when using libevent1.

This fixes the hang when using libevent2 by removing the initial loopOnce()
calls that potentially have nothing to do.  This also consolidates the 2
EventBase objects into one to avoid having to alternate loopOnce() calls
between them without knowing which one actually has work to do.

This also fixes an issue where the code never checked the return value of
`recv()`

Reviewed By: yfeldblum, siyengar

Differential Revision: D6735669

fbshipit-source-id: 5f36106a08866aa8908e82263f83a606399cdf79
folly/io/async/test/AsyncSSLSocketTest.cpp