Raphael Kubo da Costa <[email protected]> writes:
> I was working on some code which uses evas_object_image_memfile_set here
> on FreeBSD, and it was failing.
>
> After some investigation, I found out that the problem was in the stat()
> call in evas_cache_image_request.
>
> On Linux, _create_tmpf() open()s a temporary file with O_CREAT,
> unlink()s it and then changes the actual filename to
> /proc/<PID>/fds/<GENERATED-FD>, which exists and reads/writes into the
> file descriptor returned by open().
>
> On non-Linux systems, the filename renaming does not happen (since
> there's usually no /proc with that structure), so unlink() removes the
> file and the stat() in evas_cache_image_request() fails.
I've attached a patch to try to address this.
The idea is to remove the unlink() call in _create_tmpf() and only
remove the file in _cleanup_tmpf(). This has consequences for the Linux
case as well, since the Linux code might also end up creating a file in
/tmp if the attempt to use /dev/shm fails. Since the unlink() is now
made unconditionally, the indirection code which made o->tmpf point to
the process' /proc entry has also been removed, since we can't remove
that.
Index: src/lib/canvas/evas_object_image.c
===================================================================
--- src/lib/canvas/evas_object_image.c (revision 71134)
+++ src/lib/canvas/evas_object_image.c (working copy)
@@ -203,10 +203,7 @@ _cleanup_tmpf(Evas_Object *obj)
o = (Evas_Object_Image *)(obj->object_data);
if (!o->tmpf) return;
-#ifdef __linux__
-#else
unlink(o->tmpf);
-#endif
if (o->tmpf_fd >= 0) close(o->tmpf_fd);
eina_stringshare_del(o->tmpf);
o->tmpf_fd = -1;
@@ -244,7 +241,6 @@ _create_tmpf(Evas_Object *obj, void *data, int siz
close(fd);
return;
}
- unlink(buf);
eina_mmap_safety_enabled_set(EINA_TRUE);
@@ -258,9 +254,6 @@ _create_tmpf(Evas_Object *obj, void *data, int siz
return;
}
o->tmpf_fd = fd;
-#ifdef __linux__
- snprintf(buf, sizeof(buf), "/proc/%li/fd/%i", (long)getpid(), fd);
-#endif
o->tmpf = eina_stringshare_add(buf);
memcpy(dst, data, size);
munmap(dst, size);
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel