From a3abb5586ffd7c7eb95bb4762e442805913ca872 Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Tue, 17 Feb 2004 11:06:52 +0000 Subject: [PATCH] sys/: Fix a possible SHM leak if we crash. All other apps using XShm are doing that. Original commit message from CVS: 2004-02-17 Julien MOUTTE * sys/ximage/ximagesink.c: (gst_ximagesink_ximage_new): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xvimage_new): Fix a possible SHM leak if we crash. All other apps using XShm are doing that. --- ChangeLog | 7 +++++++ sys/ximage/ximagesink.c | 13 ++++++++----- sys/xvimage/xvimagesink.c | 13 ++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c571fc46e..492666a54c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-02-17 Julien MOUTTE + + * sys/ximage/ximagesink.c: (gst_ximagesink_ximage_new): + * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xvimage_new): Fix a + possible SHM leak if we crash. All other apps using XShm are doing + that. + 2004-02-17 Julien MOUTTE * sys/ximage/ximagesink.c: (gst_ximagesink_renegotiate_size), diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index d72718555f..4f61ae629f 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -178,6 +178,11 @@ gst_ximagesink_ximage_new (GstXImageSink *ximagesink, gint width, gint height) ximage->SHMInfo.readOnly = FALSE; XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo); + + XSync (ximagesink->xcontext->disp, FALSE); + + shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0); + ximage->SHMInfo.shmid = -1; } else #endif /* HAVE_XSHM */ @@ -191,13 +196,11 @@ gst_ximagesink_ximage_new (GstXImageSink *ximagesink, gint width, gint height) ximage->width, ximage->height, ximagesink->xcontext->bpp, ximage->width * (ximagesink->xcontext->bpp / 8)); - } - - if (ximage->ximage) - { + XSync (ximagesink->xcontext->disp, FALSE); } - else + + if (!ximage->ximage) { if (ximage->data) g_free (ximage->data); diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index c817a8ebbc..fb0fd2f063 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -191,6 +191,11 @@ gst_xvimagesink_xvimage_new (GstXvImageSink *xvimagesink, xvimage->SHMInfo.readOnly = FALSE; XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo); + + XSync (xvimagesink->xcontext->disp, FALSE); + + shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0); + xvimage->SHMInfo.shmid = -1; } else #endif /* HAVE_XSHM */ @@ -202,13 +207,11 @@ gst_xvimagesink_xvimage_new (GstXvImageSink *xvimagesink, xvimage->width, xvimage->height); xvimage->data = g_malloc (xvimage->xvimage->data_size); - } - - if (xvimage->xvimage) - { + XSync (xvimagesink->xcontext->disp, FALSE); } - else + + if (!xvimage->xvimage) { if (xvimage->data) g_free (xvimage->data);