[pulseaudio-discuss,6/8] rtp: Don't release memblock until we stop accessing underlying data

Submitted by Arun Raghavan on Feb. 29, 2016, 10:16 a.m.

Details

Message ID 1456740996-13908-7-git-send-email-arun@accosted.net
State New
Headers show
Series "Add GStreamer-based RTP support" ( rev: 1 ) in PulseAudio

Not browsing as part of any series.

Commit Message

Arun Raghavan Feb. 29, 2016, 10:16 a.m.
From: Arun Raghavan <git@arunraghavan.net>

---
 src/modules/rtp/rtp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/modules/rtp/rtp.c b/src/modules/rtp/rtp.c
index e372cbd..5a24a03 100644
--- a/src/modules/rtp/rtp.c
+++ b/src/modules/rtp/rtp.c
@@ -256,7 +256,6 @@  int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool, uint32_
     m.msg_flags = 0;
 
     r = recvmsg(c->fd, &m, 0);
-    pa_memblock_release(chunk->memblock);
 
     if (r != size) {
         if (r < 0 && errno != EAGAIN && errno != EINTR)
@@ -274,6 +273,8 @@  int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool, uint32_
     memcpy(rtp_tstamp, (uint8_t*) iov.iov_base + 4, sizeof(uint32_t));
     memcpy(&ssrc, (uint8_t*) iov.iov_base + 8, sizeof(uint32_t));
 
+    pa_memblock_release(chunk->memblock);
+
     header = ntohl(header);
     *rtp_tstamp = ntohl(*rtp_tstamp);
     ssrc = ntohl(c->ssrc);

Comments

On Mon, 2016-02-29 at 15:46 +0530, arun@accosted.net wrote:
> From: Arun Raghavan <git@arunraghavan.net>
> 
> ---
>  src/modules/rtp/rtp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/modules/rtp/rtp.c b/src/modules/rtp/rtp.c
> index e372cbd..5a24a03 100644
> --- a/src/modules/rtp/rtp.c
> +++ b/src/modules/rtp/rtp.c
> @@ -256,7 +256,6 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk
> *chunk, pa_mempool *pool, uint32_
>      m.msg_flags = 0;
>  
>      r = recvmsg(c->fd, &m, 0);
> -    pa_memblock_release(chunk->memblock);
>  
>      if (r != size) {
>          if (r < 0 && errno != EAGAIN && errno != EINTR)
> @@ -274,6 +273,8 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk
> *chunk, pa_mempool *pool, uint32_
>      memcpy(rtp_tstamp, (uint8_t*) iov.iov_base + 4,
> sizeof(uint32_t));
>      memcpy(&ssrc, (uint8_t*) iov.iov_base + 8, sizeof(uint32_t));
>  
> +    pa_memblock_release(chunk->memblock);
> +
>      header = ntohl(header);
>      *rtp_tstamp = ntohl(*rtp_tstamp);
>      ssrc = ntohl(c->ssrc);

Looks good!

-- 
Tanu