Skip to content

Add listen-address parameter#15

Merged
aburgm merged 1 commit intogobby:masterfrom
1uks:listen-address
May 11, 2016
Merged

Add listen-address parameter#15
aburgm merged 1 commit intogobby:masterfrom
1uks:listen-address

Conversation

@1uks
Copy link
Copy Markdown

@1uks 1uks commented May 1, 2016

These changes allow users to specify the IP address to listen on.

g_free(options->certificate_file);
g_free(options->certificate_chain_file);
g_free(options->root_directory);
inf_ip_address_free(options->listen_address);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need a NULL check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to malloc(3) free(NULL) does nothing, therefore the check is not strictly required as far as I understand.

Copy link
Copy Markdown
Contributor

@aburgm aburgm May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is not free, it is inf_ip_address_free, which does not like a NULL argument. Or at least it's not documented to. It uses g_slice_free under the hood, which apparently handles NULL fine, but in general the *_free functions in libinfinity don't.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was told that it is usual for functions that free memory to handle NULL themselves, therefore it might be a good idea to just do the same for the libinfinity free functions if they need it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, but it's more important to stay consistent within this PR. If I'm not mistaken some glib free functions such as g_object_unref don't handle NULL arguments either.

@aburgm
Copy link
Copy Markdown
Contributor

aburgm commented May 1, 2016

Thanks for the patch, this looks very solid to me!

The only thing that's missing is support for config reloading. Infinoted reloads the config file when it receives SIGHUP, so that config changes can be applied without restarting the server. The code for that is in infinoted/infinoted-config-reload.c, and it would need to support for the listen address as well, otherwise the server would fall back to listen on any address if the config file gets reloaded even if a listen address was specified in the config file. The code for that is very similar to the one in infinoted-run.c, and I'd like for it to be shared, but it's not...

Another note: Some systems don't listen automatically on IPv4 if a IPv6 socket is created, which is why the existing code was trying to create both sockets (it's a setting somewhere in /sys or /proc, I forgot, and (some versions of?) Windows do it, too). This "automatically-also-listen-on-IPv4" functionality would now be lost in case that setting is turned off and one specifies an IPv6 address in the options. That could be fixed by allowing to specify a list of IP addresses to listen on (or just an IPv4 and IPv6 one separately), but I'd happily merge the PR without that.

@tyll
Copy link
Copy Markdown
Contributor

tyll commented May 10, 2016

@1uks 1uks told me that the configuration reload does not work for him right now. Would it be ok for you to just change the reload code to not close and re-open the sockets or maybe remove the feature completely? I am not sure about its use case. If the server connection is closed/re-opened anyhow, then the service could be restarted complety instead. I the typical use case I know is when using old-style log files with logrotating and making services write to the new log file. But I am not sure that this applies here - and it would not require re-opening the sockets.

@aburgm
Copy link
Copy Markdown
Contributor

aburgm commented May 10, 2016

It is only the listening socket(s) that are re-opened; already existing connections are not terminated. So there is some value in that feature as opposed to just restarting the service. I agree it has always been a bit fragile. I'd expect this to be fairly simple. Will try to have a quick look tonight myself, and if it doesn't work out quickly let's go without for now.

@aburgm aburgm merged commit 8f8c161 into gobby:master May 11, 2016
@aburgm
Copy link
Copy Markdown
Contributor

aburgm commented May 11, 2016

I pushed this to master and just added a simple check for the config reloading to show an error message if one tries to change the listen address.

@tyll
Copy link
Copy Markdown
Contributor

tyll commented May 11, 2016

Thank you for merging it so fast! Do you have any plans for a new release soon? Could you maybe spin a release when PR #16 is merged?

@aburgm
Copy link
Copy Markdown
Contributor

aburgm commented May 12, 2016

I had some other things in mind for a 0.7 release, but I don't think I'll get to those anytime soon. So yes, will see if I can do that this weekend.

@tyll
Copy link
Copy Markdown
Contributor

tyll commented May 12, 2016

Thank you

@aburgm
Copy link
Copy Markdown
Contributor

aburgm commented May 16, 2016

I'm sorry, didn't get to it this weekend. Will do it soonish, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants