* NEWS: Document changes.
* doc/pound.texi: Likewise.
* src/http.c (accessor_query): If argument is given, prefix
it to the expansion, if the query part is present.
(accessors): Change declaration of "query".
(find_accessor): Handle optional and mandatory arguments.
Return textual error description along with the NULL return.
All callers changed.
* tests/reqacc.at: Test expansion of "%[query ?]".
In rare cases, when the input queue had been filled up and a worker
became available after disabling the listeners, the same code could have
been run again, thus effectively unblocking them. When the actual unblock
request would arrive, the pollfd descriptors would be flipped again,
leaving the listeners blocked while the state variable indicated otherwise.
* src/pound.c (pollfd_toggle): New function.
(thr_dispatch): Remove TOGGLE_FD and SET_STATE macros.
Change state only on command received via control channel.
Treat DSP_ACCEPT and DSP_BLOCK as advisory commands, checking
actual queue state to decide whether any change is needed.
Fix handling of disabled listeners.
* src/poundctl.tmpl (default.print_trace,xml.print_trace): Print both
numeric and symbolic (when available) paths.
* src/svc.c: Consistently use listener_index to refer to the listener
ordinal number. Same for service_index.
* tests/ctl-trace.at: Update expected output.
* src/http.c (match_cond): Take pointer to the trace message as
the 6th argument. All useses changed.
* src/pound.c (vlogmsg): New argument: pfx. Points to an optional
prefix to output before locus.
(tracemsg): New argument: msg.
All uses changed.
* src/pound.h (tracemsg, match_cond): Change prototypes.
* tests/tracelog.at: Change expected output.
* src/http.c (match_cond): Log implicit operations as well.
* src/svc.c [OBJ_TOP]: New constant.
(ctl_listener): Mark requests to / as OBJ_TOP.
(list_handler,disable_handler)
(session_remove_handler,session_add_handler)
(trace_handler): Handle OBJ_TOP.
(service_has_control,listener_has_control): Accept NULL argument.
(struct traceinfo): New field: enable.
(serialize_next): Set trace if enable is not NULL.
(trace_all_serialize): Take a pointer to the new trace value as
argument. Can be NULL to just list current settings.
(control_get_trace): Just call ctl_listener.
* src/pound.h (struct http_request): New field: changed.
(http_request_header_filter,http_request_header_append): New protos.
(SERVICE,REWRITE_RULE): New field: locus.
(SERVICE): New field: trace.
(LISTENER): New field: tracecnt.
(pound_http_trace): New function.
(tracemsg, dumpreq): New protos.
(rewrite_apply_rules, match_cond): Change signature.
* src/config.c (service_cond_alloc): Take pointer to locus_range as
second argument. Assign it to SERVICE_COND->locus. All uses changed.
(service_cond_append): Likewise.
(rewrite_rule_alloc,rewrite_rule_last_uncond): Likewise.
* src/http.c (http_header_list_filter): Return number of removals
performed.
(http_request_header_filter,http_request_header_append): New functions.
(http_request_rebuild_line,parse_http_request): Set changed field to 1.
(match_cond): Take trace flag as additional argument. If set, output
additional diagnostics about comparisons performed.
(add_forwarded_headers,send_to_backend): Use http_request_header_append
instead of http_header_list_append.
* src/cfg-lex.l (parse_line_directive): Fix condition.
* tests/ctl-listener.at: Update expected output.
* tests/ctl-service.at: Likewise.
* tests/ctl-trace.at: New file.
* tests/tracelog.at: New file.
* tests/Makefile.am: Add new files.
* tests/testsuite.at: Likewise.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
* doc/poundctl.8: Likewise.
* src/cfg-gram.y (T_INCLUDE, T_INCLUDEDIR): Remove terminals.
(includedir): Remove nonterminal.
(include,includedir): Remove rules.
(cfg_parse_tree): Remove useless dir argument.
All uses changed.
* src/cfg-lex.l (preproc_argv, preproc_argc): Now static.
(pragma_preproc_suppress): New static.
(skip_prefix): New function.
(parse_line_directive): Rewrite using it.
(parse_include,parse_includedir): New funtions.
(HEADERS,PP): New lexer states.
Handle "Include" and "IncludeDir" directives directly in the scanner.
Start in HEADER state.
(cfg_lex_init,cfg_open_input): Remove useless argument.
All uses changed.
(cfg_lex_preproc): Switch to the PP state.
(preproc_setup): New function.
(parse_pragma): New function.
* src/cfgdef.c: Remove the "preprocess" feature.
* src/cfgdef.h (include_dir, include_wd): New externs.
Moved from extern.h
(cfg_lex_init, cfg_lex_preproc_run, cfg_parse_tree): Update protos.
(preproc_argv, preproc_argc): Remove.
* src/config.c (feature): Remove "preprocess".
Remove handlers for "Include" and "IncludeDir".
* src/poundctl.c (read_config, scan_pound_cfg): Set up include_wd
prior to calling cfg_parse_tree.
* tests/poundharness.pl: New option --header.
* tests/syncline.at: New file.
* tests/syncline.at: New file.
* tests/preproc.at: New file.
* tests/eopt.at: New file.
* tests/eoptpp.at: New file.
* tests/Makefile.am: Add new files.
* tests/testsuite.at: Include new files.
* src/cfg-lex.l (input_close): Call yy_delete_buffer to reset
YY_CURRENT_BUFFER to NULL. This way the parser can safely be called
several times (see inctx_push), as it is in poundctl.
(skip_eol): Return 0 if safe to continue, and 1 if no more input
available.
* src/cfg-gram.y (skip_eol): New rule. Use it in all rules instead
of direct call to skip_eol. This makes sure yylex won't be called with
NULL buffer.
* src/cfgdef.c (enable_preproc_feature, set_include_dir): Functions
moved here from config.c
* src/cfgdef.h (enable_preproc_feature, set_include_dir): New protos.
* src/poundctl.c: Add include-dir and preprocess features.
* doc/pound.texi: Document the -W option to poundctl.
* doc/poundctl.8: Likewise.
Re-implement nested rewrites.
* doc/pound.texi: Explicitly mention that rewrite sections can be
nested.
* src/cfg-gram.y (find_rewrite_defn): Return NULL on failure.
(rewrite_begin): Determine default target from the data field
of the CFG_DEFN structure.
* src/config.c (http_request_eval_reset): New function.
(rw_req_defn, rw_resp_defn): Allow for nested Rewrite sections.
(svc_defn, http_common): Store the default rewrite target in the
date field.
* src/http.c (rewrite_apply_rules): Invalidate cached evaluations after
processing early rewrites.
* src/pound.h (http_request_eval_reset): New proto.
* src/svc.c (select_term_service): Invalidate cached evaluations.
* tests/Makefile.am: Add new tests.
* tests/resprwnest.at: Likewise.
* tests/rwchain.at: New test.
* tests/rwearly.at: New test.
* tests/rwnest.at: New test.
* src/pound.h (timespec_is_null): New function.
(POUND_HTTP): Replace individual timespecs with an array of such.
* src/http.c (phttp_gettime): New function. Use it instead of
clock_gettime when necessary.
(http_process_request): Save TS_SELECT time.
(do_http): Set arg->ts immediately before reading the request.
Set TS_REQ_END afterwards. Set TS_RESP_END when finished sending
the response.
* src/log.c: Print "-" if one of the timestamps involved in %{}D or
%{}T output is null.
(p_process_time): New prefix: reqend.
(p_duration): New prefixes: header, resp.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
The prefix in T indicates start of the time interval: %{init:}T,
%{req:}T, or %{be:}T. That of %D conversion specifies the stage
of request processing whose duration is required.
* src/pound.h (POUND_HTTP): New field: start_init.
* src/http.c (BIO_ARG): New fields: ts and cmd.
(bio_callback): Initialize ts upon receiving or sending the
first byte, depending on the value of cmd.
(set_callback): Take two additional arguments: pointer to
the timespec and callback command value. All uses changed.
(do_tunnel): Initialize timespecs properly.
(do_http): Likewise.
* src/log.c (struct http_log_instr): New field: off.
(add_instr): Take additional argument (the value of off). All
uses changed.
(select_prefix2, select_prefix): New functions.
(i_process_time_ms, i_process_time_us)
(i_process_time_s, i_process_time_f): Get start time from the
instruction argument.
(p_process_time): Accept prefixes.
(p_duration): New function.
(http_log_spec): Use p_duration to parse the D conversion.
* tests/logfmt.at: Add new tests.
* configure.ac: Raise version patchlevel number.
* NEWS: Document changes. Raise version patchlevel number.
* doc/pound.texi: Document changes.
* doc/pound.8: Likewise.
A "beacon" is a named boolean variable that can be inspected in
conditionals. Beacons can be set and cleared at runtime via the
pound control interface. They provide a mechanism for altering
pound behavior without the need to reconfigure it.
* src/Makefile.am: Add new source.
* src/beacon.c: New file.
* src/config.c (DeclareBeacon): New global statement.
(Beacon): New conditional statement.
* src/http.c (match_cond): Handle COND_BEACON.
* src/pound-mode.el: Add new keywords.
* src/pound.h (COND_BEACON): New condition code.
(_service_cond): New field: "beacon".
(pound_beacon_declare, pound_beacon_get)
(pound_beacon_set, pound_beacon_serialize): New protos.
* src/poundctl.c: New subcommand: "beacon".
* src/poundctl.tmpl: New templates: "default.beacon" and "xml.beacon".
* src/svc.c: New endpoint: "/beacon".
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
* doc/poundctl.8: Likewise.
* doc/poundctl.tmpl.5: Likewise.
* tests/beacon.at: New test.
* tests/Makefile.am: Add new file.
* tests/testsuite.at: Include new test.
This is necessary for fall-through services (see 191c765c).
* src/metrics.c (json_object_get_type): Treat json_null as compatible
with json_array or json_object.
(exposition_iterate,gen_backends_count)
(gen_backend_stats): Return 0 immediately if given json_null.
* src/json.c: Treat json_null as a valid json_array or json_object.
This is not strictly necessary for purposes of this commit, it is
rather done for future use.
(json_array_insert, json_array_append, json_array_set): Promote
json_null to json_array as necessary.
(json_array_get): Return ENOENT if jv is of json_null type.
(json_object_set): Promote json_null to json_object as necessary.
(json_object_get): Return ENOENT if obj is of json_null type.
(json_object_filter): Return 0 immediately if given json_null.
* doc/pound.texi: Fix definition descriptor.
* src/pound-mode.el (service-top, control-top)
(backend-top, default-top): Restore initial position and return t
if no specific matches found (i.e. at top level).
(pound-mode): Use define-derived-mode instead of plain defun.
* src/cfg-lex.l (preproc_argv, preproc_pid): New globals.
(yylex): Handle line directives.
(struct inctx): New field: pid.
(inctx_push,inctx_pop): Save and restore preproc_pid.
(input_close): Special handling for preprocessing mode.
(cfg_open_input): Use preprocessor, if defined.
(cfg_lex_preproc): New function.
* src/watcher.c (filename_catn): Move to src/cfgdef.c
* src/cfgdef.c (popen_include): New function.
* src/cfgdef.h (cfg_lex_preproc): New proto.
(CFG_DEBUG_PREPROC): New constant.
(preproc_argc,preproc_argv): New extern.
* src/config.c (feature): New feature preprocess="cmdline" defines the
command to use for config file preprocessing.
(config_parse): New option: -E. Runs the preprocessor and prints its
output.
(print_help): Document the -E option.
* src/pound.h (popen_include,filename_catn): New proto.
* doc/pound.8: Document changes.
* doc/pound.texi: Likewise.
* NEWS: Likewise.