This works when listening on a single socket, right?

While that is ok for some use cases, if you want to have the advertised address of a listen socket, then this can be coded in a different way, by saving socket->useinfo.sock_str instead of socket->sock_str.

If you still want to have a parameter like in your patch, it is fine for me, even it has rather limited usage, but in this case I think it should use a static variable in pack_ci() function, like all the other variables in the function that are used outside, to avoid the pkg_malloc() and the pkg_free(), so declare:

static struct socket_info si = {0};

Then have something like:

		if (sock_addr.len>0) {
			memset(&si, 0, sizeof(struct socket_info));
			si.sock_str = sock_addr;
			ci.sock = &si;
...

Then IF blocks to do pkg_free(si); and pkg_free(ci->sock); should dissapear, having the changes only inside the pack_ci() function.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.