[Libwebsockets] Next lws release coming up

Per Bothner per at bothner.com
Fri Apr 27 02:39:30 CEST 2018


On 04/26/2018 05:13 PM, Andy Green wrote:
> 
> 
> On 04/27/2018 07:47 AM, Per Bothner wrote:
> 
> Thanks.
> 
>> info->port = vhost->listen_port;
> 
> It's not the "right" solution, since info should be const (I am going through making it const atm).

It's a tradeoff betwen backwards compatibility vs cleaner API.
  
> Can you print what is in info->port before and after that line?  I am having trouble imagining what that is doing to fix the problem.

At the entry to lws_context_init_server, info->port is 0.
The old code did:

     n = lws_socket_bind(vhost, sockfd, info->port, info->iface);
     if (n < 0)
         goto bail;
     info->port = n;
     ...
     vhost->listen_port = info->port;

The new code does:

     is = lws_socket_bind(vhost, sockfd, vhost->listen_port, vhost->iface);
     ...
     vhost->listen_port = is;
     ....

This means when lws_context_init_server returns, info->port is still 0,
while with the old code it is the same as vhost->listen_port.

When I grep the DomTerm sources, I find these suspicious lines:

protocol.c:    display_session(opts, pclient, NULL, info.port);
protocol.c:    display_session(opts, pclient, NULL, info.port);
server.c:                port_specified = info.port;
server.c:                if (info.port < 0) {
server.c:    info.port = 0;
server.c:    make_html_file(info.port);
server.c:                info.port, info.port);

and in server.h:

extern struct lws_context_creation_info info; // FIXME rename

I'm guessing I should change info.port to vhost->listen_port
most places after the call to lws_create_context.
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the Libwebsockets mailing list