Skip to content

Commit 56b858d

Browse files
authored
optimize: add compatibility for freenginx.
Commit freenginx/nginx@3329aa9 updated the ngx_http_request_t structure with the start_time; the start_sec and start_msec were removed. Also, some additional SSL-related functionality has been added to the the nginx, however, a corresponding one for the freenginx is missing.
1 parent 9d8cea5 commit 56b858d

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

src/ngx_stream_lua_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ ngx_stream_lua_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
919919
ngx_stream_lua_srv_conf_t *conf = child;
920920

921921
#if (NGX_STREAM_SSL)
922-
#if defined(nginx_version) && nginx_version >= 1025005
922+
#if !defined (freenginx) && (defined(nginx_version) && nginx_version >= 1025005)
923923
ngx_stream_ssl_srv_conf_t *sscf;
924924
#else
925925
ngx_stream_ssl_conf_t *sscf;

src/ngx_stream_lua_socket_tcp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,9 @@ ngx_stream_lua_socket_tcp_serversslhandshake(lua_State *L)
22612261
ngx_stream_lua_ctx_t *ctx;
22622262
ngx_stream_lua_co_ctx_t *coctx;
22632263
ngx_stream_lua_socket_tcp_upstream_t *u;
2264+
#if !defined (freenginx)
22642265
ngx_stream_ssl_srv_conf_t *sscf;
2266+
#endif
22652267

22662268
/* Lua function arguments: self */
22672269

@@ -2317,6 +2319,7 @@ ngx_stream_lua_socket_tcp_serversslhandshake(lua_State *L)
23172319
return 1;
23182320
}
23192321

2322+
#if !defined (freenginx)
23202323
sscf = ngx_stream_get_module_srv_conf(r->session, ngx_stream_ssl_module);
23212324

23222325
if (sscf == NULL || sscf->ssl.ctx == NULL) {
@@ -2330,6 +2333,7 @@ ngx_stream_lua_socket_tcp_serversslhandshake(lua_State *L)
23302333
lua_pushliteral(L, "failed to create ssl connection");
23312334
return 2;
23322335
}
2336+
#endif
23332337

23342338
ctx = ngx_stream_lua_get_module_ctx(r, ngx_stream_lua_module);
23352339
if (ctx == NULL) {

src/ngx_stream_lua_ssl_certby.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ ngx_stream_lua_ffi_ssl_verify_client(ngx_stream_lua_request_t *r,
15601560

15611561
ngx_stream_lua_ctx_t *ctx;
15621562
ngx_ssl_conn_t *ssl_conn;
1563-
#if defined(nginx_version) && nginx_version >= 1025005
1563+
#if !defined (freenginx) && (defined(nginx_version) && nginx_version >= 1025005)
15641564
ngx_stream_ssl_srv_conf_t *sscf;
15651565
#else
15661566
ngx_stream_ssl_conf_t *sscf;

src/ngx_stream_lua_ssl_client_helloby.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ ngx_stream_lua_ssl_client_hello_handler(ngx_ssl_conn_t *ssl_conn,
218218
return -1;
219219
}
220220

221-
#if (nginx_version > 1029001)
221+
#if !(freenginx) && (nginx_version > 1029001)
222222
#ifdef SSL_CLIENT_HELLO_SUCCESS
223223
/* see commit 0373fe5d98c1515640 for more details */
224224
rc = ngx_ssl_client_hello_callback(ssl_conn, al, arg);

src/ngx_stream_lua_time.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,21 @@ ngx_stream_lua_ffi_now(void)
3636
double
3737
ngx_stream_lua_ffi_req_start_time(ngx_stream_lua_request_t *r)
3838
{
39+
#if defined freenginx
40+
ngx_time_t *tp;
41+
42+
tp = ngx_timeofday();
43+
tp->sec -= (ngx_current_msec - r->session->start_time) / 1000;
44+
tp->msec -= (ngx_current_msec - r->session->start_time) % 1000;
45+
if (tp->msec > NGX_MAX_INT_T_VALUE) {
46+
tp->msec += 1000;
47+
tp->sec -= 1;
48+
}
49+
50+
return tp->sec + tp->msec / 1000.0;
51+
#else
3952
return r->session->start_sec + r->session->start_msec / 1000.0;
53+
#endif
4054
}
4155

4256

0 commit comments

Comments
 (0)