From: "Dmitry V. Levin" <ldv@altlinux.org>
To: ALT Devel discussion list <devel@altlinux.ru>
Subject: Re: [devel] IPC и сборка мусора
Date: Sun, 7 Sep 2003 19:26:41 +0400
Message-ID: <20030907152641.GA2137@basalt.office.altlinux.org> (raw)
In-Reply-To: <20030907175235.A99980@elefant.dgtu.donetsk.ua>
[-- Attachment #1.1: Type: text/plain, Size: 1747 bytes --]
On Sun, Sep 07, 2003 at 06:01:36PM +0300, Denis Ovsienko wrote:
> > Это не работает. Точнее говоря, приведённый тест не имеет никакого
> > отношения к обсуждаемой задаче.
> Работает. Имеет. Либо задача решается не теми средствами.
На самом деле задача формулируется так:
гарантировать освобождение ресурсов по окончании сборки.
Другими словами, на клиента рассчитывать нельзя.
> > Короче говоря, IPC_RMID сразу уничтожает ресурс. Ни о какой уборке мусора
> > не может быть и речи. Все остальные процессы, обращающиеся к этому
> > ресурсу, получают (в лучшем случае) ошибку EIDRM.
> Это не так, и даже из лога сессии это видно. Установка флага SHM_DEST не
> мешает другим процессам вызывать shmat(), я это проверял практически. И не
> уничтожает ресурс, пока счётчик присоединённых процессов больше нуля.
Как всегда, истина где-то посередине.
То, что работает с shm, не работает с sem и msg.
Вот пример того, что происходит с очередями:
[user@localhost user]$ ipcs -q
------ Message Queues --------
key msqid owner perms used-bytes messages
[user@localhost user]$ ./msgtest &
[1] 32040
[user@localhost user]$ ./msgtest &
[2] 32041
[user@localhost user]$ ipcs -q
------ Message Queues --------
key msqid owner perms used-bytes messages
0x01070367 3866624 user 600 0 0
[user@localhost user]$ ./msgtest rm
[user@localhost user]$ ./msgtest: msgsnd: Invalid argument
[2]+ Exit 1 ./msgtest
./msgtest: msgsnd: Invalid argument
[1]- Exit 1 ./msgtest
ipcs -q
------ Message Queues --------
key msqid owner perms used-bytes messages
P.S. fakeroot использует только sem и msg.
--
ldv
[-- Attachment #1.2: msgtest.c --]
[-- Type: text/plain, Size: 741 bytes --]
#include <errno.h>
#include <error.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/msg.h>
#define SIZE 1024
struct msgbuf
{
long mtype;
char mtext[SIZE];
};
int
main (int argc, const char *argv[])
{
key_t key = ftok (argv[0], 1);
int msqid = msgget (key, IPC_CREAT | 0600);
if (msqid == -1)
error (1, errno, "msgget");
if (argc >= 2 && !strcmp (argv[1], "rm"))
{
if (msgctl (msqid, IPC_RMID, 0) == -1)
error (1, errno, "msgctl");
return 0;
}
for (;;)
{
struct msgbuf msg;
sleep (1);
msg.mtype = 1;
if (msgsnd (msqid, &msg, SIZE, 0) == -1)
error (1, errno, "msgsnd");
if (msgrcv (msqid, &msg, SIZE, 1, 0) == -1)
error (1, errno, "msgrcv");
}
return 0;
}
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2003-09-07 15:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-07 10:31 Denis Ovsienko
2003-09-07 13:19 ` Dmitry V. Levin
2003-09-07 15:01 ` Denis Ovsienko
2003-09-07 15:26 ` Dmitry V. Levin [this message]
2003-09-08 9:35 ` Denis Ovsienko
2003-09-08 10:17 ` Dmitry V. Levin
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=20030907152641.GA2137@basalt.office.altlinux.org \
--to=ldv@altlinux.org \
--cc=devel@altlinux.ru \
/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
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git