mirror of
https://github.com/haproxy/haproxy.git
synced 2026-02-20 00:10:41 -05:00
MINOR: tools: preset the port of fd-based "sockets" to zero
Addresses made of a file descriptor store the file descriptor into the address part of a sin_addr. Contrary to other address classes, there's no way to figure later based on the FD if an initialization was done (which is how logs initialize their FDs). The port part is currently left with random data, so let's instead specifically set the port part to zero when creating an FD, and let the code using it set whatever info it needs there, typically an initialization state.
This commit is contained in:
parent
cc79ed28f6
commit
0205a4e0b5
1 changed files with 2 additions and 0 deletions
|
|
@ -900,6 +900,7 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||
str2 += 9;
|
||||
|
||||
((struct sockaddr_in *)&ss)->sin_addr.s_addr = strtol(str2, &endptr, 10);
|
||||
((struct sockaddr_in *)&ss)->sin_port = 0;
|
||||
|
||||
if (!*str2 || *endptr) {
|
||||
memprintf(err, "file descriptor '%s' is not a valid integer in '%s'\n", str2, str);
|
||||
|
|
@ -914,6 +915,7 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||
|
||||
str2 += 3;
|
||||
((struct sockaddr_in *)&ss)->sin_addr.s_addr = strtol(str2, &endptr, 10);
|
||||
((struct sockaddr_in *)&ss)->sin_port = 0;
|
||||
|
||||
if (!*str2 || *endptr) {
|
||||
memprintf(err, "file descriptor '%s' is not a valid integer in '%s'\n", str2, str);
|
||||
|
|
|
|||
Loading…
Reference in a new issue