Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-php-sdk
提交
c89dac92
S
SkyAPM-php-sdk
项目概览
SkyAPM
/
SkyAPM-php-sdk
通知
14
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyAPM-php-sdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c89dac92
编写于
12月 17, 2018
作者:
H
heyanlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
curl_setopt_array
上级
37f9d751
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
81 addition
and
10 deletion
+81
-10
sky-php7ext/php_skywalking.h
sky-php7ext/php_skywalking.h
+3
-0
sky-php7ext/skywalking.c
sky-php7ext/skywalking.c
+78
-10
未找到文件。
sky-php7ext/php_skywalking.h
浏览文件 @
c89dac92
...
@@ -128,6 +128,8 @@ static void write_log( char *text);
...
@@ -128,6 +128,8 @@ static void write_log( char *text);
static
void
request_init
();
static
void
request_init
();
void
sky_curl_exec_handler
(
INTERNAL_FUNCTION_PARAMETERS
);
void
sky_curl_exec_handler
(
INTERNAL_FUNCTION_PARAMETERS
);
void
sky_curl_setopt_handler
(
INTERNAL_FUNCTION_PARAMETERS
);
void
sky_curl_setopt_array_handler
(
INTERNAL_FUNCTION_PARAMETERS
);
static
void
sky_flush_all
();
static
void
sky_flush_all
();
static
zval
*
get_first_span
();
static
zval
*
get_first_span
();
...
@@ -135,6 +137,7 @@ static zval *get_spans();
...
@@ -135,6 +137,7 @@ static zval *get_spans();
static
char
*
_get_current_machine_ip
();
static
char
*
_get_current_machine_ip
();
static
void
(
*
orig_curl_exec
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
static
void
(
*
orig_curl_exec
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
static
void
(
*
orig_curl_setopt
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
static
void
(
*
orig_curl_setopt
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
static
void
(
*
orig_curl_setopt_array
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
/*
/*
Declare any global variables you may need between the BEGIN
Declare any global variables you may need between the BEGIN
and END macros here:
and END macros here:
...
...
sky-php7ext/skywalking.c
浏览文件 @
c89dac92
...
@@ -217,20 +217,31 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
...
@@ -217,20 +217,31 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
char
headers_string
[
500
];
char
headers_string
[
500
];
sprintf
(
headers_string
,
"sw3: %s"
,
sw3
);
sprintf
(
headers_string
,
"sw3: %s"
,
sw3
);
// //send setopt header
// //send setopt header
zend_ulong
key
=
(
zend_ulong
)
Z_RES_VAL_P
(
zid
);
zend_ulong
key
=
(
zend_ulong
)
Z_RES_VAL_P
(
zid
);
zval
*
current_header
=
zend_hash_index_find
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
);
zval
*
current_header
=
zend_hash_index_find
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
);
if
(
current_header
==
NULL
)
{
if
(
current_header
==
NULL
)
{
zend_hash_index_add
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
,
&
opt
);
zval
_temp
;
array_init
(
&
_temp
);
add_assoc_long
(
&
_temp
,
"exec_call"
,
1
);
add_assoc_zval
(
&
_temp
,
"header"
,
&
opt
);
zend_hash_index_add
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
,
&
_temp
);
add_next_index_string
(
&
opt
,
headers_string
);
add_next_index_string
(
&
opt
,
headers_string
);
}
else
{
}
else
{
zend_long
_key
;
zend_long
_key
;
zval
*
_value
;
zval
*
_value
;
add_next_index_string
(
&
opt
,
headers_string
);
add_next_index_string
(
&
opt
,
headers_string
);
ZEND_HASH_FOREACH_NUM_KEY_VAL
(
Z_ARRVAL_P
(
current_header
),
_key
,
_value
)
{
zval
exec_send
;
ZVAL_LONG
(
&
exec_send
,
1
);
zend_hash_str_update
(
Z_ARRVAL_P
(
current_header
),
"exec_call"
,
sizeof
(
"exec_call"
)
-
1
,
&
exec_send
);
zval_dtor
(
&
exec_send
);
zval
*
header_entry
=
zend_hash_str_find
(
Z_ARRVAL_P
(
current_header
),
"header"
,
sizeof
(
"header"
)
-
1
);
ZEND_HASH_FOREACH_NUM_KEY_VAL
(
Z_ARRVAL_P
(
header_entry
),
_key
,
_value
)
{
add_next_index_string
(
&
opt
,
Z_STRVAL_P
(
_value
));
add_next_index_string
(
&
opt
,
Z_STRVAL_P
(
_value
));
}
ZEND_HASH_FOREACH_END
();
}
ZEND_HASH_FOREACH_END
();
}
}
zval
f_name
,
p
[
3
];
zval
f_name
,
p
[
3
];
...
@@ -298,21 +309,74 @@ void sky_curl_setopt_handler(INTERNAL_FUNCTION_PARAMETERS) {
...
@@ -298,21 +309,74 @@ void sky_curl_setopt_handler(INTERNAL_FUNCTION_PARAMETERS) {
}
}
if
(
CURLOPT_HTTPHEADER
==
options
)
{
if
(
CURLOPT_HTTPHEADER
==
options
)
{
if
(
Z_TYPE_P
(
zvalue
)
!=
IS_ARRAY
)
{
if
(
Z_TYPE_P
(
zvalue
)
!=
IS_ARRAY
)
{
return
;
return
;
}
}
zend_ulong
key
=
(
zend_ulong
)
Z_RES_VAL_P
(
zid
);
zend_ulong
key
=
(
zend_ulong
)
Z_RES_VAL_P
(
zid
);
zval
*
current_header
=
zend_hash_index_find
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
);
zval
*
current_header
=
zend_hash_index_find
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
);
if
(
current_header
==
NULL
)
{
if
(
current_header
==
NULL
)
{
zend_hash_index_add
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
,
zvalue
);
zval
temp
;
array_init
(
&
temp
);
add_assoc_long
(
&
temp
,
"exec_call"
,
0
);
add_assoc_zval
(
&
temp
,
"header"
,
zvalue
);
zend_hash_index_add
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
,
&
temp
);
}
else
{
}
else
{
zval
*
exec_call
=
zend_hash_str_find
(
Z_ARRVAL_P
(
current_header
),
"exec_call"
,
sizeof
(
"exec_call"
)
-
1
);
if
(
Z_LVAL_P
(
exec_call
)
==
1
)
{
php_var_dump
(
zvalue
,
0
);
orig_curl_setopt
(
INTERNAL_FUNCTION_PARAM_PASSTHRU
);
orig_curl_setopt
(
INTERNAL_FUNCTION_PARAM_PASSTHRU
);
}
else
{
zend_string
*
header
=
zend_string_init
(
"header"
,
sizeof
(
"header"
)
-
1
,
0
);
zend_hash_update
(
Z_ARRVAL_P
(
current_header
),
header
,
zvalue
);
zend_string_release
(
header
);
}
}
}
}
else
{
}
else
{
orig_curl_setopt
(
INTERNAL_FUNCTION_PARAM_PASSTHRU
);
orig_curl_setopt
(
INTERNAL_FUNCTION_PARAM_PASSTHRU
);
}
}
}
}
void
sky_curl_setopt_array_handler
(
INTERNAL_FUNCTION_PARAMETERS
)
{
zval
*
zid
,
*
arr
,
*
entry
;
zend_ulong
option
;
zend_string
*
string_key
;
ZEND_PARSE_PARAMETERS_START
(
2
,
2
)
Z_PARAM_RESOURCE
(
zid
)
Z_PARAM_ARRAY
(
arr
)
ZEND_PARSE_PARAMETERS_END
();
zend_ulong
key
=
(
zend_ulong
)
Z_RES_VAL_P
(
zid
);
zval
*
current_header
=
zend_hash_index_find
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
);
ZEND_HASH_FOREACH_KEY_VAL
(
Z_ARRVAL_P
(
arr
),
option
,
string_key
,
entry
)
{
if
(
string_key
)
{
php_error_docref
(
NULL
,
E_WARNING
,
"Array keys must be CURLOPT constants or equivalent integer values"
);
RETURN_FALSE
;
}
if
(
CURLOPT_HTTPHEADER
==
option
)
{
if
(
current_header
==
NULL
)
{
zval
temp
;
array_init
(
&
temp
);
add_assoc_long
(
&
temp
,
"exec_call"
,
0
);
add_assoc_zval
(
&
temp
,
"header"
,
entry
);
zend_hash_index_add
(
Z_ARRVAL_P
(
&
SKYWALKING_G
(
curl_header
)),
key
,
&
temp
);
}
else
{
zend_string
*
header
=
zend_string_init
(
"header"
,
sizeof
(
"header"
)
-
1
,
0
);
zend_hash_update
(
Z_ARRVAL_P
(
current_header
),
header
,
entry
);
zend_string_release
(
header
);
}
}
}
ZEND_HASH_FOREACH_END
();
orig_curl_setopt_array
(
INTERNAL_FUNCTION_PARAM_PASSTHRU
);
}
/* {{{ php_skywalking_init_globals
/* {{{ php_skywalking_init_globals
*/
*/
/* Uncomment this function if you have INI entries*/
/* Uncomment this function if you have INI entries*/
...
@@ -730,6 +794,10 @@ PHP_MINIT_FUNCTION (skywalking) {
...
@@ -730,6 +794,10 @@ PHP_MINIT_FUNCTION (skywalking) {
orig_curl_setopt
=
old_function
->
internal_function
.
handler
;
orig_curl_setopt
=
old_function
->
internal_function
.
handler
;
old_function
->
internal_function
.
handler
=
sky_curl_setopt_handler
;
old_function
->
internal_function
.
handler
=
sky_curl_setopt_handler
;
}
}
if
((
old_function
=
zend_hash_str_find_ptr
(
CG
(
function_table
),
"curl_setopt_array"
,
sizeof
(
"curl_setopt_array"
)
-
1
))
!=
NULL
)
{
orig_curl_setopt_array
=
old_function
->
internal_function
.
handler
;
old_function
->
internal_function
.
handler
=
sky_curl_setopt_array_handler
;
}
}
}
return
SUCCESS
;
return
SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录