mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 14:36:24 +00:00
sys/: Set shared memory segments to be deleted as soon as we have attached, that way they get cleaned up automaticall...
Original commit message from CVS: * sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls), (gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy): * sys/xvimage/xvimagesink.c: (gst_xvimage_buffer_destroy), (gst_xvimagesink_check_xshm_calls), (gst_xvimagesink_xvimage_new): Set shared memory segments to be deleted as soon as we have attached, that way they get cleaned up automatically if we crash.
This commit is contained in:
parent
0f1a1598ca
commit
c8ddff9120
3 changed files with 37 additions and 8 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2006-02-18 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
|
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
|
||||||
|
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy):
|
||||||
|
* sys/xvimage/xvimagesink.c: (gst_xvimage_buffer_destroy),
|
||||||
|
(gst_xvimagesink_check_xshm_calls), (gst_xvimagesink_xvimage_new):
|
||||||
|
Set shared memory segments to be deleted as soon as we have attached,
|
||||||
|
that way they get cleaned up automatically if we crash.
|
||||||
|
|
||||||
2006-02-18 Julien MOUTTE <julien@moutte.net>
|
2006-02-18 Julien MOUTTE <julien@moutte.net>
|
||||||
|
|
||||||
* ext/pango/gstclockoverlay.c: (gst_clock_overlay_get_text):
|
* ext/pango/gstclockoverlay.c: (gst_clock_overlay_get_text):
|
||||||
|
|
|
@ -342,9 +342,16 @@ gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
|
||||||
SHMInfo.shmaddr = shmat (SHMInfo.shmid, 0, 0);
|
SHMInfo.shmaddr = shmat (SHMInfo.shmid, 0, 0);
|
||||||
if (SHMInfo.shmaddr == ((void *) -1)) {
|
if (SHMInfo.shmaddr == ((void *) -1)) {
|
||||||
GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
|
GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
|
||||||
|
/* Clean up shm seg */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Delete the shared memory segment as soon as we manage to attach.
|
||||||
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
||||||
|
|
||||||
ximage->data = SHMInfo.shmaddr;
|
ximage->data = SHMInfo.shmaddr;
|
||||||
SHMInfo.readOnly = FALSE;
|
SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
|
@ -374,8 +381,6 @@ beach:
|
||||||
}
|
}
|
||||||
if (SHMInfo.shmaddr != ((void *) -1))
|
if (SHMInfo.shmaddr != ((void *) -1))
|
||||||
shmdt (SHMInfo.shmaddr);
|
shmdt (SHMInfo.shmaddr);
|
||||||
if (SHMInfo.shmid > 0)
|
|
||||||
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
|
||||||
if (ximage)
|
if (ximage)
|
||||||
XDestroyImage (ximage);
|
XDestroyImage (ximage);
|
||||||
return result;
|
return result;
|
||||||
|
@ -435,9 +440,16 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
|
||||||
if (ximage->SHMInfo.shmaddr == ((void *) -1)) {
|
if (ximage->SHMInfo.shmaddr == ((void *) -1)) {
|
||||||
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
|
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, (NULL),
|
||||||
("Failed to shmat: %s", g_strerror (errno)));
|
("Failed to shmat: %s", g_strerror (errno)));
|
||||||
|
/* Clean up the shared memory segment */
|
||||||
|
shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now that we've attached, we can delete the shared memory segment.
|
||||||
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
|
||||||
|
|
||||||
ximage->ximage->data = ximage->SHMInfo.shmaddr;
|
ximage->ximage->data = ximage->SHMInfo.shmaddr;
|
||||||
ximage->SHMInfo.readOnly = FALSE;
|
ximage->SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
|
@ -514,8 +526,6 @@ gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink,
|
||||||
XSync (ximagesink->xcontext->disp, 0);
|
XSync (ximagesink->xcontext->disp, 0);
|
||||||
shmdt (ximage->SHMInfo.shmaddr);
|
shmdt (ximage->SHMInfo.shmaddr);
|
||||||
}
|
}
|
||||||
if (ximage->SHMInfo.shmid > 0)
|
|
||||||
shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
|
|
||||||
if (ximage->ximage)
|
if (ximage->ximage)
|
||||||
XDestroyImage (ximage->ximage);
|
XDestroyImage (ximage->ximage);
|
||||||
|
|
||||||
|
|
|
@ -237,8 +237,6 @@ gst_xvimage_buffer_destroy (GstXvImageBuffer * xvimage)
|
||||||
XSync (xvimagesink->xcontext->disp, FALSE);
|
XSync (xvimagesink->xcontext->disp, FALSE);
|
||||||
shmdt (xvimage->SHMInfo.shmaddr);
|
shmdt (xvimage->SHMInfo.shmaddr);
|
||||||
}
|
}
|
||||||
if (xvimage->SHMInfo.shmid > 0)
|
|
||||||
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
|
|
||||||
if (xvimage->xvimage)
|
if (xvimage->xvimage)
|
||||||
XFree (xvimage->xvimage);
|
XFree (xvimage->xvimage);
|
||||||
} else
|
} else
|
||||||
|
@ -419,9 +417,16 @@ gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
|
||||||
SHMInfo.shmaddr = shmat (SHMInfo.shmid, 0, 0);
|
SHMInfo.shmaddr = shmat (SHMInfo.shmid, 0, 0);
|
||||||
if (SHMInfo.shmaddr == ((void *) -1)) {
|
if (SHMInfo.shmaddr == ((void *) -1)) {
|
||||||
GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
|
GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
|
||||||
|
/* Clean up the shared memory segment */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Delete the shared memory segment as soon as we manage to attach.
|
||||||
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
||||||
|
|
||||||
xvimage->data = SHMInfo.shmaddr;
|
xvimage->data = SHMInfo.shmaddr;
|
||||||
SHMInfo.readOnly = FALSE;
|
SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
|
@ -452,8 +457,6 @@ beach:
|
||||||
}
|
}
|
||||||
if (SHMInfo.shmaddr != ((void *) -1))
|
if (SHMInfo.shmaddr != ((void *) -1))
|
||||||
shmdt (SHMInfo.shmaddr);
|
shmdt (SHMInfo.shmaddr);
|
||||||
if (SHMInfo.shmid > 0)
|
|
||||||
shmctl (SHMInfo.shmid, IPC_RMID, 0);
|
|
||||||
if (xvimage)
|
if (xvimage)
|
||||||
XFree (xvimage);
|
XFree (xvimage);
|
||||||
return result;
|
return result;
|
||||||
|
@ -521,9 +524,16 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps)
|
||||||
if (xvimage->SHMInfo.shmaddr == ((void *) -1)) {
|
if (xvimage->SHMInfo.shmaddr == ((void *) -1)) {
|
||||||
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE, (NULL),
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE, (NULL),
|
||||||
("Failed to shmat: %s", g_strerror (errno)));
|
("Failed to shmat: %s", g_strerror (errno)));
|
||||||
|
/* Clean up the shared memory segment */
|
||||||
|
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Delete the shared memory segment as soon as we manage to attach.
|
||||||
|
* This way, it will be deleted as soon as we detach later, and not
|
||||||
|
* leaked if we crash. */
|
||||||
|
shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
|
||||||
|
|
||||||
xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
|
xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
|
||||||
xvimage->SHMInfo.readOnly = FALSE;
|
xvimage->SHMInfo.readOnly = FALSE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue