Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 96d922a

Browse files
sapi/litespeed
1 parent 40f157f commit 96d922a

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

‎sapi/litespeed/lsapi_main.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "php_variables.h"
2222
#include "zend_highlight.h"
2323
#include "zend_portability.h"
24+
#include "zend_time.h"
2425
#include "zend.h"
2526
#include "ext/standard/basic_functions.h"
2627
#include "ext/standard/info.h"
@@ -46,7 +47,6 @@
4647
#include <sys/socket.h>
4748
#include <arpa/inet.h>
4849
#include <netinet/in.h>
49-
#include <sys/time.h>
5050

5151
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
5252
#include "lscriu.c"
@@ -1450,8 +1450,8 @@ int main( int argc, char * argv[] )
14501450
char * php_bind = NULL;
14511451
int n;
14521452
int climode = 0;
1453-
structtimevaltv_req_begin;
1454-
structtimevaltv_req_end;
1453+
int64_treq_begin_ns, req_end_ns;
1454+
time_treq_end_sec;
14551455
int slow_script_msec = 0;
14561456
char time_buf[40];
14571457

@@ -1563,16 +1563,16 @@ int main( int argc, char * argv[] )
15631563
}
15641564
#endif
15651565
if ( slow_script_msec ) {
1566-
gettimeofday( &tv_req_begin, NULL);
1566+
req_begin_ns=zend_monotime_fallback();
15671567
}
15681568
ret = processReq();
15691569
if ( slow_script_msec ) {
1570-
gettimeofday( &tv_req_end, NULL );
1571-
n = ((long) tv_req_end.tv_sec - tv_req_begin.tv_sec ) * 1000
1572-
+ (tv_req_end.tv_usec - tv_req_begin.tv_usec) / 1000;
1570+
req_end_ns = zend_monotime_fallback();
1571+
n = (long) (req_end_ns - req_begin_ns) / 1000000;
15731572
if ( n > slow_script_msec )
15741573
{
1575-
strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &tv_req_end.tv_sec ) );
1574+
req_end_sec = (time_t) (req_end_ns / ZEND_NANO_IN_SEC);
1575+
strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &req_end_sec ) );
15761576
fprintf( stderr, "[%s] Slow PHP script: %d ms\n URL: %s %s\n Query String: %s\n Script: %s\n",
15771577
time_buf, n, LSAPI_GetRequestMethod(),
15781578
LSAPI_GetScriptName(), LSAPI_GetQueryString(),

‎sapi/litespeed/lsapilib.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9393
#endif
9494

9595
#include <Zend/zend_portability.h>
96+
#include <Zend/zend_time.h>
9697

9798
struct lsapi_MD5Context {
9899
uint32 buf[4];
@@ -246,15 +247,15 @@ void LSAPI_Log(int flag, const char * fmt, ...)
246247
if ((flag & LSAPI_LOG_TIMESTAMP_BITS)
247248
&& !(s_stderr_is_pipe))
248249
{
249-
struct timevaltv;
250+
struct timespects;
250251
struct tm tm;
251-
gettimeofday(&tv, NULL);
252-
localtime_r(&tv.tv_sec, &tm);
252+
zend_realtime_spec(&ts);
253+
localtime_r(&ts.tv_sec, &tm);
253254
if (flag & LSAPI_LOG_TIMESTAMP_FULL)
254255
{
255-
p += snprintf(p, 1024, "%04d-%02d-%02d %02d:%02d:%02d.%06d ",
256+
p += snprintf(p, 1024, "%04d-%02d-%02d %02d:%02d:%02d.%09ld ",
256257
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
257-
tm.tm_hour, tm.tm_min, tm.tm_sec, (int)tv.tv_usec);
258+
tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
258259
}
259260
else if (flag & LSAPI_LOG_TIMESTAMP_HMS)
260261
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /