comparison src/stream/ngx_stream_script.c @ 6678:0125b151c9a5

Stream: log module.
author Vladimir Homutov <vl@nginx.com>
date Mon, 05 Sep 2016 17:50:16 +0300
parents af642539cd53
children 39ff6939266e
comparison
equal deleted inserted replaced
6677:c02290241cbe 6678:0125b151c9a5
386 386
387 return NGX_ERROR; 387 return NGX_ERROR;
388 } 388 }
389 389
390 390
391 u_char *
392 ngx_stream_script_run(ngx_stream_session_t *s, ngx_str_t *value,
393 void *code_lengths, size_t len, void *code_values)
394 {
395 ngx_uint_t i;
396 ngx_stream_script_code_pt code;
397 ngx_stream_script_engine_t e;
398 ngx_stream_core_main_conf_t *cmcf;
399 ngx_stream_script_len_code_pt lcode;
400
401 cmcf = ngx_stream_get_module_main_conf(s, ngx_stream_core_module);
402
403 for (i = 0; i < cmcf->variables.nelts; i++) {
404 if (s->variables[i].no_cacheable) {
405 s->variables[i].valid = 0;
406 s->variables[i].not_found = 0;
407 }
408 }
409
410 ngx_memzero(&e, sizeof(ngx_stream_script_engine_t));
411
412 e.ip = code_lengths;
413 e.session = s;
414 e.flushed = 1;
415
416 while (*(uintptr_t *) e.ip) {
417 lcode = *(ngx_stream_script_len_code_pt *) e.ip;
418 len += lcode(&e);
419 }
420
421
422 value->len = len;
423 value->data = ngx_pnalloc(s->connection->pool, len);
424 if (value->data == NULL) {
425 return NULL;
426 }
427
428 e.ip = code_values;
429 e.pos = value->data;
430
431 while (*(uintptr_t *) e.ip) {
432 code = *(ngx_stream_script_code_pt *) e.ip;
433 code((ngx_stream_script_engine_t *) &e);
434 }
435
436 return e.pos;
437 }
438
439
440 void
441 ngx_stream_script_flush_no_cacheable_variables(ngx_stream_session_t *s,
442 ngx_array_t *indices)
443 {
444 ngx_uint_t n, *index;
445
446 if (indices) {
447 index = indices->elts;
448 for (n = 0; n < indices->nelts; n++) {
449 if (s->variables[index[n]].no_cacheable) {
450 s->variables[index[n]].valid = 0;
451 s->variables[index[n]].not_found = 0;
452 }
453 }
454 }
455 }
456
457
391 static ngx_int_t 458 static ngx_int_t
392 ngx_stream_script_init_arrays(ngx_stream_script_compile_t *sc) 459 ngx_stream_script_init_arrays(ngx_stream_script_compile_t *sc)
393 { 460 {
394 ngx_uint_t n; 461 ngx_uint_t n;
395 462