konqueror embedded from busybox init RESOLUTION

Yan Seiner yan at seiner.com
Thu Mar 9 03:26:37 CET 2006


yan seiner wrote:

> First of all, apologies for cross-posting to both of these, but I am 
> somewhat (OK, totally) stupmed.
>
> I am running konqueror embedded, a browser based on KDE.  It is 
> running on top of Qt/E.
>
> If I launch it from the command line (busybox ash) , all is well.  But 
> if I start it from busybox init, it will crash several times before it 
> finally 'catches'.  This crash occurs in the same way if I start the 
> box cold, or if I kill the konqueror process the machine is completely 
> booted...
>
> The exact number of times it crashes varies; it appears to be around 
> 3.  It crashes consistently at the point of launching the flash 
> plugin.  I've posted a tarball of one of the runs and the html and 
> flash generation code at <http://www.seiner.com/busykonqcrash.tar.gz>.
>
> The only thing I can think of is that there is some sort of timing 
> issue....

I suspect the problem lies in connection.cpp, in  Connection::sendnow.

The code sends a 10 byte header, and then immediately sends the data:

    size_t n = fwrite( buffer, 1, 10, f_out );

...

    n = fwrite( data.data(), 1, data.size(), f_out );

If data.size() is 4096 - the size of the buffer - and the machine is not 
very fast, the receiving end has no chance to empty the buffer and the 
write fails.  Since the write is all or nothing, the connection keeps 
repeating its mistake, and eventually something pukes.

The quick and dirty solution is to stick a usleep(usec); between the 
two, but the better solution would be to write the data, check for 
completeness, and if not done, advance the buffer pointer, usleep some, 
and try to send the rest of the data.  Repeat as necessary, with some 
reasonable timeout.

If that's impossible, the function should send (bufsize - headersize) 
bytes, instead of the full bufsize as now.

As I am the expert in ugly and dirty solutions, I solved my problem by 
the usleep method... Initial testing indicates it works.  :-)

--Yan


More information about the konq-e mailing list