Home
last modified time | relevance | path

Searched hist:56 (Results 101 – 125 of 143) sorted by path

123456

/unit/src/
H A Dnxt_thread.cdiff 1:fdc027c56872 Mon Jan 23 16:56:00 UTC 2017 Igor Sysoev <igor@sysoev.ru> Introducing tasks.
H A Dnxt_thread.hdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
H A Dnxt_thread_id.hdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
H A Dnxt_thread_pool.cdiff 1:fdc027c56872 Mon Jan 23 16:56:00 UTC 2017 Igor Sysoev <igor@sysoev.ru> Introducing tasks.
H A Dnxt_thread_pool.hdiff 1:fdc027c56872 Mon Jan 23 16:56:00 UTC 2017 Igor Sysoev <igor@sysoev.ru> Introducing tasks.
H A Dnxt_thread_time.hdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
H A Dnxt_time.hdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
H A Dnxt_unit.hdiff 877:ed8b1aaefdd1 Wed Dec 19 12:56:00 UTC 2018 Alexander Borisov <alexander.borisov@nginx.com> libunit: added generation of version header file.
H A Dnxt_unix.hdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
diff 1:fdc027c56872 Mon Jan 23 16:56:00 UTC 2017 Igor Sysoev <igor@sysoev.ru> Introducing tasks.
H A Dnxt_vector.hdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
H A Dnxt_work_queue.cdiff 1:fdc027c56872 Mon Jan 23 16:56:00 UTC 2017 Igor Sysoev <igor@sysoev.ru> Introducing tasks.
H A Dnxt_work_queue.hdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
diff 1:fdc027c56872 Mon Jan 23 16:56:00 UTC 2017 Igor Sysoev <igor@sysoev.ru> Introducing tasks.
/unit/src/python/
H A Dnxt_python.cdiff 2251:6e5a9550ead3 Thu Nov 17 21:56:00 UTC 2022 Andrew Clayton <a.clayton@nginx.com> Python: Added support for Python 3.11.

Python 3.8 added a new Python initialisation configuration API[0].

Python 3.11 marked the old API as deprecated resulting in the following
compiler warnings which we treat as errors, failing the build

src/python/nxt_python.c: In function ‘nxt_python_start’:
src/python/nxt_python.c:130:13: error: ‘Py_SetProgramName’ is deprecated [-Werror=deprecated-declarations]
130 | Py_SetProgramName(nxt_py_home);
| ^~~~~~~~~~~~~~~~~
In file included from /opt/python-3.11/include/python3.11/Python.h:94,
from src/python/nxt_python.c:7:
/opt/python-3.11/include/python3.11/pylifecycle.h:37:38: note: declared here
37 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
| ^~~~~~~~~~~~~~~~~
src/python/nxt_python.c:134:13: error: ‘Py_SetPythonHome’ is deprecated [-Werror=deprecated-declarations]
134 | Py_SetPythonHome(nxt_py_home);
| ^~~~~~~~~~~~~~~~
/opt/python-3.11/include/python3.11/pylifecycle.h:40:38: note: declared here
40 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *);
| ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

We actually have a few config scenarios: Python < 3, Python >= 3.0 < 3.8
and for Python 3 we have two configs where we select one based on
virtual environment setup.

Factor out the Python 3 config initialisation into its own function. We
actually create two functions, one for Python 3.8+ and one for older
Python 3. We pick the right function to use at build time.

The new API also has error checking (where the old API doesn't) which we
handle.

[0]: https://peps.python.org/pep-0587/

Closes: <https://github.com/nginx/unit/issues/710>
[ Andrew: Expanded upon patch from @sandeep-gh ]
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
/unit/src/ruby/
H A Dnxt_ruby.cdiff 2608:2091b078cdf6 Mon Oct 23 13:24:00 UTC 2023 Andrew Clayton <a.clayton@nginx.com> Ruby: Handle response field arrays

@xeron on GitHub reported an issue whereby with a Rails 7.1 application
they were getting the following error

2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Wrong header entry 'value' from application
2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Failed to run ruby script

After some back and forth debugging it turns out rack was trying to send
back a header comprised of an array of values. E.g

app = Proc.new do |env|
["200", {
"Content-Type" => "text/plain",
"X-Array-Header" => ["Item-1", "Item-2"],
}, ["Hello World\n"]]
end

run app

It seems this became a possibility in rack v3.0[0]

So along with a header value type of T_STRING we need to also allow
T_ARRAY.

If we get a T_ARRAY we need to build up the header field using the given
values.

E.g

"X-Array-Header" => ["Item-1", "", "Item-3", "Item-4"],

becomes

X-Array-Header: Item-1; ; Item-3; Item-4

[0]: <https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md?plain=1#L26>

Reported-by: Ivan Larionov <xeron.oskom@gmail.com>
Closes: <https://github.com/nginx/unit/issues/974>
Link: <https://github.com/nginx/unit/pull/998>
Tested-by: Timo Stark <t.stark@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
diff 2608:2091b078cdf6 Mon Oct 23 13:24:00 UTC 2023 Andrew Clayton <a.clayton@nginx.com> Ruby: Handle response field arrays

@xeron on GitHub reported an issue whereby with a Rails 7.1 application
they were getting the following error

2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Wrong header entry 'value' from application
2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Failed to run ruby script

After some back and forth debugging it turns out rack was trying to send
back a header comprised of an array of values. E.g

app = Proc.new do |env|
["200", {
"Content-Type" => "text/plain",
"X-Array-Header" => ["Item-1", "Item-2"],
}, ["Hello World\n"]]
end

run app

It seems this became a possibility in rack v3.0[0]

So along with a header value type of T_STRING we need to also allow
T_ARRAY.

If we get a T_ARRAY we need to build up the header field using the given
values.

E.g

"X-Array-Header" => ["Item-1", "", "Item-3", "Item-4"],

becomes

X-Array-Header: Item-1; ; Item-3; Item-4

[0]: <https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md?plain=1#L26>

Reported-by: Ivan Larionov <xeron.oskom@gmail.com>
Closes: <https://github.com/nginx/unit/issues/974>
Link: <https://github.com/nginx/unit/pull/998>
Tested-by: Timo Stark <t.stark@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
diff 2608:2091b078cdf6 Mon Oct 23 13:24:00 UTC 2023 Andrew Clayton <a.clayton@nginx.com> Ruby: Handle response field arrays

@xeron on GitHub reported an issue whereby with a Rails 7.1 application
they were getting the following error

2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Wrong header entry 'value' from application
2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Failed to run ruby script

After some back and forth debugging it turns out rack was trying to send
back a header comprised of an array of values. E.g

app = Proc.new do |env|
["200", {
"Content-Type" => "text/plain",
"X-Array-Header" => ["Item-1", "Item-2"],
}, ["Hello World\n"]]
end

run app

It seems this became a possibility in rack v3.0[0]

So along with a header value type of T_STRING we need to also allow
T_ARRAY.

If we get a T_ARRAY we need to build up the header field using the given
values.

E.g

"X-Array-Header" => ["Item-1", "", "Item-3", "Item-4"],

becomes

X-Array-Header: Item-1; ; Item-3; Item-4

[0]: <https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md?plain=1#L26>

Reported-by: Ivan Larionov <xeron.oskom@gmail.com>
Closes: <https://github.com/nginx/unit/issues/974>
Link: <https://github.com/nginx/unit/pull/998>
Tested-by: Timo Stark <t.stark@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
diff 2608:2091b078cdf6 Mon Oct 23 13:24:00 UTC 2023 Andrew Clayton <a.clayton@nginx.com> Ruby: Handle response field arrays

@xeron on GitHub reported an issue whereby with a Rails 7.1 application
they were getting the following error

2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Wrong header entry 'value' from application
2023/10/22 20:57:28 [error] 56#56 [unit] #8: Ruby: Failed to run ruby script

After some back and forth debugging it turns out rack was trying to send
back a header comprised of an array of values. E.g

app = Proc.new do |env|
["200", {
"Content-Type" => "text/plain",
"X-Array-Header" => ["Item-1", "Item-2"],
}, ["Hello World\n"]]
end

run app

It seems this became a possibility in rack v3.0[0]

So along with a header value type of T_STRING we need to also allow
T_ARRAY.

If we get a T_ARRAY we need to build up the header field using the given
values.

E.g

"X-Array-Header" => ["Item-1", "", "Item-3", "Item-4"],

becomes

X-Array-Header: Item-1; ; Item-3; Item-4

[0]: <https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md?plain=1#L26>

Reported-by: Ivan Larionov <xeron.oskom@gmail.com>
Closes: <https://github.com/nginx/unit/issues/974>
Link: <https://github.com/nginx/unit/pull/998>
Tested-by: Timo Stark <t.stark@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
/unit/src/test/
H A Dnxt_rbtree1_test.cdiff 2084:7d479274f334 Sat Apr 30 17:20:00 UTC 2022 Alejandro Colomar <alx.manpages@gmail.com> Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'
/unit/src/wasm/
H A Dnxt_wasm.hdiff 2558:9bcb190bc8be Thu Sep 14 19:35:00 UTC 2023 Andrew Clayton <a.clayton@nginx.com> Wasm: Allow uploads larger than 4GiB.

Currently Wasm modules are limited to a 32bit address space (until at
least the memory64 work is completed). All the counters etc in the
request structure were u32's. Which matched with 32bit memory
limitation.

However there is really no need to not allow >4GiB uploads that can be
saved off to disk or some such.

To do this we just need to increase the ->content_len &
->total_content_sent members to u64's.

However because we need the request structure to have the exact same
layout on 32bit (for Wasm modules) as it does on 64bit we need to re-jig
the order of some of these members and add a four-byte padding member.

Thus the request structure now looks like on 64bit (as shown by
pahole(1))

struct nxt_wasm_request_s {
uint32_t method_off; /* 0 4 */
uint32_t method_len; /* 4 4 */
uint32_t version_off; /* 8 4 */
uint32_t version_len; /* 12 4 */
uint32_t path_off; /* 16 4 */
uint32_t path_len; /* 20 4 */
uint32_t query_off; /* 24 4 */
uint32_t query_len; /* 28 4 */
uint32_t remote_off; /* 32 4 */
uint32_t remote_len; /* 36 4 */
uint32_t local_addr_off; /* 40 4 */
uint32_t local_addr_len; /* 44 4 */
uint32_t local_port_off; /* 48 4 */
uint32_t local_port_len; /* 52 4 */
uint32_t server_name_off; /* 56 4 */
uint32_t server_name_len; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
uint64_t content_len; /* 64 8 */
uint64_t total_content_sent; /* 72 8 */
uint32_t content_sent; /* 80 4 */
uint32_t content_off; /* 84 4 */
uint32_t request_size; /* 88 4 */
uint32_t nfields; /* 92 4 */
uint32_t tls; /* 96 4 */
char __pad[4]; /* 100 4 */
nxt_wasm_http_field_t fields[]; /* 104 0 */

/* size: 104, cachelines: 2, members: 25 */
/* last cacheline: 40 bytes */
};

and the same structure (taken from unit-wasm) compiled as 32bit

struct luw_req {
u32 method_off; /* 0 4 */
u32 method_len; /* 4 4 */
u32 version_off; /* 8 4 */
u32 version_len; /* 12 4 */
u32 path_off; /* 16 4 */
u32 path_len; /* 20 4 */
u32 query_off; /* 24 4 */
u32 query_len; /* 28 4 */
u32 remote_off; /* 32 4 */
u32 remote_len; /* 36 4 */
u32 local_addr_off; /* 40 4 */
u32 local_addr_len; /* 44 4 */
u32 local_port_off; /* 48 4 */
u32 local_port_len; /* 52 4 */
u32 server_name_off; /* 56 4 */
u32 server_name_len; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
u64 content_len; /* 64 8 */
u64 total_content_sent; /* 72 8 */
u32 content_sent; /* 80 4 */
u32 content_off; /* 84 4 */
u32 request_size; /* 88 4 */
u32 nr_fields; /* 92 4 */
u32 tls; /* 96 4 */
char __pad[4]; /* 100 4 */
struct luw_hdr_field fields[]; /* 104 0 */

/* size: 104, cachelines: 2, members: 25 */
/* last cacheline: 40 bytes */
};

We can see the structures have the same layout, same size and no
padding.

We need the __pad member as otherwise I saw gcc and clang on Alpine
Linux automatically add the 'packed' attribute to the structure which
made the two structures not match.

Link: <https://github.com/WebAssembly/memory64>
Link: <https://github.com/nginx/unit-wasm>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
diff 2558:9bcb190bc8be Thu Sep 14 19:35:00 UTC 2023 Andrew Clayton <a.clayton@nginx.com> Wasm: Allow uploads larger than 4GiB.

Currently Wasm modules are limited to a 32bit address space (until at
least the memory64 work is completed). All the counters etc in the
request structure were u32's. Which matched with 32bit memory
limitation.

However there is really no need to not allow >4GiB uploads that can be
saved off to disk or some such.

To do this we just need to increase the ->content_len &
->total_content_sent members to u64's.

However because we need the request structure to have the exact same
layout on 32bit (for Wasm modules) as it does on 64bit we need to re-jig
the order of some of these members and add a four-byte padding member.

Thus the request structure now looks like on 64bit (as shown by
pahole(1))

struct nxt_wasm_request_s {
uint32_t method_off; /* 0 4 */
uint32_t method_len; /* 4 4 */
uint32_t version_off; /* 8 4 */
uint32_t version_len; /* 12 4 */
uint32_t path_off; /* 16 4 */
uint32_t path_len; /* 20 4 */
uint32_t query_off; /* 24 4 */
uint32_t query_len; /* 28 4 */
uint32_t remote_off; /* 32 4 */
uint32_t remote_len; /* 36 4 */
uint32_t local_addr_off; /* 40 4 */
uint32_t local_addr_len; /* 44 4 */
uint32_t local_port_off; /* 48 4 */
uint32_t local_port_len; /* 52 4 */
uint32_t server_name_off; /* 56 4 */
uint32_t server_name_len; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
uint64_t content_len; /* 64 8 */
uint64_t total_content_sent; /* 72 8 */
uint32_t content_sent; /* 80 4 */
uint32_t content_off; /* 84 4 */
uint32_t request_size; /* 88 4 */
uint32_t nfields; /* 92 4 */
uint32_t tls; /* 96 4 */
char __pad[4]; /* 100 4 */
nxt_wasm_http_field_t fields[]; /* 104 0 */

/* size: 104, cachelines: 2, members: 25 */
/* last cacheline: 40 bytes */
};

and the same structure (taken from unit-wasm) compiled as 32bit

struct luw_req {
u32 method_off; /* 0 4 */
u32 method_len; /* 4 4 */
u32 version_off; /* 8 4 */
u32 version_len; /* 12 4 */
u32 path_off; /* 16 4 */
u32 path_len; /* 20 4 */
u32 query_off; /* 24 4 */
u32 query_len; /* 28 4 */
u32 remote_off; /* 32 4 */
u32 remote_len; /* 36 4 */
u32 local_addr_off; /* 40 4 */
u32 local_addr_len; /* 44 4 */
u32 local_port_off; /* 48 4 */
u32 local_port_len; /* 52 4 */
u32 server_name_off; /* 56 4 */
u32 server_name_len; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
u64 content_len; /* 64 8 */
u64 total_content_sent; /* 72 8 */
u32 content_sent; /* 80 4 */
u32 content_off; /* 84 4 */
u32 request_size; /* 88 4 */
u32 nr_fields; /* 92 4 */
u32 tls; /* 96 4 */
char __pad[4]; /* 100 4 */
struct luw_hdr_field fields[]; /* 104 0 */

/* size: 104, cachelines: 2, members: 25 */
/* last cacheline: 40 bytes */
};

We can see the structures have the same layout, same size and no
padding.

We need the __pad member as otherwise I saw gcc and clang on Alpine
Linux automatically add the 'packed' attribute to the structure which
made the two structures not match.

Link: <https://github.com/WebAssembly/memory64>
Link: <https://github.com/nginx/unit-wasm>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
/unit/test/
H A Dconftest.pydiff 1852:74a7d5e98a88 Wed Apr 14 14:56:00 UTC 2021 Andrei Zeliankou <zelenkov@nginx.com> Tests: fixed "skip" descriptors check flag for controller.
H A Dtest_access_log.pydiff 2479:208ef4e1186a Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: "temp_dir" fixture used were possible.
H A Dtest_asgi_websockets.pydiff 2480:63b9663e2f8f Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: assertion related fixes.
H A Dtest_client_ip.pydiff 2478:c08289a08a73 Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: unified setup method usage.

To make fixtures accessible inside of setup methods in tests all these methods
are renamed to the "setup_method_fixture" and decorated by autouse flag.

Also all setup methods moved to the top of the files.
H A Dtest_forwarded_header.pydiff 2478:c08289a08a73 Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: unified setup method usage.

To make fixtures accessible inside of setup methods in tests all these methods
are renamed to the "setup_method_fixture" and decorated by autouse flag.

Also all setup methods moved to the top of the files.
H A Dtest_go_isolation.pydiff 2480:63b9663e2f8f Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: assertion related fixes.
H A Dtest_go_isolation_rootfs.pydiff 2480:63b9663e2f8f Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: assertion related fixes.
H A Dtest_java_application.pydiff 2480:63b9663e2f8f Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: assertion related fixes.
H A Dtest_java_isolation_rootfs.pydiff 2478:c08289a08a73 Thu May 25 15:56:00 UTC 2023 Andrei Zeliankou <zelenkov@nginx.com> Tests: unified setup method usage.

To make fixtures accessible inside of setup methods in tests all these methods
are renamed to the "setup_method_fixture" and decorated by autouse flag.

Also all setup methods moved to the top of the files.

123456