mmenu; just to be sure we dont' collide with pndnotifyd for this /tmp/iconcache scan
authorskeezix <skeezix@flotsam-vm.(none)>
Tue, 1 Feb 2011 19:01:39 +0000 (14:01 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Tue, 1 Feb 2011 19:01:39 +0000 (14:01 -0500)
minimenu/mmcache.c

index 2cc9431..6816242 100644 (file)
@@ -260,8 +260,9 @@ unsigned char cache_icon ( pnd_disco_t *app, unsigned char maxwidth, unsigned ch
 
     sprintf ( ovrfile, "%s/%s.png", iconpath, app -> unique_id );
 
+    // making sure the file is at least a few seconds old, to help avoid race condition
     struct stat statbuf;
-    if ( stat ( ovrfile, &statbuf ) == 0 ) {
+    if ( stat ( ovrfile, &statbuf ) == 0 && time ( NULL ) - statbuf.st_mtime > 5 ) { // race with pndnotifyd
       buflen = statbuf.st_size;
       if ( ( iconbuf = malloc ( statbuf.st_size ) ) ) {
        int fd = open ( ovrfile, O_RDONLY );