[mythtv] [PATCH] util.cpp: Fix EOF readStringList on USB 802.11b

Holger Buchfink avalanche at beyondmonkey.com
Wed Sep 29 19:12:38 EDT 2004


Colin Cross wrote:
> As promised, here's a patch that cleans up the network code in util.cpp 
> used by the frontend (all the functions that work on a QSocketDevice).
> 
> I think I figured out why the old code was written to fail on 100 reads 
> instead of 100 reads of zero bytes.  The variable "zerocnt" suggests it 
> was originally supposed to do the latter, but it was written to do the 
> former.  My guess is that sometime during development it was getting 
> stuck in an infinte loop there because the socket->readBlock was 
> returning -1 on some error, but it was never being checked.  It would 
> happily decrement the number of bytes read and repeat.
> 
> Summary of changes:
>    Check the return values for errors
>    Report errors using VERBOSE instead of printf
>    Count up to number of bytes to send/receive consistently
>    Remove all unnecessary usleeps before blocking calls
> 
> The result should be more readable, more efficient, and fix my problem 
> with my frontend on a USB 802.11b adapter.  It does, however, make some 
> changes that may show up in strange places if those usleep's were 
> preventing race conditions in other code.  My frontend still works fine 
> with this code.
> 
> If this is acceptable, I can make the same changes to the QSocket 
> functions used by the backend.

I committed some changes that should take care of your issues and hopefully
not break stuff for other people. Just relying on the QSocketDevice return
codes and removing the usleeps will cause trouble, most likely for hdtv. Keep
in mind that combined frontend/backend setups still use the network path.

Holger


More information about the mythtv-dev mailing list