I have implemented part of the last step for adding this feature,
as you proposed them:
*(1) Add new "index" option, with minimal support (a string).
*(2) Allow variables in the "index" option.
+(3) Allow multiple filenames in the "index" option.
However, there's something that I couldn't yet fully understand,
which I need for this: how does the iteration of shares exactly
work, how do other variables (e.g., chroot, fallback) intervene,
and how is index expected to intervene in that mix. Since instead
of an explicit loop there are quite some nested function calls,
I couldn't manage to understand it. Could you please share some
brief description of the purpose of each static function in
<src/nxt_http_static.c> and how all this iteration works?
For this review of the patch set, I didn't yet do much testing. I
passed all previously existing pytests. The only one that fails
is the one I modified in patch 12 (the last one), which is to be
expected, since I didn't yet write code to iterate over the
indices (it's just picking the first element in the array always).
If you reverse the order in the array (in the pytest) to be
it passes the test, which at least makes me happy since the
part that should still work (compared to step 2) still works.
Then, there are a few extra additions (and removals) in this patch
set since v2.
- Add support for variables in "index"
- Don't move share_idx, since that caused unnecessary padding.
- Use <stdbool.h>
- Don't use <stdbool.h> (as previously discussed).
- Add a .gitignore:
While doing this work, I had quite some accidents. This
prevented them from happening again. I based it on the
.gitignore of the Linux man-pages
- Treat non-arrays as arrays of size 1
(as discussed earlier today:
- Simplify all of the code that can be simplified thanks to the
change mentioned above (arrays of size 1).
- Fix the indentation of some random lines that I found to have an
- Reduce branching (especially 'else's), to improve readability.
I didn't merge this change into the patch that adds the feature
because there it adds too much complexity for nothing, and the
patches read better separately. However, I patched it previous
to the third step to simplify that patch too, so this change
sits on a patch of its own better, I think.
- Use const for a read-only parameter of a function. I didn't
change other functions (not even in the same file), since that
would mean a huuuge diff, and for consistency we would need to
do it everywhere. So I only did it where I *needed* it to
compile, for now.
Could you please give some feedback (again) on these changes?
Alejandro Colomar (12):
.gitignore: ignore new files
nxt_conf.c: Treat non-arrays as arrays of size 1
Remove special cases for non-NXT_CONF_VALUE_ARRAY
nxt_http_static_ctx_t: rename field 'index' to 'share_idx'
test_static.py: formatting fix
Static: add "index" option
nxt_http_static_iterate(): generalize code
Static: variables in the "index" option.
nxt_conf_set_string_dup(): Use 'const' for read-only parameter
nxt_http_static_init(): Simplify branching
Static: multiple paths in the "index" option
.gitignore | 2 +
docs/changes.xml | 18 ++++++
src/nxt_conf.c | 7 ++-
src/nxt_conf.h | 2 +-
src/nxt_conf_validation.c | 8 ++-
src/nxt_gnutls.c | 4 +-
src/nxt_http.h | 15 ++---
src/nxt_http_route.c | 54 +++--------------
src/nxt_http_static.c | 124 ++++++++++++++++++++++++--------------
src/nxt_main_process.c | 2 +-
src/nxt_openssl.c | 24 ++------
src/nxt_router.c | 23 ++-----
src/nxt_time_parse.c | 6 +-
src/nxt_unit.c | 4 +-
src/nxt_work_queue.h | 4 +-
src/perl/nxt_perl_psgi.c | 2 +-
src/python/nxt_python.c | 9 ---
test/test_static.py | 18 ++++--
18 files changed, 164 insertions(+), 162 deletions(-)
create mode 100644 .gitignore