i'm putting this here so it doesn't get lost.
thanks tom! -spot
-----------------------------
A few more small patches proposed against CVS tip:
In DownloadThread.m: I've been seeing the attempt to delete an old anim
file fail every so often. I'm not sure why; I added a
shouldProceedAfterError callback to try to find out, and so far all it
gives me is
2007-03-29 23:08:00.950 ScreenSaverEngine[372] File deletion error: Error removing with file: /Users/tgl/Library/Application Support/ElectricSheep/00202=65681=65620=65181.mpg
which isn't real informative. But the problem is that DownloadThread
locks up when it happens because it goes into an infinite loop. I have
also seen it escape out of that section, leaving the cachedAnims lock
held which of course brings the whole thing to a halt. The patch adds
the callback (for what it's worth), puts in an @try/@finally construct
to ensure the lock is released, and tweaks the loop to not repeat after
a deletion failure.
In ElectricSheep.m: add a check on _nextAnim == nil; prevents a crash
I've seen occasionally.
In VoteThread.m: voting is broken in CVS tip, when you try you get this
in the log:
2007-03-30 20:49:45.042 ScreenSaverEngine[465] Vote: http://(null)/cgi/vote?id=73215&vote=1&u=7AED3C973039EBD5&v=OSX_2.7b1
I suppose this is because the recent changes for v2d7 are incomplete.
It works for me after applying the patch. I believe that uploadFlame
in RenderThread.m has got the same problem, but I have not seen it fail
because my machine doesn't seem to want to render anything at all ---
some other recently-introduced bug, I think, but haven't found it.
regards, tom lane
Index: DownloadThread.m
===================================================================
RCS file: /cvsroot/electricsheep/client_osx/DownloadThread.m,v
retrieving revision 1.34
diff -c -r1.34 DownloadThread.m
*** DownloadThread.m 1 Dec 2006 07:31:49 -0000 1.34
--- DownloadThread.m 31 Mar 2007 01:38:42 -0000
***************
*** 640,645 ****
--- 640,654 ----
}
+ - (BOOL)fileManager:(NSFileManager *)manager shouldProceedAfterError:(NSDictionary *)errorInfo
+ {
+ NSLog(@"File deletion error: %@ with file: %@",
+ [errorInfo objectForKey:@"Error"],
+ [errorInfo objectForKey:@"Path"]);
+ return NO;
+ }
+
+
// expungeAnim
// Removes an animation from the disk cache and from the list of cached animations
// Returns YES if removed successfully, NO if the animation does not exist or could not be
***************
*** 660,666 ****
if (debug)
NSLog(@"deleting %@", path);
! deleteResult = [fm removeFileAtPath:path handler:nil];
if (deleteResult == YES) {
[anim setDeleted:1];
[anim setChecked:0];
--- 669,675 ----
if (debug)
NSLog(@"deleting %@", path);
! deleteResult = [fm removeFileAtPath:path handler:self];
if (deleteResult == YES) {
[anim setDeleted:1];
[anim setChecked:0];
***************
*** 708,713 ****
--- 717,723 ----
NSLog(@"begin delete cached");
[cachedAnims lock];
+ @try {
numAnims = [cachedAnims numberOfAnims];
do {
worstDate = [NSDate distantFuture];
***************
*** 738,749 ****
BOOL deleteResult = [self expungeAnim:worstAnim];
if (deleteResult == YES)
{
! total = total - worstAnimSize;
numAnims--;
! };
! };
} while (maxCacheSize != 0 && total > maxCacheSize);
[cachedAnims unlock];
if (debug)
NSLog(@"end delete cached");
--- 748,765 ----
BOOL deleteResult = [self expungeAnim:worstAnim];
if (deleteResult == YES)
{
! // adjust total to avoid an extra trip through the loop
! total -= worstAnimSize;
numAnims--;
! }
! else
! break; // to avoid infinite loop
! }
} while (maxCacheSize != 0 && total > maxCacheSize);
+ }
+ @finally {
[cachedAnims unlock];
+ }
if (debug)
NSLog(@"end delete cached");
Index: ElectricSheep.m
===================================================================
RCS file: /cvsroot/electricsheep/client_osx/ElectricSheep.m,v
retrieving revision 1.90
diff -c -r1.90 ElectricSheep.m
*** ElectricSheep.m 1 Dec 2006 07:31:49 -0000 1.90
--- ElectricSheep.m 31 Mar 2007 01:38:42 -0000
***************
*** 1827,1833 ****
[loopSuccs clearSet];
// If fuse is out, reset fuse and pick random animation
! if (resetFuse-- <= 0 || nRepeats >= max_repeats || [self check_for_eddy]) {
if (debug) printf("reset nrepeated=%d reset_fuse=%d\n", nRepeats, resetFuse);
[self initCurrentAnim];
} else {
--- 1827,1833 ----
[loopSuccs clearSet];
// If fuse is out, reset fuse and pick random animation
! if (resetFuse-- <= 0 || nRepeats >= max_repeats || _nextAnim == nil || [self check_for_eddy]) {
if (debug) printf("reset nrepeated=%d reset_fuse=%d\n", nRepeats, resetFuse);
[self initCurrentAnim];
} else {
Index: VoteThread.m
===================================================================
RCS file: /cvsroot/electricsheep/client_osx/VoteThread.m,v
retrieving revision 1.14
diff -c -r1.14 VoteThread.m
*** VoteThread.m 1 Dec 2006 07:31:50 -0000 1.14
--- VoteThread.m 31 Mar 2007 01:38:42 -0000
***************
*** 167,177 ****
[data getBytes:&vote range:NSMakeRange(0, sizeof(int))];
[data getBytes:&animID range:NSMakeRange(sizeof(int), sizeof(int))];
[voteQueue removeObjectAtIndex:0];
// Create URL
NSString *url = [NSString stringWithFormat:
@"http://%@/cgi/vote?id=%d&vote=%d&u=%@&v=%@",
! [[sheep defaults] stringForKey:DreamServerK |