[Libwebsockets] problems with big dynamic content

Per Bothner per at bothner.com
Thu Jun 21 21:55:26 CEST 2018


On 06/16/2018 03:49 PM, Andy Green wrote:
>> (I still have what appears to a server problem where after creating
>> many DomTerm
>> windows creating a new one freezes.  I'm trying to pin that down.  It
>> used to
>> happen much more easily.  I'd say progress - but now it is harder to
>> reproduce ...)
> 
> "freezes" is almost always a placeholder for some more exact description yet unknown.

It looks like a problem with keep-alive.  When I pass an explicit content length
to lws_add_http_common_headers, things are fine for a while.  But on the 3rd or 4th
(sometimes later) terminal window I open I will have the browser hang waiting
for resources.  When I replace the resource length by LWS_ILLEGAL_HTTP_CONTENT_LEN
(as in the minimal-http-server-dynamic.c example) then I don't seem to get that
problem - at least in testing so far.

I.e. it looks like the browser is re-using a connection: after loading the main html
file (with a file: url), then the browser hangs when requesting css and js resources from
the domterm server.  I don't know how the keep-alive protocol is supposed to work, but
somehow the server drops the request - it never calls the callback function.

Another clue that keep-alive is the problem: The main socket that the server listens
on is not waking up (in poll) when I see the hang.  So presumably the request is
coming in on a "kept-alive" socket.  I could add lwsl_notice calls around poll to
try to catch that, but I'd have to figure out how to filter out the noise.

The logic for handling these requests is the same as the minimal-http-server-dynamic.c
example, as far as I can see, but it hangs when using an explicit content-length.

> Valgrind is often good at reporting the first "preliminary madness" with a backtrace, or attach gdb -p (I guess you know all this already...)

Before I started with the lws-based domterm, it had been over a decade since I did much C or C+
programming or used gdb on a regular basis.  (It was mostly Java, JavaScript, or Scheme.)
But recently I've been using gdb more - that is one reason I added a --no-daemonize flag to domterm.

-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the Libwebsockets mailing list