* SysV IPC message queues
@ 2010-03-22 2:28 Kyle Hubert
2010-03-22 8:46 ` Kyle Hubert
0 siblings, 1 reply; 3+ messages in thread
From: Kyle Hubert @ 2010-03-22 2:28 UTC (permalink / raw)
To: linux-kernel
Hi, I recently found myself using SysV IPC message queues in a Linux
specific application. However, I have one concern, I'm using
IPC_PRIVATE for the key to instantiate the message queue (then doing
pthread_creates with the open file descriptor accessed from children
threads).
Anyways, upon reception of signals, the message queue lingers around
taking up memory. I wouldn't mind this if I was using a key_t which I
could use to reopen the message queue at a later instantiation.
However, IPC_PRIVATE just grabs an available queue, and I don't have
access to the key, so I can't exactly open and remove it later. It's
my opinion that IPC_PRIVATE should cause the message queue to get
destroyed when all the open file descriptors are closed, not solely
when msgctl is used to remove it. Also, I don't want to capture
signals, since that's a slippery slope and SIGKILL will still leak
message queues. I also don't think ipcs/ipcrm are long term solutions,
since I'm handing the library off as an abstraction.
Would it be worth it to generate a patch to the Linux kernel to add
this functionality? Or, is there an undocumented ioctl I can call to
set that feature on?
IE: IPC_PRIVATE message queues should be freed when ref count drops to zero.
Thank you very much for your time,
-Kyle Hubert
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: SysV IPC message queues
2010-03-22 2:28 SysV IPC message queues Kyle Hubert
@ 2010-03-22 8:46 ` Kyle Hubert
2010-03-22 19:02 ` David Newall
0 siblings, 1 reply; 3+ messages in thread
From: Kyle Hubert @ 2010-03-22 8:46 UTC (permalink / raw)
To: linux-kernel
OK, so the Linux kernel implementation does syscalls for SysV IPC
message queues, hence the lack of freeing resources when IPC_PRIVATE
is used. If IPC_PRIVATE is used, can't we open a file descriptor for
the user process, and it's file operation on close would just call
freequeue?
Thanks,
-Kyle Hubert
On Sun, Mar 21, 2010 at 7:28 PM, Kyle Hubert <khubert@gmail.com> wrote:
> Hi, I recently found myself using SysV IPC message queues in a Linux
> specific application. However, I have one concern, I'm using
> IPC_PRIVATE for the key to instantiate the message queue (then doing
> pthread_creates with the open file descriptor accessed from children
> threads).
>
> Anyways, upon reception of signals, the message queue lingers around
> taking up memory. I wouldn't mind this if I was using a key_t which I
> could use to reopen the message queue at a later instantiation.
> However, IPC_PRIVATE just grabs an available queue, and I don't have
> access to the key, so I can't exactly open and remove it later. It's
> my opinion that IPC_PRIVATE should cause the message queue to get
> destroyed when all the open file descriptors are closed, not solely
> when msgctl is used to remove it. Also, I don't want to capture
> signals, since that's a slippery slope and SIGKILL will still leak
> message queues. I also don't think ipcs/ipcrm are long term solutions,
> since I'm handing the library off as an abstraction.
>
> Would it be worth it to generate a patch to the Linux kernel to add
> this functionality? Or, is there an undocumented ioctl I can call to
> set that feature on?
>
> IE: IPC_PRIVATE message queues should be freed when ref count drops to zero.
>
> Thank you very much for your time,
>
> -Kyle Hubert
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: SysV IPC message queues
2010-03-22 8:46 ` Kyle Hubert
@ 2010-03-22 19:02 ` David Newall
0 siblings, 0 replies; 3+ messages in thread
From: David Newall @ 2010-03-22 19:02 UTC (permalink / raw)
To: Kyle Hubert; +Cc: linux-kernel
Kyle,
Processes do not open nor close message queues, rather they place
messages on and fetch them from queues. Let me say this again: you do
not open a queue like you must for a file, but go directly to the
equivalent of read and write. There is no refcount to indicate how many
processes are "using" a queue, although there may be one indicating how
many are actively waiting to receive a message. Removing a queue when
that count reaches zero would be quite wrong because a process stops
waiting as soon as it receives a message; so the count would be zero
more often than not.
Do not allow IPC_PRIVATE to lead you into false understanding of what a
message queue is. IPC_PRIVATE does not cause creation of a private
queue, as indicated in msgget(2): "The name choice IPC_PRIVATE was
perhaps unfortunate, IPC_NEW would more clearly show its function."
Queues are not accessed by key but by id. You do not need to know the
key for a queue to access it, neither do you need to use msgget(2) to
find a queue's id.
So, no, sorry, but your idea must be rejected.
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-22 19:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-22 2:28 SysV IPC message queues Kyle Hubert
2010-03-22 8:46 ` Kyle Hubert
2010-03-22 19:02 ` David Newall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome