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

[Tracker] Letting the TIFF extractor use posix_fadvise



This is a patch that makes the tiff extractor use the posix_fadvise too.

Note that TIFFClose() does close() itself. You can't mix TIFFClose()
with tracker_file_close, as tracker_file_close also does the close()
call using fclose().

So this is a problem, as the FILE* part is leaked this way. Perhaps we
could reopen the fd so that fclose() would work fine?

Suggestions? We aren't applying this patch just yet btw.

-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 65bba39..7aecb3e 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -21,6 +21,13 @@
 
 #include "config.h"
 
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <limits.h>
+
 #include <glib.h>
 #include <glib/gstdio.h>
 
@@ -104,10 +111,13 @@ date_to_iso8601 (gchar *date)
 	return tracker_date_format_to_iso8601 (date, EXIF_DATE_FORMAT);
 }
 
+
 static void
 extract_tiff (const gchar *filename, 
 	      GHashTable  *metadata)
 {
+	FILE	    *f;
+	int          fd;
 	TIFF *image;
 	glong exifOffset;
 
@@ -133,8 +143,15 @@ extract_tiff (const gchar *filename,
 	guint32 size;
 #endif /* HAVE_EXEMPI */
 
-	if ((image = TIFFOpen (filename, "r")) == NULL){
-		g_critical ("Could not open image:'%s'\n", filename);
+	f = tracker_file_open (filename, "r", FALSE); 
+
+	if (!f) {
+		return;
+	}
+
+	fd = fileno (f);
+
+	if ((image = TIFFFdOpen(fd, filename, "r")) == NULL){
 		return;
 	}
 
@@ -279,7 +296,12 @@ extract_tiff (const gchar *filename,
 		g_free (date);
 	}
 
+#ifdef HAVE_POSIX_FADVISE
+	posix_fadvise (fd, 0, 0, POSIX_FADV_DONTNEED);
+#endif
+
 	TIFFClose (image);
+
 }
 
 TrackerExtractData *


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