Make AsioExternalThreadEvent::abandon() not hit assertion error
Destructor of AsioExternalThreadEvent uses assert() to check whether the state is legal. Introduction of abandon() mechanism makes it possible to destroy the AsioExternalThreadEvent in the Waiting state and hit the assertion error. This diff solves the problem by introducing Abandoned state.
Esse commit está contido em:
@@ -15,9 +15,9 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/runtime/ext/asio/asio_external_thread_event.h"
|
||||
#include <thread>
|
||||
#include "hphp/runtime/ext/ext_asio.h"
|
||||
#include "hphp/runtime/ext/asio/asio_external_thread_event.h"
|
||||
#include "hphp/runtime/ext/asio/asio_session.h"
|
||||
|
||||
namespace HPHP {
|
||||
@@ -32,6 +32,7 @@ AsioExternalThreadEvent::AsioExternalThreadEvent(ObjectData* priv_data)
|
||||
void AsioExternalThreadEvent::abandon() {
|
||||
assert(m_state.load() == Waiting);
|
||||
assert(m_waitHandle->getCount() == 1);
|
||||
m_state.store(Abandoned);
|
||||
m_waitHandle->abandon(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,11 @@ class AsioExternalThreadEvent {
|
||||
* is eventually called.
|
||||
*/
|
||||
virtual ~AsioExternalThreadEvent() {
|
||||
assert(m_state.load() == Finished || m_state.load() == Canceled);
|
||||
assert(
|
||||
m_state.load() == Finished ||
|
||||
m_state.load() == Canceled ||
|
||||
m_state.load() == Abandoned
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -267,6 +271,14 @@ class AsioExternalThreadEvent {
|
||||
* eventually calling markAsFinished() that will destruct this object.
|
||||
*/
|
||||
Canceled,
|
||||
|
||||
/**
|
||||
* Web request thread abandoned event before passing to processing thread.
|
||||
*
|
||||
* This object is owned by web request thread, which is trying to abandon
|
||||
* it prior to passing ownership to processing thread.
|
||||
*/
|
||||
Abandoned,
|
||||
};
|
||||
|
||||
AsioSession* m_session;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário