diff --git a/sky-php7ext/skywalking.c b/sky-php7ext/skywalking.c index 079f008734aabc2746f3b5fbd533ab74c9c09251..b49e3bf2f042ec2c1bd2a7c36b9ce0ca7ad52b83 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 c608e5b635086d6635620d9885b7740d107db97d..2177c655cc1d9ba98e116a8b8573888928f56708 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;