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

Colin Cross colin at colincross.com
Tue Sep 28 01:32:13 EDT 2004


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: network-frontend-patch.diff
Type: text/x-patch
Size: 5083 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040928/552413e4/network-frontend-patch-0001.bin


More information about the mythtv-dev mailing list