Commit Graph

32 Commits

Author SHA1 Message Date
Alejandro Colomar
ebf02266a2 Removed the unsafe nxt_memchr() wrapper for memchr(3).
The casts are unnecessary, since memchr(3)'s argument is 'const void *'.
It might have been necessary in the times of K&R, where 'void *' didn't
exist.  Nowadays, it's unnecessary, and _very_ unsafe, since casts can
hide all classes of bugs by silencing most compiler warnings.

The changes from nxt_memchr() to memchr(3) were scripted:

$ find src/ -type f \
  | grep '\.[ch]$' \
  | xargs sed -i 's/nxt_memchr/memchr/'

Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-04 00:30:50 +01:00
Alejandro Colomar
1b05161107 Removed the unsafe nxt_memcmp() wrapper for memcmp(3).
The casts are unnecessary, since memcmp(3)'s arguments are 'void *'.
It might have been necessary in the times of K&R, where 'void *' didn't
exist.  Nowadays, it's unnecessary, and _very_ unsafe, since casts can
hide all classes of bugs by silencing most compiler warnings.

The changes from nxt_memcmp() to memcmp(3) were scripted:

$ find src/ -type f \
  | grep '\.[ch]$' \
  | xargs sed -i 's/nxt_memcmp/memcmp/'

Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-04 00:30:27 +01:00
Alejandro Colomar
7e4a8a5422 Disallowed abstract unix socket syntax in non-Linux systems.
The previous commit added/fixed support for abstract Unix domain sockets
on Linux with a leading '@' or '\0'.  To be consistent in all platforms,
treat those prefixes as markers for abstract sockets in all platforms,
and fail if abstract sockets are not supported by the platform.

That will avoid mistakes when copying a config file from a Linux system
and using it in non-Linux, which would surprisingly create a normal socket.
2022-08-18 18:58:41 +02:00
Alejandro Colomar
22c5100666 Removed dead code.
nxt_sockaddr_ntop() stopped being used in commit (git) 029942f4eb.
It has been replaced mostly by nxt_sockaddr_text().

    commit 029942f4eb
    Author: Igor Sysoev <igor@sysoev.ru>
    Date:   Wed Feb 22 15:09:59 2017 +0300

        I/O operations refactoring.

nxt_job_sockaddr_parse() stopped being used in commit (git) 794248090a.

    commit 794248090a
    Author: Igor Sysoev <igor@sysoev.ru>
    Date:   Wed Mar 4 14:04:08 2020 +0300

        Legacy upstream code removed.

Also, remove functions and types used only by those two functions:

nxt_job_sockaddr_unix_parse()
nxt_job_sockaddr_inet6_parse()
nxt_job_sockaddr_inet_parse()
nxt_job_sockaddr_parse_t
nxt_job_resolve()
nxt_job_resolve_t
2022-08-11 18:43:12 +02:00
Alejandro Colomar
6ba39ccf9b Fixed incorrect code.
The #endif was misplaced by accident during a refactor:
<029942f4eb>.

clang(1)'s -Wunreachable-code-break (implied by -Weverything) catches
that, but it is only produced for code compiled without support
for Unix sockets, which is probably the reason it was undetected:
no-one seems to be compiling Unit without Unix sockets support (at
least with clang(1)).
2022-07-18 19:09:30 +02:00
Andrew Clayton
7a286ec079 Socket: removed useless port < 1 check.
In src/nxt_sockaddr.c::nxt_job_sockaddr_inet_parse() there is a check
that port > 0 then there is a check that port < 1 || port > 65535, well
we _know_ it can't be less than 1.
2022-06-22 00:30:44 +02:00
Oisin Canty
73ea6a1c3a Introduced nxt_sockaddr_parse_optport() for addresses w/o ports. 2021-08-12 08:23:09 +00:00
Oisin Canty
7d2bc04e39 Fixing crash during IPv6 text address generation.
When the textual representation of an IPv6 nxt_sockaddr_t was being
generated, a crash would occur if the address had a full IPv6 form:

f607:7403:1e4b:6c66:33b2:843f:2517:da27

This was caused by a variable that tracks the location of a
collapsed group ("::") that was not set to a sane default.  When
the address was generated, a group would be inserted when
it was not necessary, thus causing an overflow.

This closes #481 issue on GitHub.
2021-07-02 10:55:13 +00:00
Axel Duch
8677bf8d41 Router: introducing routing on client address. 2019-12-24 13:58:10 +00:00
Igor Sysoev
07c007af57 Event engine memory cache refactored. 2019-11-14 16:39:48 +03:00
Andrey Zelenkov
22de5fcddf Style. 2019-03-11 17:31:59 +03:00
Igor Sysoev
ab5b67b45d Fixed typo.
This closes #165 issue on GitHub.
Thanks to 洪志道 (Hong Zhi Dao).
2018-09-17 16:37:11 +03:00
Valentin Bartenev
1a52d876f7 Introduced nxt_length() macro. 2018-06-25 16:51:47 +03:00
Valentin Bartenev
0665896a55 Style: capitalized letters in hexadecimal literals. 2018-04-04 18:13:05 +03:00
Sergey Kandaurov
67c64a99fb Using size_t for the field width type of the "%*s" specifier. 2018-01-24 15:16:32 +03:00
Igor Sysoev
09ef66d39c Storing memory cache slot hint inside nxt_sockaddr_t. 2017-10-17 16:22:38 +03:00
Igor Sysoev
bfa808d689 Event engine memory cache for nxt_sockaddr_t.
Introducing event engine memory cache and using the cache for
nxt_sockaddr_t structures.
2017-09-27 19:22:59 +03:00
Ruslan Ermilov
23d38a5794 Corrected path to nxt_socket.h in comments. 2017-08-16 14:16:14 +03:00
Igor Sysoev
46c6513c2b Fixed port processing in nxt_sockaddr_text(). 2017-06-29 19:25:46 +03:00
Igor Sysoev
61c20aae4b Small optimization in nxt_sockaddr_text(). 2017-06-28 09:33:35 +03:00
Igor Sysoev
2006e9f537 Fixed INET6 sockaddr processing in nxt_sockaddr_text(). 2017-06-27 20:06:59 +03:00
Igor Sysoev
cf3e714c39 Fixed Unix sockaddr processing in nxt_sockaddr_text(). 2017-06-27 20:06:56 +03:00
Igor Sysoev
9041d276fc nxt_sockaddr_parse() introducted. 2017-06-27 19:06:58 +03:00
Valentin Bartenev
dfd3cc8c0e Applied nxt_pointer_to() and nxt_value_at() where possible. 2017-06-27 17:27:18 +03:00
Valentin Bartenev
9593ce769a Removed surplus type casting from nxt_memcmp() calls. 2017-06-21 22:45:20 +03:00
Igor Sysoev
f888a5310c Using new memory pool implementation. 2017-06-20 19:49:17 +03:00
Igor Sysoev
6f2c9acd18 Processes refactoring.
The cycle has been renamed to the runtime.
2017-03-09 18:03:27 +03:00
Igor Sysoev
029942f4eb I/O operations refactoring. 2017-02-22 15:09:59 +03:00
Igor Sysoev
6e67bee0f4 nxt_str_t changes. 2017-02-01 19:20:07 +03:00
Igor Sysoev
ba0391577b Work queues refactoring. 2017-01-27 11:35:11 +03:00
Igor Sysoev
de532922d9 Introducing tasks. 2017-01-23 19:56:03 +03:00
Igor Sysoev
16cbf3c076 Initial version. 2017-01-17 20:00:00 +03:00