Fix ext_asio callback checks
The callback passed to asio_set_on_{failed, started}_callback was
never null because the way types for input parameters work in
extensions. Null from user PHP code was converted to a stdClass
object, triggering an exception.
Esse commit está contido em:
@@ -139,7 +139,7 @@ DefineFunction(
|
||||
'args' => array(
|
||||
array(
|
||||
'name' => "on_failed_cb",
|
||||
'type' => Object,
|
||||
'type' => Variant,
|
||||
'desc' => "A Closure to be called when wait handle fails",
|
||||
),
|
||||
),
|
||||
@@ -156,7 +156,7 @@ DefineFunction(
|
||||
'args' => array(
|
||||
array(
|
||||
'name' => "on_started_cb",
|
||||
'type' => Object,
|
||||
'type' => Variant,
|
||||
'desc' => "A Closure to be called when wait handle is started",
|
||||
),
|
||||
),
|
||||
|
||||
@@ -63,24 +63,24 @@ Object f_asio_get_current() {
|
||||
return AsioSession::Get()->getCurrentWaitHandle();
|
||||
}
|
||||
|
||||
void f_asio_set_on_failed_callback(CObjRef on_failed_cb) {
|
||||
void f_asio_set_on_failed_callback(CVarRef on_failed_cb) {
|
||||
if (!on_failed_cb.isNull() && !on_failed_cb.instanceof(c_Closure::s_cls)) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Unable to set asio on failed callback: on_failed_cb not a closure"));
|
||||
throw e;
|
||||
}
|
||||
|
||||
AsioSession::Get()->setOnFailedCallback(on_failed_cb.get());
|
||||
AsioSession::Get()->setOnFailedCallback(on_failed_cb.getObjectDataOrNull());
|
||||
}
|
||||
|
||||
void f_asio_set_on_started_callback(CObjRef on_started_cb) {
|
||||
void f_asio_set_on_started_callback(CVarRef on_started_cb) {
|
||||
if (!on_started_cb.isNull() && !on_started_cb.instanceof(c_Closure::s_cls)) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Unable to set asio on started callback: on_started_cb not a closure"));
|
||||
throw e;
|
||||
}
|
||||
|
||||
AsioSession::Get()->setOnStartedCallback(on_started_cb.get());
|
||||
AsioSession::Get()->setOnStartedCallback(on_started_cb.getObjectDataOrNull());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -241,42 +241,25 @@ TypedValue* fg_asio_get_current(HPHP::VM::ActRec *ar) {
|
||||
|
||||
|
||||
/*
|
||||
void HPHP::f_asio_set_on_failed_callback(HPHP::Object const&)
|
||||
_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_6ObjectE
|
||||
void HPHP::f_asio_set_on_failed_callback(HPHP::Variant const&)
|
||||
_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_7VariantE
|
||||
|
||||
on_failed_cb => rdi
|
||||
*/
|
||||
|
||||
void fh_asio_set_on_failed_callback(Value* on_failed_cb) asm("_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_6ObjectE");
|
||||
|
||||
TypedValue * fg1_asio_set_on_failed_callback(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold));
|
||||
TypedValue * fg1_asio_set_on_failed_callback(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) {
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
rv->m_data.num = 0LL;
|
||||
rv->m_type = KindOfNull;
|
||||
tvCastToObjectInPlace(args-0);
|
||||
fh_asio_set_on_failed_callback((Value*)(args-0));
|
||||
return rv;
|
||||
}
|
||||
void fh_asio_set_on_failed_callback(TypedValue* on_failed_cb) asm("_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_7VariantE");
|
||||
|
||||
TypedValue* fg_asio_set_on_failed_callback(HPHP::VM::ActRec *ar) {
|
||||
TypedValue rv;
|
||||
int64_t count = ar->numArgs();
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
if (count == 1LL) {
|
||||
if ((args-0)->m_type == KindOfObject) {
|
||||
rv.m_data.num = 0LL;
|
||||
rv.m_type = KindOfNull;
|
||||
fh_asio_set_on_failed_callback((Value*)(args-0));
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
} else {
|
||||
fg1_asio_set_on_failed_callback(&rv, ar, count);
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
}
|
||||
rv.m_data.num = 0LL;
|
||||
rv.m_type = KindOfNull;
|
||||
fh_asio_set_on_failed_callback((args-0));
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
} else {
|
||||
throw_wrong_arguments_nr("asio_set_on_failed_callback", count, 1, 1, 1);
|
||||
}
|
||||
@@ -291,42 +274,25 @@ TypedValue* fg_asio_set_on_failed_callback(HPHP::VM::ActRec *ar) {
|
||||
|
||||
|
||||
/*
|
||||
void HPHP::f_asio_set_on_started_callback(HPHP::Object const&)
|
||||
_ZN4HPHP30f_asio_set_on_started_callbackERKNS_6ObjectE
|
||||
void HPHP::f_asio_set_on_started_callback(HPHP::Variant const&)
|
||||
_ZN4HPHP30f_asio_set_on_started_callbackERKNS_7VariantE
|
||||
|
||||
on_started_cb => rdi
|
||||
*/
|
||||
|
||||
void fh_asio_set_on_started_callback(Value* on_started_cb) asm("_ZN4HPHP30f_asio_set_on_started_callbackERKNS_6ObjectE");
|
||||
|
||||
TypedValue * fg1_asio_set_on_started_callback(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold));
|
||||
TypedValue * fg1_asio_set_on_started_callback(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) {
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
rv->m_data.num = 0LL;
|
||||
rv->m_type = KindOfNull;
|
||||
tvCastToObjectInPlace(args-0);
|
||||
fh_asio_set_on_started_callback((Value*)(args-0));
|
||||
return rv;
|
||||
}
|
||||
void fh_asio_set_on_started_callback(TypedValue* on_started_cb) asm("_ZN4HPHP30f_asio_set_on_started_callbackERKNS_7VariantE");
|
||||
|
||||
TypedValue* fg_asio_set_on_started_callback(HPHP::VM::ActRec *ar) {
|
||||
TypedValue rv;
|
||||
int64_t count = ar->numArgs();
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
if (count == 1LL) {
|
||||
if ((args-0)->m_type == KindOfObject) {
|
||||
rv.m_data.num = 0LL;
|
||||
rv.m_type = KindOfNull;
|
||||
fh_asio_set_on_started_callback((Value*)(args-0));
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
} else {
|
||||
fg1_asio_set_on_started_callback(&rv, ar, count);
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
}
|
||||
rv.m_data.num = 0LL;
|
||||
rv.m_type = KindOfNull;
|
||||
fh_asio_set_on_started_callback((args-0));
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
} else {
|
||||
throw_wrong_arguments_nr("asio_set_on_started_callback", count, 1, 1, 1);
|
||||
}
|
||||
|
||||
@@ -73,22 +73,22 @@ _rv => rdi
|
||||
Value* fh_asio_get_current(Value* _rv) asm("_ZN4HPHP18f_asio_get_currentEv");
|
||||
|
||||
/*
|
||||
void HPHP::f_asio_set_on_failed_callback(HPHP::Object const&)
|
||||
_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_6ObjectE
|
||||
void HPHP::f_asio_set_on_failed_callback(HPHP::Variant const&)
|
||||
_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_7VariantE
|
||||
|
||||
on_failed_cb => rdi
|
||||
*/
|
||||
|
||||
void fh_asio_set_on_failed_callback(Value* on_failed_cb) asm("_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_6ObjectE");
|
||||
void fh_asio_set_on_failed_callback(TypedValue* on_failed_cb) asm("_ZN4HPHP29f_asio_set_on_failed_callbackERKNS_7VariantE");
|
||||
|
||||
/*
|
||||
void HPHP::f_asio_set_on_started_callback(HPHP::Object const&)
|
||||
_ZN4HPHP30f_asio_set_on_started_callbackERKNS_6ObjectE
|
||||
void HPHP::f_asio_set_on_started_callback(HPHP::Variant const&)
|
||||
_ZN4HPHP30f_asio_set_on_started_callbackERKNS_7VariantE
|
||||
|
||||
on_started_cb => rdi
|
||||
*/
|
||||
|
||||
void fh_asio_set_on_started_callback(Value* on_started_cb) asm("_ZN4HPHP30f_asio_set_on_started_callbackERKNS_6ObjectE");
|
||||
void fh_asio_set_on_started_callback(TypedValue* on_started_cb) asm("_ZN4HPHP30f_asio_set_on_started_callbackERKNS_7VariantE");
|
||||
|
||||
|
||||
} // !HPHP
|
||||
|
||||
@@ -30,8 +30,8 @@ int f_asio_get_current_context_idx();
|
||||
Object f_asio_get_running_in_context(int ctx_idx);
|
||||
Object f_asio_get_running();
|
||||
Object f_asio_get_current();
|
||||
void f_asio_set_on_failed_callback(CObjRef on_failed_cb);
|
||||
void f_asio_set_on_started_callback(CObjRef on_failed_cb);
|
||||
void f_asio_set_on_failed_callback(CVarRef on_failed_cb);
|
||||
void f_asio_set_on_started_callback(CVarRef on_started_cb);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// class WaitHandle
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
"asio_get_running_in_context", T(Object), S(0), "ctx_idx", T(Int32), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-get-running-in-context.php )\n *\n * Get currently running wait handle in a context specified by its index\n *\n * @ctx_idx int An index of a specified context\n *\n * @return object A ContinuationWaitHandle that is running in a\n * specified context\n */",
|
||||
"asio_get_running", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/function.asio-get-running.php )\n *\n * Get currently running wait handle, or null if there is none\n *\n * @return object A ContinuationWaitHandle that is running in the\n * current context\n */",
|
||||
"asio_get_current", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/function.asio-get-current.php )\n *\n * DEPRECATED: use asio_get_running\n *\n * @return object A ContinuationWaitHandle that is running in the\n * current context\n */",
|
||||
"asio_set_on_failed_callback", T(Void), S(0), "on_failed_cb", T(Object), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-set-on-failed-callback.php )\n *\n * Set callback to be called when wait handle fails\n *\n * @on_failed_cb\n * object A Closure to be called when wait handle fails\n */",
|
||||
"asio_set_on_failed_callback", T(Void), S(0), "on_failed_cb", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-set-on-failed-callback.php )\n *\n * Set callback to be called when wait handle fails\n *\n * @on_failed_cb\n * mixed A Closure to be called when wait handle fails\n */",
|
||||
"asio_set_on_started_callback", T(Void), S(0), "on_started_cb", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-set-on-started-callback.php )\n *\n * Set callback to be called when a continuation is started\n *\n * @on_started_cb\n * mixed A Closure to be called when wait handle is started\n */",
|
||||
|
||||
#elif EXT_TYPE == 1
|
||||
|
||||
#elif EXT_TYPE == 2
|
||||
"WaitHandle", "", "awaitable",NULL, "__construct", T(Void), S(0), NULL, S(16640), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.construct.php )\n *\n *\n */", S(16640),"import", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.import.php )\n *\n * Import this wait handle to the current scheduler context\n *\n */", S(16384),"getWaitHandle", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.getwaithandle.php )\n *\n * Start this wait handle to the current scheduler context\n *\n * @return object\n */", S(16384),"join", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.join.php )\n *\n * Wait until this wait handle is finished and return its result (operates\n * in a new scheduler context)\n *\n * @return mixed A result of the operation represented by given wait\n * handle\n */", S(16384),"isFinished", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.isfinished.php )\n *\n * Check if this wait handle finished (succeeded or failed)\n *\n * @return bool A boolean indicating whether this wait handle\n * finished\n */", S(16384),"isSucceeded", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.issucceeded.php )\n *\n * Check if this wait handle succeeded\n *\n * @return bool A boolean indicating whether this wait handle\n * succeeded\n */", S(16384),"isFailed", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.isfailed.php )\n *\n * Check if this wait handle failed\n *\n * @return bool A boolean indicating whether this wait handle failed\n */", S(16384),"getID", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.getid.php )\n *\n * Get unique ID of this wait handle (amongst existing ones)\n *\n * @return int An integer representing unique ID of this wait\n * handle\n */", S(16384),"getName", T(String), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.getname.php )\n *\n * Get name of the operation behind this wait handle\n *\n * @return string A name of the operation behind this wait handle\n */", S(16384),"getExceptionIfFailed", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/waithandle.getexceptioniffailed.php )\n *\n * Get exception if this wait handle has failed, or null\n *\n * @return object An exception if this wait handle has failed, or null\n */", S(16384),NULL,NULL,NULL,
|
||||
"WaitHandle", "", "awaitable",NULL, "__construct", T(Void), S(0), NULL, S(16640), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.construct.php )\n *\n *\n */", S(16640),"getWaitHandle", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.getwaithandle.php )\n *\n * Return this wait handle (for Awaitable interface)\n *\n * @return object\n */", S(16384),"import", T(Void), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.import.php )\n *\n * Import this wait handle to the current scheduler context\n *\n */", S(16384),"join", T(Variant), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.join.php )\n *\n * Wait until this wait handle is finished and return its result (operates\n * in a new scheduler context)\n *\n * @return mixed A result of the operation represented by given wait\n * handle\n */", S(16384),"isFinished", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.isfinished.php )\n *\n * Check if this wait handle finished (succeeded or failed)\n *\n * @return bool A boolean indicating whether this wait handle\n * finished\n */", S(16384),"isSucceeded", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.issucceeded.php )\n *\n * Check if this wait handle succeeded\n *\n * @return bool A boolean indicating whether this wait handle\n * succeeded\n */", S(16384),"isFailed", T(Boolean), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.isfailed.php )\n *\n * Check if this wait handle failed\n *\n * @return bool A boolean indicating whether this wait handle failed\n */", S(16384),"getID", T(Int64), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.getid.php )\n *\n * Get unique ID of this wait handle (amongst existing ones)\n *\n * @return int An integer representing unique ID of this wait\n * handle\n */", S(16384),"getName", T(String), S(0), NULL, S(16384), "/**\n * ( excerpt from http://php.net/manual/en/waithandle.getname.php )\n *\n * Get name of the operation behind this wait handle\n *\n * @return string A name of the operation behind this wait handle\n */", S(16384),"getExceptionIfFailed", T(Object), S(0), NULL, S(16384), "/**\n * ( excerpt from\n * http://php.net/manual/en/waithandle.getexceptioniffailed.php )\n *\n * Get exception if this wait handle has failed, or null\n *\n * @return object An exception if this wait handle has failed, or null\n */", S(16384),NULL,NULL,NULL,
|
||||
S(17424), "/**\n * ( excerpt from http://php.net/manual/en/class.waithandle.php )\n *\n * A wait handle representing asynchronous operation\n *\n */", "StaticWaitHandle", "waithandle", NULL, "__construct", T(Void), S(0), NULL, S(16640), "/**\n * ( excerpt from http://php.net/manual/en/staticwaithandle.construct.php )\n *\n *\n */", S(16640),NULL,NULL,NULL,
|
||||
S(17424), "/**\n * ( excerpt from http://php.net/manual/en/class.staticwaithandle.php )\n *\n * A wait handle that is always finished\n *\n */", "StaticResultWaitHandle", "staticwaithandle", NULL, "__construct", T(Void), S(0), NULL, S(16640), "/**\n * ( excerpt from\n * http://php.net/manual/en/staticresultwaithandle.construct.php )\n *\n *\n */", S(16640),"create", T(Object), S(0), "result", T(Variant), NULL, S(0), NULL, S(0), NULL, S(16896), "/**\n * ( excerpt from\n * http://php.net/manual/en/staticresultwaithandle.create.php )\n *\n * Create a wait handle that always succeeds with a given result\n *\n * @result mixed A result wait handle will succeed with\n *\n * @return object A StaticResultWaitHandle representing given result\n */", S(16896),NULL,NULL,NULL,
|
||||
S(16384), "/**\n * ( excerpt from http://php.net/manual/en/class.staticresultwaithandle.php\n * )\n *\n * A wait handle representing static result\n *\n */", "StaticExceptionWaitHandle", "staticwaithandle", NULL, "__construct", T(Void), S(0), NULL, S(16640), "/**\n * ( excerpt from\n * http://php.net/manual/en/staticexceptionwaithandle.construct.php )\n *\n *\n */", S(16640),"create", T(Object), S(0), "exception", T(Object), NULL, S(0), NULL, S(0), NULL, S(16896), "/**\n * ( excerpt from\n * http://php.net/manual/en/staticexceptionwaithandle.create.php )\n *\n * Create a wait handle that always fails with a given exception\n *\n * @exception object An exception wait handle will fail with\n *\n * @return object A StaticExceptionWaitHandle representing given\n * exception\n */", S(16896),NULL,NULL,NULL,
|
||||
|
||||
@@ -7505,14 +7505,14 @@ const char *g_class_map[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "asio_set_on_failed_callback", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-set-on-failed-callback.php )\n *\n * Set callback to be called when wait handle fails\n *\n * @on_failed_cb\n * object A Closure to be called when wait handle fails\n */",
|
||||
(const char *)-1, (const char *)0x2000, "on_failed_cb", "", (const char *)0x40, "", "", NULL,
|
||||
"/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-set-on-failed-callback.php )\n *\n * Set callback to be called when wait handle fails\n *\n * @on_failed_cb\n * mixed A Closure to be called when wait handle fails\n */",
|
||||
(const char *)-1, (const char *)0x2000, "on_failed_cb", "", (const char *)0xffffffff, "", "", NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "asio_set_on_started_callback", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-set-on-started-callback.php )\n *\n * Set callback to be called when a continuation is started\n *\n * @on_started_cb\n * object A Closure to be called when wait handle is started\n */",
|
||||
(const char *)-1, (const char *)0x2000, "on_started_cb", "", (const char *)0x40, "", "", NULL,
|
||||
"/**\n * ( excerpt from\n * http://php.net/manual/en/function.asio-set-on-started-callback.php )\n *\n * Set callback to be called when a continuation is started\n *\n * @on_started_cb\n * mixed A Closure to be called when wait handle is started\n */",
|
||||
(const char *)-1, (const char *)0x2000, "on_started_cb", "", (const char *)0xffffffff, "", "", NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário