pan-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pan-devel] PATCH to close cache files before unlinking


From: John Morris
Subject: Re: [Pan-devel] PATCH to close cache files before unlinking
Date: Thu, 19 Sep 2002 09:34:30 -0500

oops, slight mishap with the patch I sent.  Use this one instead.  
Also, I noticed that the "entry" parameter of
acache_get_message_file_stream() is decalred const, which causes a
compiler warning since I am setting a member in the entry structure.  
Maybe this isn't such a good place to do this?

Anyway this revised patch checks that the cache file is actually open
before closing it.


John Morris
address@hidden

Patch follows:
 
--- pan/base/acache.c.org       2002-09-19 02:41:07.000000000 -0500
+++ pan/base/acache.c   2002-09-19 09:25:38.000000000 -0500
@@ -71,6 +71,7 @@
 typedef struct
 {
        AcachePath * path;
+        FILE * file_ptr;
        int refcount;
        char * message_id;
        size_t size;
@@ -325,6 +326,7 @@
 
        /* remove the file */
        acache_get_filename (filename, sizeof(filename), entry->path->path, 
entry->message_id);
+        if (entry->file_ptr) fclose(entry->file_ptr);
        unlink (filename);
 }
 
@@ -637,6 +639,7 @@
                else
                {
                        GMimeStream * file_stream = g_mime_stream_file_new (fp);
+                        entry->file_ptr=fp;
                        retval = g_mime_stream_buffer_new (file_stream, 
GMIME_STREAM_BUFFER_BLOCK_READ);
                        g_object_unref (file_stream);
                }
@@ -855,6 +858,7 @@
 
                                        entry = (AcacheEntry*) memchunk_alloc 
(acache_entry_chunk);
                                        entry->path = apath;
+                                        entry->file_ptr=NULL;
                                        entry->message_id = g_strdup 
(message_id);
                                        entry->size = stat_p.st_size;
                                        entry->date = stat_p.st_mtime;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]