summaryrefslogtreecommitdiff
path: root/src/lib/eina_mmap.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-09-27 03:42:08 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-09-27 03:42:08 +0000
commit26024088829a36698c57bf0b05dfc34f42adfc54 (patch)
tree347cbbdb803c4b4023c17125da00addc60186f44 /src/lib/eina_mmap.c
parentbf41a5e786002f2b635921e65c63e2b1af5b3c8b (diff)
backport mmap safety fix.
SVN revision: 77114
Diffstat (limited to 'src/lib/eina_mmap.c')
-rw-r--r--src/lib/eina_mmap.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/eina_mmap.c b/src/lib/eina_mmap.c
index b99a542..90809a2 100644
--- a/src/lib/eina_mmap.c
+++ b/src/lib/eina_mmap.c
@@ -164,10 +164,7 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
164 sa.sa_sigaction = _eina_mmap_safe_sigbus; 164 sa.sa_sigaction = _eina_mmap_safe_sigbus;
165 sa.sa_flags = SA_RESTART | SA_SIGINFO; 165 sa.sa_flags = SA_RESTART | SA_SIGINFO;
166 sigemptyset(&sa.sa_mask); 166 sigemptyset(&sa.sa_mask);
167 /* FIXME: This is rubbish. We return EINA_FALSE whether sigaction 167 if (sigaction(SIGBUS, &sa, NULL) == 0) goto done;
168 * fails or not. And we never set mmap_safe, so we always hit this
169 * code path. */
170 if (sigaction(SIGBUS, &sa, NULL) == 0) return EINA_FALSE;
171 /* setup of SIGBUS handler failed, lets close zero page dev and fail */ 168 /* setup of SIGBUS handler failed, lets close zero page dev and fail */
172 close(_eina_mmap_zero_fd); 169 close(_eina_mmap_zero_fd);
173 _eina_mmap_zero_fd = -1; 170 _eina_mmap_zero_fd = -1;
@@ -176,8 +173,14 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
176 else 173 else
177 { 174 {
178 /* reset signal handler to default for SIGBUS */ 175 /* reset signal handler to default for SIGBUS */
176 if (_eina_mmap_zero_fd >= 0)
177 {
178 close(_eina_mmap_zero_fd);
179 _eina_mmap_zero_fd = -1;
180 }
179 signal(SIGBUS, SIG_DFL); 181 signal(SIGBUS, SIG_DFL);
180 } 182 }
183done:
181 mmap_safe = enabled; 184 mmap_safe = enabled;
182 return mmap_safe; 185 return mmap_safe;
183#endif 186#endif