From 8c14de85419f88cbc64e1208269c6ccef8489a23 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Mon, 14 May 2018 15:42:10 +0200 Subject: [PATCH] edje_cc: do not keep the filedescriptor we have a limited number of filedescriptors available, a theme can consist out of a number of groups with scripts, keeping the fd for later use is going above the maximum number of open files, thus use the path of the file, not the fd to access the file. fix T6922 Differential Revision: https://phab.enlightenment.org/D6159 --- src/bin/edje/edje_cc_out.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index f315526e4f..24118e1a98 100644 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c @@ -129,7 +129,7 @@ struct _Script_Write Code *cd; int i; Ecore_Exe *exe; - int tmpn_fd, tmpo_fd; + int tmpn_fd; Eina_Tmpstr *tmpn; Eina_Tmpstr *tmpo; char *errstr; @@ -2054,7 +2054,7 @@ data_thread_script(void *data, Ecore_Thread *thread EINA_UNUSED) int size; char buf[PATH_MAX]; - f = fdopen(sc->tmpo_fd, "rb"); + f = fopen(sc->tmpo, "rb"); if (!f) { snprintf(buf, sizeof(buf), @@ -2129,8 +2129,6 @@ data_thread_script(void *data, Ecore_Thread *thread EINA_UNUSED) eina_tmpstr_del(sc->tmpo); // closed by fclose(f) in create_script_file() // close(sc->tmpn_fd); -// closed by fclose(f) above -// close(sc->tmpo_fd); } typedef struct @@ -2275,6 +2273,7 @@ data_write_scripts(Eet_File *ef) { Code *cd = eina_list_data_get(l); Script_Write *sc; + int fd; char buf[EINA_PATH_MAX]; if (cd->is_lua) @@ -2289,14 +2288,18 @@ data_write_scripts(Eet_File *ef) if (sc->tmpn_fd < 0) error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.", sc->tmpn); - sc->tmpo_fd = eina_file_mkstemp("edje_cc.amx-tmp-XXXXXX", &sc->tmpo); - if (sc->tmpo_fd < 0) + fd = eina_file_mkstemp("edje_cc.amx-tmp-XXXXXX", &sc->tmpo); + if (fd < 0) { unlink(sc->tmpn); eina_tmpstr_del(sc->tmpn); error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.", sc->tmpo); } + //do not carry the fd over the time + //we should not unnesseserrily carry filedescriptors over time as this could excede system limits + //which have been fetched earlier + close(fd); create_script_file(ef, sc->tmpn, cd, sc->tmpn_fd); snprintf(buf, sizeof(buf), "%s -i %s -o %s %s", embryo_cc_path, inc_path,