From d016eccfcce0ba824134f8177a714d99a1f8b57b Mon Sep 17 00:00:00 2001 From: heyanlong Date: Wed, 12 Dec 2018 17:57:23 +0800 Subject: [PATCH] default port --- sky-php7ext/skywalking.c | 24 +++++++++++------------- sky-php7ext/src/report/report_client.cpp | 12 ++++++------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/sky-php7ext/skywalking.c b/sky-php7ext/skywalking.c index 079f008..b49e3bf 100644 --- a/sky-php7ext/skywalking.c +++ b/sky-php7ext/skywalking.c @@ -180,7 +180,6 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS) char *sw3 = generate_sw3(Z_LVAL_P(span_id) + 1, _peer_host, _op_name); zend_string_release(_peer_host); zend_string_release(_op_name); - if (sw3 != NULL) { zval z_sw3; array_init(&z_sw3); @@ -207,18 +206,21 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS) orig_curl_exec(INTERNAL_FUNCTION_PARAM_PASSTHRU); - - call_user_function(CG(function_table), NULL, &function_name, &curlInfo, 1, params); - zval_dtor(¶ms[0]); - zval_dtor(&function_name); + zval function_name_1,curlInfo_1; + zval params_1[1]; + ZVAL_COPY(¶ms_1[0], zid); + ZVAL_STRING(&function_name_1, "curl_getinfo"); + call_user_function(CG(function_table), NULL, &function_name_1, &curlInfo_1, 1, params_1); + zval_dtor(¶ms_1[0]); + zval_dtor(&function_name_1); zval *z_http_code; l_millisecond = get_millisecond(); millisecond = zend_atol(l_millisecond, strlen(l_millisecond)); efree(l_millisecond); - z_http_code = zend_hash_str_find(Z_ARRVAL(curlInfo), ZEND_STRL("http_code")); - zval_dtor(&curlInfo); + z_http_code = zend_hash_str_find(Z_ARRVAL(curlInfo_1), ZEND_STRL("http_code")); + zval_dtor(&curlInfo_1); add_assoc_long(&temp, "endTime", millisecond); @@ -278,17 +280,13 @@ static void write_log(char *text) { char message[strlen(text) + 1]; log_path = SKY_G(log_path); - zend_string *date_fmt, *_log_path, *_log_path_lower; - time_t t; - t = time(NULL); - date_fmt = php_format_date("YmdHi", sizeof("YmdHi") - 1, t, 1); + zend_string *_log_path, *_log_path_lower; _log_path = zend_string_init(log_path, strlen(log_path), 0); _log_path_lower = php_string_tolower(_log_path); bzero(logFilename, 100); - sprintf(logFilename, "%s/skywalking.%s.log", ZSTR_VAL(_log_path_lower), ZSTR_VAL(date_fmt)); + sprintf(logFilename, "%s/skywalking.%d.log", ZSTR_VAL(_log_path_lower), get_second()); - zend_string_release(date_fmt); zend_string_release(_log_path); zend_string_release(_log_path_lower); bzero(message, strlen(text)); diff --git a/sky-php7ext/src/report/report_client.cpp b/sky-php7ext/src/report/report_client.cpp index c608e5b..2177c65 100644 --- a/sky-php7ext/src/report/report_client.cpp +++ b/sky-php7ext/src/report/report_client.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -118,12 +119,11 @@ int main(int argc, char **argv) { if (valid) { - time_t t = time(NULL); - t = t - 65; - char ch[64] = {0}; - strftime(ch, sizeof(ch) - 1, "%Y%m%d%H%M", localtime(&t)); - unsigned long fileTime = std::stoul(result[1]); - unsigned long localTime = std::stoul(ch); + struct timeval tv; + gettimeofday(&tv,NULL); + + long fileTime = std::stol(result[1]); + long localTime = tv.tv_sec - 3; if (fileTime < localTime) { std::ifstream file; -- GitLab