Re: bug in state-from-file with resolvers?

2016-01-19 Thread Baptiste
On Sat, Jan 16, 2016 at 7:52 PM, Nenad Merdanovic  wrote:
> Forgot to add the ML :/
>
> On 01/16/2016 07:43 PM, Nenad Merdanovic wrote:
>> Hello Robert,
>>
>> + Baptiste
>>
>>>
>>> Connect() failed for backend bk: no free ports.
>>>
>>> If you comment out either the load-server-state-from-file line or remove 
>>> 'resolvers dns' from the end of the server line, then the backend works 
>>> correctly.
>>>
>>
>> This happens because of:
>> server.c:2156
>> /* update server IP only if DNS resolution is used on the server */
>> if (srv->resolution) {
>> memset(, 0, sizeof(struct sockaddr_storage));
>> if (str2ip2(params[0], , 0))
>> memcpy(>addr, , sizeof(struct sockaddr_storage));
>>
>> str2ip2 doesn't work with ports (and there are none in the dump file),
>> yet we overwrite the whole struct.
>>
>> Few options I see:
>> 1. Dump the port to the state file, use str2sa_range
>> 2. Check the ss_family of 'addr', memcpy only the address
>>
>> And my personal favorite
>> 3. Just (ab)use something like "server_parse_addr_change_request(srv,
>> params[0]);" with a small change so it accepts the 'updater' also, which
>> could say 'server-state' or something.
>>
>>> The same behaviour with 1.7-dev1, and I encounter the issue on Linux and 
>>> OSX.
>>>
>>> It’s worth noting that "show servers state" returns nothing if there are a 
>>> lot of backends, hence I’m using the 'local' option.
>>>
>>>
>>> B.
>>>
>>
>> Regards,
>> Nenad
>>


Hi guys,

Good catch nenad :)
I may use solution #2 for now. I'll provide a patch asap for this bug.

That said, I'm working on a function which allow changing the server
port at run time using the stats socket.
It will be able to match if a port is provided or not and update both
ADDR and/or PORT accordingly (and will be compatible with AF_UNIX).

Baptiste



Re: bug in state-from-file with resolvers?

2016-01-16 Thread Nenad Merdanovic
Forgot to add the ML :/

On 01/16/2016 07:43 PM, Nenad Merdanovic wrote:
> Hello Robert,
> 
> + Baptiste
> 
>>
>> Connect() failed for backend bk: no free ports.
>>
>> If you comment out either the load-server-state-from-file line or remove 
>> 'resolvers dns' from the end of the server line, then the backend works 
>> correctly.
>>
> 
> This happens because of:
> server.c:2156
> /* update server IP only if DNS resolution is used on the server */
> if (srv->resolution) {
> memset(, 0, sizeof(struct sockaddr_storage));
> if (str2ip2(params[0], , 0))
> memcpy(>addr, , sizeof(struct sockaddr_storage));
> 
> str2ip2 doesn't work with ports (and there are none in the dump file),
> yet we overwrite the whole struct.
> 
> Few options I see:
> 1. Dump the port to the state file, use str2sa_range
> 2. Check the ss_family of 'addr', memcpy only the address
> 
> And my personal favorite
> 3. Just (ab)use something like "server_parse_addr_change_request(srv,
> params[0]);" with a small change so it accepts the 'updater' also, which
> could say 'server-state' or something.
> 
>> The same behaviour with 1.7-dev1, and I encounter the issue on Linux and OSX.
>>
>> It’s worth noting that "show servers state" returns nothing if there are a 
>> lot of backends, hence I’m using the 'local' option.
>>
>>
>> B.
>>
> 
> Regards,
> Nenad
>