From dcaa0c166d0379dba734fde47d911ba7ffd971ce Mon Sep 17 00:00:00 2001 From: zhkag Date: Sat, 7 Jan 2023 02:09:40 +0000 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=20?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=98=9F=E5=88=97=E5=AD=98=E5=9C=A8=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=20O=5FCREAT=20=E4=B8=8D=E5=BA=94?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=96=B0=E7=9A=84=E6=B6=88=E6=81=AF=E9=98=9F?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/posix/ipc/mqueue.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/components/libc/posix/ipc/mqueue.c b/components/libc/posix/ipc/mqueue.c index 8cbe440c9f..8f78037c82 100644 --- a/components/libc/posix/ipc/mqueue.c +++ b/components/libc/posix/ipc/mqueue.c @@ -121,7 +121,13 @@ mqd_t mq_open(const char *name, int oflag, ...) rt_sem_take(&posix_mq_lock, RT_WAITING_FOREVER); mqdes = RT_NULL; - if (oflag & O_CREAT) + /* find mqueue */ + mqdes = posix_mq_find(name); + if (mqdes != RT_NULL) + { + mqdes->refcount ++; /* increase reference count */ + } + else if (oflag & O_CREAT) { va_start(arg, oflag); mode = (mode_t)va_arg(arg, unsigned int); @@ -161,17 +167,8 @@ mqd_t mq_open(const char *name, int oflag, ...) } else { - /* find mqueue */ - mqdes = posix_mq_find(name); - if (mqdes != RT_NULL) - { - mqdes->refcount ++; /* increase reference count */ - } - else - { - rt_set_errno(ENOENT); - goto __return; - } + rt_set_errno(ENOENT); + goto __return; } rt_sem_release(&posix_mq_lock);