All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Kai <mlist1@bollue.de>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai] Pool memory leak when writing to full queue
Date: Fri, 13 Jul 2012 21:00:21 +0200	[thread overview]
Message-ID: <50007045.8040208@xenomai.org> (raw)
In-Reply-To: <4FFF2C70.7080509@bollue.de>

On 07/12/2012 09:58 PM, Kai wrote:
> Hi,
>
> I have a problem using rt_queue_write() (native skin):
> As far as I understand, the function wraps around rt_queue_send() by
> allocating pool memory first and memcpy-ing the user-supplied buffer
> into it.
> Problem: If sending fails because the queue is full (w.r.t. the number
> of queued messages), the error is returned to the caller, but the
> allocated pool memory is never freed.
> The attached program shows how the pool memory gets almost completely
> filled without any messages left in the queue.
>
> The following patch seems to fix it:
>
> --- xenomai-2.6.1/ksrc/skins/native/syscall_old.c       2012-07-12
> 19:53:48.464968791 +0200
> +++ xenomai-2.6.1/ksrc/skins/native/syscall.c   2012-07-12
> 19:48:34.174968603 +0200
> @@ -2358,6 +2358,8 @@
>          ret = rt_queue_send(q, mbuf, size, mode);
>          if (ret == 0 && (mode & Q_BROADCAST))
>                  rt_queue_free(q, mbuf); /* Nobody received, free the
> buffer. */
> +       if (ret < 0) /* Send failed */
> +               rt_queue_free(q, mbuf);
>
>          return ret;
>   }

Ack. Picking this one for 2.6.2, thanks.

-- 
Philippe.




      reply	other threads:[~2012-07-13 19:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-12 19:58 [Xenomai] Pool memory leak when writing to full queue Kai
2012-07-13 19:00 ` Philippe Gerum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50007045.8040208@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=mlist1@bollue.de \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.