[gst-cvs] gst-plugins-bad: shm: Don' t pass the ShmPipe to the function closing the shm area
Olivier Crête
tester at kemper.freedesktop.org
Wed Nov 24 16:12:45 PST 2010
Module: gst-plugins-bad
Branch: master
Commit: ecb7674640fb2cc7b171d2fa405dc0d46d0d7cbc
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=ecb7674640fb2cc7b171d2fa405dc0d46d0d7cbc
Author: Olivier Crête <olivier.crete at collabora.co.uk>
Date: Sat Oct 23 01:56:04 2010 +0200
shm: Don't pass the ShmPipe to the function closing the shm area
---
sys/shm/shmpipe.c | 53 +++++++++++++++++++++++++++--------------------------
1 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c
index 40bd18f..9d1ab56 100644
--- a/sys/shm/shmpipe.c
+++ b/sys/shm/shmpipe.c
@@ -172,7 +172,7 @@ struct CommandBuffer
};
static ShmArea *sp_open_shm (char *path, int id, mode_t perms, size_t size);
-static void sp_close_shm (ShmPipe * self, ShmArea * area);
+static void sp_close_shm (ShmArea * area);
static int sp_shmbuf_dec (ShmPipe * self, ShmBuffer * buf,
ShmBuffer * prev_buf);
static void sp_shm_area_dec (ShmPipe * self, ShmArea * area);
@@ -182,7 +182,8 @@ static void sp_shm_area_dec (ShmPipe * self, ShmArea * area);
#define RETURN_ERROR(format, ...) do { \
fprintf (stderr, format, __VA_ARGS__); \
sp_close (self); \
- return NULL; } while (0)
+ return NULL; \
+ } while (0)
ShmPipe *
sp_writer_create (const char *path, size_t size, mode_t perms)
@@ -239,10 +240,12 @@ sp_writer_create (const char *path, size_t size, mode_t perms)
#undef RETURN_ERROR
-#define RETURN_ERROR(format, ...) \
- fprintf (stderr, format, __VA_ARGS__); \
- sp_shm_area_dec (NULL, area); \
- return NULL;
+#define RETURN_ERROR(format, ...) do { \
+ fprintf (stderr, format, __VA_ARGS__); \
+ area->use_count--; \
+ sp_close_shm (area); \
+ return NULL; \
+ } while (0)
/**
* sp_open_shm:
@@ -316,30 +319,13 @@ sp_open_shm (char *path, int id, mode_t perms, size_t size)
#undef RETURN_ERROR
static void
-sp_close_shm (ShmPipe * self, ShmArea * area)
+sp_close_shm (ShmArea * area)
{
assert (area->use_count == 0);
if (area->allocspace)
shm_alloc_space_free (area->allocspace);
- if (self != NULL) {
- ShmArea *item = NULL;
- ShmArea *prev_item = NULL;
-
- for (item = self->shm_area; item; item = item->next) {
- if (item == area) {
- if (prev_item)
- prev_item->next = item->next;
- else
- self->shm_area = item->next;
- break;
- }
- prev_item = item;
- }
- assert (item);
- }
-
if (area->shm_area_buf != MAP_FAILED)
munmap (area->shm_area_buf, area->shm_area_len);
@@ -367,7 +353,22 @@ sp_shm_area_dec (ShmPipe * self, ShmArea * area)
area->use_count--;
if (area->use_count == 0) {
- sp_close_shm (self, area);
+ ShmArea *item = NULL;
+ ShmArea *prev_item = NULL;
+
+ for (item = self->shm_area; item; item = item->next) {
+ if (item == area) {
+ if (prev_item)
+ prev_item->next = item->next;
+ else
+ self->shm_area = item->next;
+ break;
+ }
+ prev_item = item;
+ }
+ assert (item);
+
+ sp_close_shm (area);
}
}
@@ -784,7 +785,7 @@ sp_shmbuf_dec (ShmPipe * self, ShmBuffer * buf, ShmBuffer * prev_buf)
shm_alloc_space_block_dec (buf->ablock);
sp_shm_area_dec (self, buf->shm_area);
- spalloc_free1 (sizeof (ShmBuffer) + sizeof (int) * sb->num_clients, buf);
+ spalloc_free1 (sizeof (ShmBuffer) + sizeof (int) * buf->num_clients, buf);
return 0;
}
More information about the Gstreamer-commits
mailing list