summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-26 13:18:22 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-26 13:21:50 +0900
commit93a683daad30bdf4440efaa0a1c5bffcb81f53ef (patch)
tree9a621e46d645459e4b303e2e4cc984a22f373f2d
parente2093f788600e64fe17ee4d79d89e23e2127676c (diff)
evas and ecore_x shm segment management - fix over allocation and perms
so our sysv shm segments were both over-permissive (nothing bad really, just other users could read and write to/from our pixel data destined for the screen... they could do this to x11 directly anyway so no real issue), but be more restrictive and use 0600 as xserver runs as root so can read/write anyway and we only want our own uid access. but even more - fix our shm segment flushing to not keep lots of segments floating about like a bad smell when we don't need them. we had a cache but it wasnt flushed when it should be since async rendering turned up. this fixes that and we're back to agressively flushing them out when idle. @fix
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_image.c4
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_image.c4
-rw-r--r--src/modules/evas/engines/software_x11/evas_engine.h1
-rw-r--r--src/modules/evas/engines/software_x11/evas_xcb_buffer.c2
-rw-r--r--src/modules/evas/engines/software_x11/evas_xcb_outbuf.c64
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_buffer.c2
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_outbuf.c72
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_swapper.c2
8 files changed, 121 insertions, 30 deletions
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_image.c b/src/lib/ecore_x/xcb/ecore_xcb_image.c
index 67a1470..b6ac6ff 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_image.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_image.c
@@ -621,7 +621,7 @@ _ecore_xcb_image_shm_check(void)
621 } 621 }
622 622
623 shminfo.shmid = 623 shminfo.shmid =
624 shmget(IPC_PRIVATE, img->stride * img->height, (IPC_CREAT | 0666)); 624 shmget(IPC_PRIVATE, img->stride * img->height, (IPC_CREAT | 0600));
625 if (shminfo.shmid == (uint32_t)-1) 625 if (shminfo.shmid == (uint32_t)-1)
626 { 626 {
627 xcb_image_destroy(img); 627 xcb_image_destroy(img);
@@ -675,7 +675,7 @@ _ecore_xcb_image_shm_create(Ecore_X_Image *im)
675 im->depth, NULL, ~0, NULL); 675 im->depth, NULL, ~0, NULL);
676 if (!im->xim) return; 676 if (!im->xim) return;
677 677
678 im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0666)); 678 im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0600));
679 if (im->shminfo.shmid == (uint32_t)-1) 679 if (im->shminfo.shmid == (uint32_t)-1)
680 { 680 {
681 xcb_image_destroy(im->xim); 681 xcb_image_destroy(im->xim);
diff --git a/src/lib/ecore_x/xlib/ecore_x_image.c b/src/lib/ecore_x/xlib/ecore_x_image.c
index 6dfe931..35ee976 100644
--- a/src/lib/ecore_x/xlib/ecore_x_image.c
+++ b/src/lib/ecore_x/xlib/ecore_x_image.c
@@ -120,7 +120,7 @@ _ecore_x_image_shm_check(void)
120 } 120 }
121 121
122 shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height, 122 shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height,
123 IPC_CREAT | 0666); 123 IPC_CREAT | 0600);
124 if (shminfo.shmid == -1) 124 if (shminfo.shmid == -1)
125 { 125 {
126 ERR("%s", strerror(errno)); 126 ERR("%s", strerror(errno));
@@ -246,7 +246,7 @@ _ecore_x_image_shm_create(Ecore_X_Image *im)
246 246
247 im->shminfo.shmid = shmget(IPC_PRIVATE, 247 im->shminfo.shmid = shmget(IPC_PRIVATE,
248 im->xim->bytes_per_line * im->xim->height, 248 im->xim->bytes_per_line * im->xim->height,
249 IPC_CREAT | 0666); 249 IPC_CREAT | 0600);
250 if (im->shminfo.shmid == -1) 250 if (im->shminfo.shmid == -1)
251 { 251 {
252 ERR("shmget failed: %s", strerror(errno)); 252 ERR("shmget failed: %s", strerror(errno));
diff --git a/src/modules/evas/engines/software_x11/evas_engine.h b/src/modules/evas/engines/software_x11/evas_engine.h
index c29f62d..895e320 100644
--- a/src/modules/evas/engines/software_x11/evas_engine.h
+++ b/src/modules/evas/engines/software_x11/evas_engine.h
@@ -106,6 +106,7 @@ struct _Outbuf
106 106
107 /* a list of previous frame pending regions to write to the target */ 107 /* a list of previous frame pending regions to write to the target */
108 Eina_List *prev_pending_writes; 108 Eina_List *prev_pending_writes;
109 Eina_Spinlock lock;
109 110
110 unsigned char mask_dither : 1; 111 unsigned char mask_dither : 1;
111 unsigned char destination_alpha : 1; 112 unsigned char destination_alpha : 1;
diff --git a/src/modules/evas/engines/software_x11/evas_xcb_buffer.c b/src/modules/evas/engines/software_x11/evas_xcb_buffer.c
index 38d4584..ff90a68 100644
--- a/src/modules/evas/engines/software_x11/evas_xcb_buffer.c
+++ b/src/modules/evas/engines/software_x11/evas_xcb_buffer.c
@@ -282,7 +282,7 @@ evas_software_xcb_output_buffer_new(xcb_connection_t *conn, xcb_visualtype_t *vi
282 xcbob->shm_info->shmid = 282 xcbob->shm_info->shmid =
283 shmget(IPC_PRIVATE, 283 shmget(IPC_PRIVATE,
284 xcbob->xim->stride * xcbob->xim->height, 284 xcbob->xim->stride * xcbob->xim->height,
285 (IPC_CREAT | 0777)); 285 (IPC_CREAT | 0600));
286 if (xcbob->shm_info->shmid == (uint32_t)-1) 286 if (xcbob->shm_info->shmid == (uint32_t)-1)
287 { 287 {
288 xcb_image_destroy(xcbob->xim); 288 xcb_image_destroy(xcbob->xim);
diff --git a/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c b/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c
index 632d13c..cee38e9 100644
--- a/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c
+++ b/src/modules/evas/engines/software_x11/evas_xcb_outbuf.c
@@ -46,6 +46,7 @@ evas_software_xcb_outbuf_init(void)
46void 46void
47evas_software_xcb_outbuf_free(Outbuf *buf) 47evas_software_xcb_outbuf_free(Outbuf *buf)
48{ 48{
49 eina_spinlock_take(&(buf->priv.lock));
49 while (buf->priv.pending_writes) 50 while (buf->priv.pending_writes)
50 { 51 {
51 RGBA_Image *im = NULL; 52 RGBA_Image *im = NULL;
@@ -67,6 +68,7 @@ evas_software_xcb_outbuf_free(Outbuf *buf)
67 if (obr->mask) _unfind_xcbob(obr->mask, EINA_FALSE); 68 if (obr->mask) _unfind_xcbob(obr->mask, EINA_FALSE);
68 free(obr); 69 free(obr);
69 } 70 }
71 eina_spinlock_release(&(buf->priv.lock));
70 72
71 evas_software_xcb_outbuf_idle_flush(buf); 73 evas_software_xcb_outbuf_idle_flush(buf);
72 evas_software_xcb_outbuf_flush(buf, NULL, MODE_FULL); 74 evas_software_xcb_outbuf_flush(buf, NULL, MODE_FULL);
@@ -82,10 +84,9 @@ evas_software_xcb_outbuf_free(Outbuf *buf)
82 buf->priv.pal); 84 buf->priv.pal);
83 85
84 eina_array_flush(&buf->priv.onebuf_regions); 86 eina_array_flush(&buf->priv.onebuf_regions);
85 87 eina_spinlock_free(&(buf->priv.lock));
86 free(buf); 88 free(buf);
87 _clear_xcbob(EINA_FALSE); 89 _clear_xcbob(EINA_TRUE);
88 eina_spinlock_free(&shmpool_lock);
89} 90}
90 91
91Outbuf * 92Outbuf *
@@ -260,6 +261,7 @@ evas_software_xcb_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, xcb_co
260 261
261 evas_software_xcb_outbuf_drawable_set(buf, draw); 262 evas_software_xcb_outbuf_drawable_set(buf, draw);
262 evas_software_xcb_outbuf_mask_set(buf, mask); 263 evas_software_xcb_outbuf_mask_set(buf, mask);
264 eina_spinlock_new(&(buf->priv.lock));
263 265
264 return buf; 266 return buf;
265} 267}
@@ -273,6 +275,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
273 Eina_Bool alpha = EINA_FALSE; 275 Eina_Bool alpha = EINA_FALSE;
274 int bpl = 0; 276 int bpl = 0;
275 277
278 eina_spinlock_take(&(buf->priv.lock));
276 if ((buf->onebuf) && (buf->priv.x11.xcb.shm)) 279 if ((buf->onebuf) && (buf->priv.x11.xcb.shm))
277 { 280 {
278 Eina_Rectangle *rect; 281 Eina_Rectangle *rect;
@@ -280,11 +283,15 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
280 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h); 283 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h);
281 284
282 if (!(obr = calloc(1, sizeof(Outbuf_Region)))) 285 if (!(obr = calloc(1, sizeof(Outbuf_Region))))
283 return NULL; 286 {
287 eina_spinlock_release(&(buf->priv.lock));
288 return NULL;
289 }
284 290
285 if (!(rect = eina_rectangle_new(x, y, w, h))) 291 if (!(rect = eina_rectangle_new(x, y, w, h)))
286 { 292 {
287 free(obr); 293 free(obr);
294 eina_spinlock_release(&(buf->priv.lock));
288 return NULL; 295 return NULL;
289 } 296 }
290 297
@@ -301,6 +308,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
301 buf->priv.synced = EINA_TRUE; 308 buf->priv.synced = EINA_TRUE;
302 } 309 }
303 free(obr); 310 free(obr);
311 eina_spinlock_release(&(buf->priv.lock));
304 return buf->priv.onebuf; 312 return buf->priv.onebuf;
305 } 313 }
306 obr->x = 0; 314 obr->x = 0;
@@ -330,6 +338,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
330 if (!obr->xcbob) 338 if (!obr->xcbob)
331 { 339 {
332 free(obr); 340 free(obr);
341 eina_spinlock_release(&(buf->priv.lock));
333 return NULL; 342 return NULL;
334 } 343 }
335#ifdef EVAS_CSERVE2 344#ifdef EVAS_CSERVE2
@@ -355,6 +364,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
355 { 364 {
356 evas_software_xcb_output_buffer_free(obr->xcbob, EINA_FALSE); 365 evas_software_xcb_output_buffer_free(obr->xcbob, EINA_FALSE);
357 free(obr); 366 free(obr);
367 eina_spinlock_release(&(buf->priv.lock));
358 return NULL; 368 return NULL;
359 } 369 }
360 im->extended_info = obr; 370 im->extended_info = obr;
@@ -387,6 +397,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
387 if (!im) 397 if (!im)
388 { 398 {
389 free(obr); 399 free(obr);
400 eina_spinlock_release(&(buf->priv.lock));
390 return NULL; 401 return NULL;
391 } 402 }
392 im->cache_entry.flags.alpha |= (alpha ? 1 : 0); 403 im->cache_entry.flags.alpha |= (alpha ? 1 : 0);
@@ -423,6 +434,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
423 evas_cache_image_drop(&im->cache_entry); 434 evas_cache_image_drop(&im->cache_entry);
424 435
425 free(obr); 436 free(obr);
437 eina_spinlock_release(&(buf->priv.lock));
426 return NULL; 438 return NULL;
427 } 439 }
428 if (buf->priv.x11.xcb.mask) 440 if (buf->priv.x11.xcb.mask)
@@ -441,11 +453,15 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
441// memset(im->image.data, 0, (w * h * sizeof(DATA32))); 453// memset(im->image.data, 0, (w * h * sizeof(DATA32)));
442 } 454 }
443 buf->priv.onebuf = im; 455 buf->priv.onebuf = im;
456 eina_spinlock_release(&(buf->priv.lock));
444 return im; 457 return im;
445 } 458 }
446 459
447 if (!(obr = calloc(1, sizeof(Outbuf_Region)))) 460 if (!(obr = calloc(1, sizeof(Outbuf_Region))))
448 return NULL; 461 {
462 eina_spinlock_release(&(buf->priv.lock));
463 return NULL;
464 }
449 465
450 obr->x = x; 466 obr->x = x;
451 obr->y = y; 467 obr->y = y;
@@ -470,6 +486,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
470 if (!obr->xcbob) 486 if (!obr->xcbob)
471 { 487 {
472 free(obr); 488 free(obr);
489 eina_spinlock_release(&(buf->priv.lock));
473 return NULL; 490 return NULL;
474 } 491 }
475#ifdef EVAS_CSERVE2 492#ifdef EVAS_CSERVE2
@@ -495,6 +512,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
495 { 512 {
496 _unfind_xcbob(obr->xcbob, EINA_FALSE); 513 _unfind_xcbob(obr->xcbob, EINA_FALSE);
497 free(obr); 514 free(obr);
515 eina_spinlock_release(&(buf->priv.lock));
498 return NULL; 516 return NULL;
499 } 517 }
500 im->extended_info = obr; 518 im->extended_info = obr;
@@ -525,6 +543,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
525 if (!im) 543 if (!im)
526 { 544 {
527 free(obr); 545 free(obr);
546 eina_spinlock_release(&(buf->priv.lock));
528 return NULL; 547 return NULL;
529 } 548 }
530 im->cache_entry.flags.alpha |= (alpha ? 1 : 0); 549 im->cache_entry.flags.alpha |= (alpha ? 1 : 0);
@@ -558,6 +577,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
558#endif 577#endif
559 evas_cache_image_drop(&im->cache_entry); 578 evas_cache_image_drop(&im->cache_entry);
560 free(obr); 579 free(obr);
580 eina_spinlock_release(&(buf->priv.lock));
561 return NULL; 581 return NULL;
562 } 582 }
563 if (buf->priv.x11.xcb.mask) 583 if (buf->priv.x11.xcb.mask)
@@ -577,6 +597,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
577 597
578 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im); 598 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);
579 599
600 eina_spinlock_release(&(buf->priv.lock));
580 return im; 601 return im;
581} 602}
582 603
@@ -587,14 +608,13 @@ evas_software_xcb_outbuf_free_region_for_update(Outbuf *buf EINA_UNUSED, RGBA_Im
587} 608}
588 609
589void 610void
590evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode) 611evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode EINA_UNUSED)
591{ 612{
592 Eina_List *l = NULL; 613 Eina_List *l = NULL;
593 RGBA_Image *im = NULL; 614 RGBA_Image *im = NULL;
594 Outbuf_Region *obr = NULL; 615 Outbuf_Region *obr = NULL;
595 616
596 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return; 617 eina_spinlock_take(&(buf->priv.lock));
597
598 if ((buf->priv.onebuf) && (eina_array_count(&buf->priv.onebuf_regions))) 618 if ((buf->priv.onebuf) && (eina_array_count(&buf->priv.onebuf_regions)))
599 { 619 {
600 Eina_Array_Iterator it; 620 Eina_Array_Iterator it;
@@ -743,12 +763,14 @@ evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Eva
743 } 763 }
744#endif 764#endif
745 } 765 }
766 eina_spinlock_release(&(buf->priv.lock));
746 evas_common_cpu_end_opt(); 767 evas_common_cpu_end_opt();
747} 768}
748 769
749void 770void
750evas_software_xcb_outbuf_idle_flush(Outbuf *buf) 771evas_software_xcb_outbuf_idle_flush(Outbuf *buf)
751{ 772{
773 eina_spinlock_release(&(buf->priv.lock));
752 if (buf->priv.onebuf) 774 if (buf->priv.onebuf)
753 { 775 {
754 RGBA_Image *im; 776 RGBA_Image *im;
@@ -795,6 +817,7 @@ evas_software_xcb_outbuf_idle_flush(Outbuf *buf)
795 } 817 }
796 _clear_xcbob(EINA_FALSE); 818 _clear_xcbob(EINA_FALSE);
797 } 819 }
820 eina_spinlock_release(&(buf->priv.lock));
798} 821}
799 822
800void 823void
@@ -807,8 +830,13 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
807 int bpl = 0, yy = 0; 830 int bpl = 0, yy = 0;
808 int bw = 0, bh = 0; 831 int bw = 0, bh = 0;
809 832
833 eina_spinlock_release(&(buf->priv.lock));
810 obr = update->extended_info; 834 obr = update->extended_info;
811 if (!obr->xcbob) return; 835 if (!obr->xcbob)
836 {
837 eina_spinlock_release(&(buf->priv.lock));
838 return;
839 }
812 840
813 if ((buf->rot == 0) || (buf->rot == 180)) 841 if ((buf->rot == 0) || (buf->rot == 180))
814 { 842 {
@@ -834,11 +862,22 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
834 buf->priv.mask.g, buf->priv.mask.b, 862 buf->priv.mask.g, buf->priv.mask.b,
835 PAL_MODE_NONE, buf->rot); 863 PAL_MODE_NONE, buf->rot);
836 } 864 }
837 if (!func_conv) return; 865 if (!func_conv)
866 {
867 eina_spinlock_release(&(buf->priv.lock));
868 return;
869 }
838 870
839 if (!(data = evas_software_xcb_output_buffer_data(obr->xcbob, &bpl))) 871 if (!(data = evas_software_xcb_output_buffer_data(obr->xcbob, &bpl)))
840 return; 872 {
841 if (!(src_data = update->image.data)) return; 873 eina_spinlock_release(&(buf->priv.lock));
874 return;
875 }
876 if (!(src_data = update->image.data))
877 {
878 eina_spinlock_release(&(buf->priv.lock));
879 return;
880 }
842 if (buf->rot == 0) 881 if (buf->rot == 0)
843 { 882 {
844 obr->x = x; 883 obr->x = x;
@@ -965,6 +1004,7 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
965#else 1004#else
966 xcb_flush(buf->priv.x11.xcb.conn); 1005 xcb_flush(buf->priv.x11.xcb.conn);
967#endif 1006#endif
1007 eina_spinlock_release(&(buf->priv.lock));
968} 1008}
969 1009
970void 1010void
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_buffer.c b/src/modules/evas/engines/software_x11/evas_xlib_buffer.c
index 9faf9eb..6ab1278 100644
--- a/src/modules/evas/engines/software_x11/evas_xlib_buffer.c
+++ b/src/modules/evas/engines/software_x11/evas_xlib_buffer.c
@@ -288,7 +288,7 @@ evas_software_xlib_x_output_buffer_new(Display *d, Visual *v, int depth, int w,
288 xob->shm_info->shmid = shmget(IPC_PRIVATE, 288 xob->shm_info->shmid = shmget(IPC_PRIVATE,
289 xob->xim->bytes_per_line * 289 xob->xim->bytes_per_line *
290 xob->xim->height, 290 xob->xim->height,
291 IPC_CREAT | 0777); 291 IPC_CREAT | 0600);
292 if (xob->shm_info->shmid >= 0) 292 if (xob->shm_info->shmid >= 0)
293 { 293 {
294 xob->shm_info->readOnly = False; 294 xob->shm_info->readOnly = False;
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c b/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c
index 52dffd6..63b55c4 100644
--- a/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c
+++ b/src/modules/evas/engines/software_x11/evas_xlib_outbuf.c
@@ -161,6 +161,7 @@ evas_software_xlib_outbuf_init(void)
161void 161void
162evas_software_xlib_outbuf_free(Outbuf *buf) 162evas_software_xlib_outbuf_free(Outbuf *buf)
163{ 163{
164 eina_spinlock_take(&(buf->priv.lock));
164 while (buf->priv.pending_writes) 165 while (buf->priv.pending_writes)
165 { 166 {
166 RGBA_Image *im; 167 RGBA_Image *im;
@@ -181,6 +182,7 @@ evas_software_xlib_outbuf_free(Outbuf *buf)
181 if (obr->mxob) _unfind_xob(obr->mxob, 0); 182 if (obr->mxob) _unfind_xob(obr->mxob, 0);
182 free(obr); 183 free(obr);
183 } 184 }
185 eina_spinlock_release(&(buf->priv.lock));
184 evas_software_xlib_outbuf_idle_flush(buf); 186 evas_software_xlib_outbuf_idle_flush(buf);
185 evas_software_xlib_outbuf_flush(buf, NULL, EVAS_RENDER_MODE_UNDEF); 187 evas_software_xlib_outbuf_flush(buf, NULL, EVAS_RENDER_MODE_UNDEF);
186 if (buf->priv.x11.xlib.gc) 188 if (buf->priv.x11.xlib.gc)
@@ -195,8 +197,9 @@ evas_software_xlib_outbuf_free(Outbuf *buf)
195 XFreeColormap (buf->priv.x11.xlib.disp, buf->priv.x11.xlib.cmap); 197 XFreeColormap (buf->priv.x11.xlib.disp, buf->priv.x11.xlib.cmap);
196 198
197 eina_array_flush(&buf->priv.onebuf_regions); 199 eina_array_flush(&buf->priv.onebuf_regions);
200 eina_spinlock_free(&(buf->priv.lock));
198 free(buf); 201 free(buf);
199 _clear_xob(0); 202 _clear_xob(1);
200} 203}
201 204
202Outbuf * 205Outbuf *
@@ -372,6 +375,7 @@ evas_software_xlib_outbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
372 evas_software_xlib_outbuf_drawable_set(buf, draw); 375 evas_software_xlib_outbuf_drawable_set(buf, draw);
373 evas_software_xlib_outbuf_mask_set(buf, mask); 376 evas_software_xlib_outbuf_mask_set(buf, mask);
374 } 377 }
378 eina_spinlock_new(&(buf->priv.lock));
375 return buf; 379 return buf;
376} 380}
377 381
@@ -384,6 +388,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
384 int use_shm = 1; 388 int use_shm = 1;
385 int alpha; 389 int alpha;
386 390
391 eina_spinlock_take(&(buf->priv.lock));
387 if ((buf->onebuf) && (buf->priv.x11.xlib.shm)) 392 if ((buf->onebuf) && (buf->priv.x11.xlib.shm))
388 { 393 {
389 Eina_Rectangle *rect; 394 Eina_Rectangle *rect;
@@ -391,7 +396,11 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
391 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h); 396 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h);
392 397
393 rect = eina_rectangle_new(x, y, w, h); 398 rect = eina_rectangle_new(x, y, w, h);
394 if (!rect) return NULL; 399 if (!rect)
400 {
401 eina_spinlock_release(&(buf->priv.lock));
402 return NULL;
403 }
395 404
396 if ((eina_array_push(&buf->priv.onebuf_regions, rect)) && 405 if ((eina_array_push(&buf->priv.onebuf_regions, rect)) &&
397 (buf->priv.onebuf)) 406 (buf->priv.onebuf))
@@ -405,13 +414,18 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
405 XSync(buf->priv.x11.xlib.disp, False); 414 XSync(buf->priv.x11.xlib.disp, False);
406 buf->priv.synced = 1; 415 buf->priv.synced = 1;
407 } 416 }
417 eina_spinlock_release(&(buf->priv.lock));
408 return buf->priv.onebuf; 418 return buf->priv.onebuf;
409 } 419 }
410 420
411 if (rect) eina_rectangle_free(rect); 421 if (rect) eina_rectangle_free(rect);
412 422
413 obr = calloc(1, sizeof(Outbuf_Region)); 423 obr = calloc(1, sizeof(Outbuf_Region));
414 if (!obr) return NULL; 424 if (!obr)
425 {
426 eina_spinlock_release(&(buf->priv.lock));
427 return NULL;
428 }
415 429
416 obr->x = 0; 430 obr->x = 0;
417 obr->y = 0; 431 obr->y = 0;
@@ -440,6 +454,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
440 if (!obr->xob) 454 if (!obr->xob)
441 { 455 {
442 free(obr); 456 free(obr);
457 eina_spinlock_release(&(buf->priv.lock));
443 return NULL; 458 return NULL;
444 } 459 }
445#ifdef EVAS_CSERVE2 460#ifdef EVAS_CSERVE2
@@ -460,6 +475,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
460 { 475 {
461 evas_software_xlib_x_output_buffer_free(obr->xob, 0); 476 evas_software_xlib_x_output_buffer_free(obr->xob, 0);
462 free(obr); 477 free(obr);
478 eina_spinlock_release(&(buf->priv.lock));
463 return NULL; 479 return NULL;
464 } 480 }
465 im->extended_info = obr; 481 im->extended_info = obr;
@@ -482,6 +498,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
482 if (!im) 498 if (!im)
483 { 499 {
484 free(obr); 500 free(obr);
501 eina_spinlock_release(&(buf->priv.lock));
485 return NULL; 502 return NULL;
486 } 503 }
487 im->cache_entry.flags.alpha |= alpha ? 1 : 0; 504 im->cache_entry.flags.alpha |= alpha ? 1 : 0;
@@ -511,6 +528,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
511#endif 528#endif
512 evas_cache_image_drop(&im->cache_entry); 529 evas_cache_image_drop(&im->cache_entry);
513 free(obr); 530 free(obr);
531 eina_spinlock_release(&(buf->priv.lock));
514 return NULL; 532 return NULL;
515 } 533 }
516 if (buf->priv.x11.xlib.mask) 534 if (buf->priv.x11.xlib.mask)
@@ -539,6 +557,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
539#endif 557#endif
540 evas_cache_image_drop(&im->cache_entry); 558 evas_cache_image_drop(&im->cache_entry);
541 free(obr); 559 free(obr);
560 eina_spinlock_release(&(buf->priv.lock));
542 return NULL; 561 return NULL;
543 } 562 }
544 if (buf->priv.x11.xlib.mask) 563 if (buf->priv.x11.xlib.mask)
@@ -558,11 +577,16 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
558 } 577 }
559 578
560 buf->priv.onebuf = im; 579 buf->priv.onebuf = im;
580 eina_spinlock_release(&(buf->priv.lock));
561 return im; 581 return im;
562 } 582 }
563 583
564 obr = calloc(1, sizeof(Outbuf_Region)); 584 obr = calloc(1, sizeof(Outbuf_Region));
565 if (!obr) return NULL; 585 if (!obr)
586 {
587 eina_spinlock_release(&(buf->priv.lock));
588 return NULL;
589 }
566 obr->x = x; 590 obr->x = x;
567 obr->y = y; 591 obr->y = y;
568 obr->w = w; 592 obr->w = w;
@@ -596,6 +620,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
596 if (!obr->xob) 620 if (!obr->xob)
597 { 621 {
598 free(obr); 622 free(obr);
623 eina_spinlock_release(&(buf->priv.lock));
599 return NULL; 624 return NULL;
600 } 625 }
601#ifdef EVAS_CSERVE2 626#ifdef EVAS_CSERVE2
@@ -614,6 +639,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
614 { 639 {
615 _unfind_xob(obr->xob, 0); 640 _unfind_xob(obr->xob, 0);
616 free(obr); 641 free(obr);
642 eina_spinlock_release(&(buf->priv.lock));
617 return NULL; 643 return NULL;
618 } 644 }
619 im->extended_info = obr; 645 im->extended_info = obr;
@@ -635,6 +661,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
635 if (!im) 661 if (!im)
636 { 662 {
637 free(obr); 663 free(obr);
664 eina_spinlock_release(&(buf->priv.lock));
638 return NULL; 665 return NULL;
639 } 666 }
640 im->cache_entry.w = w; 667 im->cache_entry.w = w;
@@ -666,6 +693,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
666#endif 693#endif
667 evas_cache_image_drop(&im->cache_entry); 694 evas_cache_image_drop(&im->cache_entry);
668 free(obr); 695 free(obr);
696 eina_spinlock_release(&(buf->priv.lock));
669 return NULL; 697 return NULL;
670 } 698 }
671 if (buf->priv.x11.xlib.mask) 699 if (buf->priv.x11.xlib.mask)
@@ -694,6 +722,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
694#endif 722#endif
695 evas_cache_image_drop(&im->cache_entry); 723 evas_cache_image_drop(&im->cache_entry);
696 free(obr); 724 free(obr);
725 eina_spinlock_release(&(buf->priv.lock));
697 return NULL; 726 return NULL;
698 } 727 }
699 if (buf->priv.x11.xlib.mask) 728 if (buf->priv.x11.xlib.mask)
@@ -714,6 +743,7 @@ evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w
714 } 743 }
715 744
716 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im); 745 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);
746 eina_spinlock_release(&(buf->priv.lock));
717 return im; 747 return im;
718} 748}
719 749
@@ -724,14 +754,13 @@ evas_software_xlib_outbuf_free_region_for_update(Outbuf *buf EINA_UNUSED, RGBA_I
724} 754}
725 755
726void 756void
727evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode) 757evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode EINA_UNUSED)
728{ 758{
729 Eina_List *l; 759 Eina_List *l;
730 RGBA_Image *im; 760 RGBA_Image *im;
731 Outbuf_Region *obr; 761 Outbuf_Region *obr;
732 762
733 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return; 763 eina_spinlock_take(&(buf->priv.lock));
734
735 if ((buf->priv.onebuf) && eina_array_count(&buf->priv.onebuf_regions)) 764 if ((buf->priv.onebuf) && eina_array_count(&buf->priv.onebuf_regions))
736 { 765 {
737 Eina_Rectangle *rect; 766 Eina_Rectangle *rect;
@@ -890,12 +919,14 @@ evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Ev
890 } 919 }
891#endif 920#endif
892 } 921 }
922 eina_spinlock_release(&(buf->priv.lock));
893 evas_common_cpu_end_opt(); 923 evas_common_cpu_end_opt();
894} 924}
895 925
896void 926void
897evas_software_xlib_outbuf_idle_flush(Outbuf *buf) 927evas_software_xlib_outbuf_idle_flush(Outbuf *buf)
898{ 928{
929 eina_spinlock_take(&(buf->priv.lock));
899 if (buf->priv.onebuf) 930 if (buf->priv.onebuf)
900 { 931 {
901 RGBA_Image *im; 932 RGBA_Image *im;
@@ -943,6 +974,7 @@ evas_software_xlib_outbuf_idle_flush(Outbuf *buf)
943 } 974 }
944 _clear_xob(0); 975 _clear_xob(0);
945 } 976 }
977 eina_spinlock_release(&(buf->priv.lock));
946} 978}
947 979
948void 980void
@@ -954,6 +986,7 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i
954 unsigned char *data; 986 unsigned char *data;
955 int bpl = 0, yy; 987 int bpl = 0, yy;
956 988
989 eina_spinlock_take(&(buf->priv.lock));
957 obr = update->extended_info; 990 obr = update->extended_info;
958 if (buf->priv.pal) 991 if (buf->priv.pal)
959 { 992 {
@@ -985,13 +1018,29 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i
985 buf->priv.mask.g, buf->priv.mask.b, 1018 buf->priv.mask.g, buf->priv.mask.b,
986 PAL_MODE_NONE, buf->rot); 1019 PAL_MODE_NONE, buf->rot);
987 } 1020 }
988 if (!conv_func) return; 1021 if (!conv_func)
1022 {
1023 eina_spinlock_release(&(buf->priv.lock));
1024 return;
1025 }
989 1026
990 if (!obr->xob) return; 1027 if (!obr->xob)
1028 {
1029 eina_spinlock_release(&(buf->priv.lock));
1030 return;
1031 }
991 data = evas_software_xlib_x_output_buffer_data(obr->xob, &bpl); 1032 data = evas_software_xlib_x_output_buffer_data(obr->xob, &bpl);
992 if (!data) return; 1033 if (!data)
1034 {
1035 eina_spinlock_release(&(buf->priv.lock));
1036 return;
1037 }
993 src_data = update->image.data; 1038 src_data = update->image.data;
994 if (!src_data) return; 1039 if (!src_data)
1040 {
1041 eina_spinlock_release(&(buf->priv.lock));
1042 return;
1043 }
995 if (buf->rot == 0) 1044 if (buf->rot == 0)
996 { 1045 {
997 obr->x = x; 1046 obr->x = x;
@@ -1125,6 +1174,7 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i
1125#else 1174#else
1126 XFlush(buf->priv.x11.xlib.disp); 1175 XFlush(buf->priv.x11.xlib.disp);
1127#endif 1176#endif
1177 eina_spinlock_release(&(buf->priv.lock));
1128} 1178}
1129 1179
1130void 1180void
diff --git a/src/modules/evas/engines/software_x11/evas_xlib_swapper.c b/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
index c60c9d7..6749f8c 100644
--- a/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
+++ b/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
@@ -59,7 +59,7 @@ _buf_new(X_Swapper *swp, Buffer *buf)
59 buf->bpl = buf->xim->bytes_per_line; 59 buf->bpl = buf->xim->bytes_per_line;
60 60
61 buf->shm_info.shmid = shmget(IPC_PRIVATE, buf->bpl * buf->h, 61 buf->shm_info.shmid = shmget(IPC_PRIVATE, buf->bpl * buf->h,
62 IPC_CREAT | 0777); 62 IPC_CREAT | 0600);
63 if (buf->shm_info.shmid >= 0) 63 if (buf->shm_info.shmid >= 0)
64 { 64 {
65 buf->shm_info.readOnly = False; 65 buf->shm_info.readOnly = False;