[Libwebsockets] recent changes breaking DomTerm

Per Bothner per at bothner.com
Thu Jan 25 02:59:28 CET 2018

On 01/24/2018 05:16 PM, Andy Green wrote:
> On 25/01/18 09:05, Andy Green wrote:
>> I guess your HEAD (3623ee96eb6c0ab552483ca14d1919fcfe81d874) doesn't have whatever fix you made for the actual back-to-back write that you mentioned you fixed up, because it still blows there.  But the backtrace shows it's inside the WRITABLE callback suggesting it's a real problem.
> This kind of thing won't fly (write_to_browser calls lws_write())
>                  write_to_browser(wsi, p, strlen(p), false);
>                  if (pclient->saved_window_contents != NULL) {
>                    int rcount = pclient->preserved_sent_count;
>                    char *buf = xmalloc(strlen(pclient->saved_window_contents)+40);
>                    sprintf(buf+LWS_PRE,
>                            URGENT_START_STRING "\033]103;%d,%s\007" URGENT_END_STRING,
>                            pclient->preserved_sent_count,
>                            pclient->saved_window_contents);
>                    int rlen = strlen(buf+LWS_PRE);
>                    write_to_browser(wsi, buf+LWS_PRE, rlen, false);
> ...
> if it's common more than one case will want to write, I suggest you concatenate them into the tx buffer and then write once at the end if anything wrote in the tx buffer.  Otherwise you can only send one and ask for another writable callback if you detect something more to do.

I'll look into it.  However, I'm pretty sure that is not where the problem is.
That code is in the websockets communication - and that specific code is
only when attaching a window to a previously saved connection.
I.e. we're de-serializing a previous serialized terminal session.
(Possibly the previous connection was detached; possibly we're creating
a second view on the same session.  Also, atom-domterm does a lot of
implicit detaching when moving panes around.)

I'm seeing 'could_have_pending' failures when serving the http resources (javascript,
css, and the initial html file).  This happens before we set up websockets connection.
The former logic is in http.c.
	--Per Bothner
per at bothner.com   http://per.bothner.com/

More information about the Libwebsockets mailing list