Fixed race between {stop(), abort()} and join() in the scheduler driver.
Fixed race between {stop(), abort()} and join() in the scheduler driver.

Previously, it was possible for join() to return before a schedDriver
was actually fully stopped or aborted (breaking the semantics of the
join() call). The race came from a short circuit in join(), which
simply checked for status != DRIVER_RUNNING before returning. It appears
this short circuit was introduced to handle cases where initialize() or
start() ended up aborting before ever starting the driver to begin with.
However, it unintentionally covers cases where stop() or abort() were
called *after* the driver started running as well.

The problem is that stop() and abort() will change the status
to DRIVER_STOPPED or DRIVER_ABORTED before actually processing
dispatched stop or abort events (which happen asynchronously in a
libprocess thread). Under normal operation, join() would wait for these
events to trigger a latch that allowed the join() call to return.
However, with the short circuit, join() exits immediately even if the
libprocess thread hasn't yet processed the stop() or abort() events.

This commit fixes the semantics of the join() call to avoid this race.
We considered removing the latch completely and replacing it with
process.wait(), but, unlike the latch, this wouldn't ensure that stop()
or abort() was ever called in the first place.

Review: https://reviews.apache.org/r/42519/

yuquanshan/customizedMesos,verizonlabs/mesos,Aman-Jain-14/customizedMesos,kaysoky/mesos,zmalik/mesos,asamerh4/mesos,Aman-Jain-14/customizedMesos,reneploetz/mesos,andschwa/mesos,asamerh4/mesos,dforsyth/mesos,asamerh4/mesos,neilconway/mesos,chhsia0/mesos,verizonlabs/mesos,chhsia0/mesos,neilconway/mesos,zmalik/mesos,gsantovena/mesos,dforsyth/mesos,asamerh4/mesos,gsantovena/mesos,Gilbert88/mesos,jpeach/mesos,reneploetz/mesos,asamerh4/mesos,andschwa/mesos,gsantovena/mesos,craimbert/mesos,reneploetz/mesos,abudnik/mesos,dforsyth/mesos,abudnik/mesos,kaysoky/mesos,andschwa/mesos,yuquanshan/customizedMesos,zmalik/mesos,yuquanshan/customizedMesos,zmalik/mesos,chhsia0/mesos,neilconway/mesos,verizonlabs/mesos,neilconway/mesos,craimbert/mesos,chhsia0/mesos,reneploetz/mesos,reneploetz/mesos,verizonlabs/mesos,chhsia0/mesos,dforsyth/mesos,Aman-Jain-14/customizedMesos,craimbert/mesos,chhsia0/mesos,craimbert/mesos,reneploetz/mesos,kaysoky/mesos,kaysoky/mesos,gsantovena/mesos,Gilbert88/mesos,Aman-Jain-14/customizedMesos,neilconway/mesos,abudnik/mesos,zmalik/mesos,chhsia0/mesos,jpeach/mesos,asamerh4/mesos,yuquanshan/customizedMesos,dforsyth/mesos,verizonlabs/mesos,Aman-Jain-14/customizedMesos,verizonlabs/mesos,jpeach/mesos,craimbert/mesos,yuquanshan/customizedMesos,zmalik/mesos,jpeach/mesos,abudnik/mesos,gsantovena/mesos,Aman-Jain-14/customizedMesos,andschwa/mesos,Gilbert88/mesos,gsantovena/mesos,jpeach/mesos,kaysoky/mesos,zmalik/mesos,dforsyth/mesos,kaysoky/mesos,neilconway/mesos,abudnik/mesos,reneploetz/mesos,Gilbert88/mesos,dforsyth/mesos,craimbert/mesos,Aman-Jain-14/customizedMesos,Gilbert88/mesos,gsantovena/mesos,verizonlabs/mesos,abudnik/mesos,neilconway/mesos,andschwa/mesos,craimbert/mesos,Gilbert88/mesos,andschwa/mesos,yuquanshan/customizedMesos,andschwa/mesos,kaysoky/mesos,abudnik/mesos,jpeach/mesos,yuquanshan/customizedMesos,jpeach/mesos,Gilbert88/mesos,asamerh4/mesos