comparison src/stream/ngx_stream_variables.c @ 6674:38143d1abdec

Stream: the $status variable. The stream session status is one of the following: 200 - normal completion 403 - access forbidden 500 - internal server error 502 - bad gateway 503 - limit conn
author Roman Arutyunyan <arut@nginx.com>
date Thu, 11 Aug 2016 20:22:23 +0300
parents c6372a40c2a7
children b9f78a4e3597
comparison
equal deleted inserted replaced
6673:e4c1f5b32868 6674:38143d1abdec
23 ngx_stream_variable_value_t *v, uintptr_t data); 23 ngx_stream_variable_value_t *v, uintptr_t data);
24 static ngx_int_t ngx_stream_variable_bytes(ngx_stream_session_t *s, 24 static ngx_int_t ngx_stream_variable_bytes(ngx_stream_session_t *s,
25 ngx_stream_variable_value_t *v, uintptr_t data); 25 ngx_stream_variable_value_t *v, uintptr_t data);
26 static ngx_int_t ngx_stream_variable_session_time(ngx_stream_session_t *s, 26 static ngx_int_t ngx_stream_variable_session_time(ngx_stream_session_t *s,
27 ngx_stream_variable_value_t *v, uintptr_t data); 27 ngx_stream_variable_value_t *v, uintptr_t data);
28 static ngx_int_t ngx_stream_variable_status(ngx_stream_session_t *s,
29 ngx_stream_variable_value_t *v, uintptr_t data);
28 static ngx_int_t ngx_stream_variable_connection(ngx_stream_session_t *s, 30 static ngx_int_t ngx_stream_variable_connection(ngx_stream_session_t *s,
29 ngx_stream_variable_value_t *v, uintptr_t data); 31 ngx_stream_variable_value_t *v, uintptr_t data);
30 32
31 static ngx_int_t ngx_stream_variable_nginx_version(ngx_stream_session_t *s, 33 static ngx_int_t ngx_stream_variable_nginx_version(ngx_stream_session_t *s,
32 ngx_stream_variable_value_t *v, uintptr_t data); 34 ngx_stream_variable_value_t *v, uintptr_t data);
66 68
67 { ngx_string("bytes_received"), NULL, ngx_stream_variable_bytes, 69 { ngx_string("bytes_received"), NULL, ngx_stream_variable_bytes,
68 1, 0, 0 }, 70 1, 0, 0 },
69 71
70 { ngx_string("session_time"), NULL, ngx_stream_variable_session_time, 72 { ngx_string("session_time"), NULL, ngx_stream_variable_session_time,
73 0, NGX_STREAM_VAR_NOCACHEABLE, 0 },
74
75 { ngx_string("status"), NULL, ngx_stream_variable_status,
71 0, NGX_STREAM_VAR_NOCACHEABLE, 0 }, 76 0, NGX_STREAM_VAR_NOCACHEABLE, 0 },
72 77
73 { ngx_string("connection"), NULL, 78 { ngx_string("connection"), NULL,
74 ngx_stream_variable_connection, 0, 0, 0 }, 79 ngx_stream_variable_connection, 0, 0, 0 },
75 80
522 v->len = ngx_sprintf(p, "%T.%03M", (time_t) ms / 1000, ms % 1000) - p; 527 v->len = ngx_sprintf(p, "%T.%03M", (time_t) ms / 1000, ms % 1000) - p;
523 v->valid = 1; 528 v->valid = 1;
524 v->no_cacheable = 0; 529 v->no_cacheable = 0;
525 v->not_found = 0; 530 v->not_found = 0;
526 v->data = p; 531 v->data = p;
532
533 return NGX_OK;
534 }
535
536
537 static ngx_int_t
538 ngx_stream_variable_status(ngx_stream_session_t *s,
539 ngx_stream_variable_value_t *v, uintptr_t data)
540 {
541 v->data = ngx_pnalloc(s->connection->pool, NGX_INT_T_LEN);
542 if (v->data == NULL) {
543 return NGX_ERROR;
544 }
545
546 v->len = ngx_sprintf(v->data, "%03ui", s->status) - v->data;
547 v->valid = 1;
548 v->no_cacheable = 0;
549 v->not_found = 0;
527 550
528 return NGX_OK; 551 return NGX_OK;
529 } 552 }
530 553
531 554