Skip to content

Commit 5bb966d

Browse files
committed
fix lines in the websocket log truncated
1 parent f1f1556 commit 5bb966d

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

ngx_http_websocket_stat_format.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <ngx_core.h>
2+
#include <ngx_http.h>
13
#include <assert.h>
24
#include <ctype.h>
35
#include <stdlib.h>
@@ -12,7 +14,7 @@ size_t HTTP_VAR_LEN = sizeof("$http_") - 1;
1214

1315
template_variable null_variable = {NULL, 0, 0, NULL};
1416
const char *http_header_var(ngx_http_request_t *r, void *data);
15-
template_variable header_variable = {NULL, 0, 50, http_header_var};
17+
template_variable header_variable = {NULL, 0, 150, http_header_var};
1618

1719
typedef struct {
1820
const template_variable *variable;

ngx_http_websocket_stat_module.c

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#include "ngx_http_websocket_stat_format.h"
2-
#include "ngx_http_websocket_stat_frame_counter.h"
3-
#include <assert.h>
41
#include <ngx_config.h>
52
#include <ngx_core.h>
63
#include <ngx_http.h>
74

5+
#include "ngx_http_websocket_stat_format.h"
6+
#include "ngx_http_websocket_stat_frame_counter.h"
7+
#include <assert.h>
8+
89
#include <openssl/bio.h>
910
#include <openssl/evp.h>
1011
#include <openssl/sha.h>
@@ -334,9 +335,9 @@ my_send(ngx_connection_t *c, u_char *buf, size_t size)
334335
}
335336
int n = orig_send(c, buf, size);
336337
if (n < 0) {
337-
if(!ngx_atomic_cmp_set(ngx_websocket_stat_active, 0, 0)){
338-
ngx_atomic_fetch_add(ngx_websocket_stat_active, -1);
339-
ws_do_log(log_close_template, r, &template_ctx);
338+
if (!ngx_atomic_cmp_set(ngx_websocket_stat_active, 0, 0)) {
339+
ngx_atomic_fetch_add(ngx_websocket_stat_active, -1);
340+
ws_do_log(log_close_template, r, &template_ctx);
340341
}
341342
}
342343
return n;
@@ -415,9 +416,9 @@ ngx_http_websocket_stat_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
415416
ngx_atomic_fetch_add(ngx_websocket_stat_active, 1);
416417
ctx->ws_conn_start_time = ngx_time();
417418
} else {
418-
if(!ngx_atomic_cmp_set(ngx_websocket_stat_active, 0, 0)){
419-
ngx_atomic_fetch_add(ngx_websocket_stat_active, -1);
420-
ws_do_log(log_close_template, r, &template_ctx);
419+
if (!ngx_atomic_cmp_set(ngx_websocket_stat_active, 0, 0)) {
420+
ngx_atomic_fetch_add(ngx_websocket_stat_active, -1);
421+
ws_do_log(log_close_template, r, &template_ctx);
421422
}
422423
}
423424
}
@@ -546,9 +547,9 @@ const template_variable variables[] = {
546547
{VAR_NAME("$ws_conn_age"), NGX_SIZE_T_LEN, ws_connection_age},
547548
{VAR_NAME("$time_local"), sizeof("Mon, 23 Oct 2017 11:27:42 GMT") - 1,
548549
local_time},
549-
{VAR_NAME("$upstream_addr"), 60, upstream_addr},
550-
{VAR_NAME("$request"), 60, request},
551-
{VAR_NAME("$uri"), 60, uri},
550+
{VAR_NAME("$upstream_addr"), 160, upstream_addr},
551+
{VAR_NAME("$request"), 160, request},
552+
{VAR_NAME("$uri"), 160, uri},
552553
{VAR_NAME("$request_id"), UID_LENGTH, request_id},
553554
{VAR_NAME("$remote_user"), 60, remote_user},
554555
{VAR_NAME("$remote_addr"), 60, remote_addr},

0 commit comments

Comments
 (0)