Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
a7a25bb0
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
大约 1 年 前同步成功
通知
455
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a7a25bb0
编写于
7月 31, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 31, 2021
浏览文件
操作
浏览文件
下载
差异文件
!382 fix mq by enable mq_notify API
Merge pull request !382 from guweijie/master
上级
1394b3be
4427142d
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
201 addition
and
10 deletion
+201
-10
compat/posix/include/mqueue.h
compat/posix/include/mqueue.h
+7
-0
compat/posix/src/mqueue.c
compat/posix/src/mqueue.c
+113
-0
syscall/ipc_syscall.c
syscall/ipc_syscall.c
+12
-0
syscall/los_syscall.h
syscall/los_syscall.h
+1
-0
syscall/syscall_lookup.h
syscall/syscall_lookup.h
+1
-0
testsuites/unittest/posix/mqueue/BUILD.gn
testsuites/unittest/posix/mqueue/BUILD.gn
+5
-5
testsuites/unittest/posix/mqueue/It_posix_queue.h
testsuites/unittest/posix/mqueue/It_posix_queue.h
+5
-5
testsuites/unittest/posix/mqueue/full/It_posix_queue_205.cpp
testsuites/unittest/posix/mqueue/full/It_posix_queue_205.cpp
+0
-0
testsuites/unittest/posix/mqueue/full/It_posix_queue_206.cpp
testsuites/unittest/posix/mqueue/full/It_posix_queue_206.cpp
+0
-0
testsuites/unittest/posix/mqueue/full/It_posix_queue_207.cpp
testsuites/unittest/posix/mqueue/full/It_posix_queue_207.cpp
+0
-0
testsuites/unittest/posix/mqueue/full/It_posix_queue_208.cpp
testsuites/unittest/posix/mqueue/full/It_posix_queue_208.cpp
+0
-0
testsuites/unittest/posix/mqueue/full/It_posix_queue_209.cpp
testsuites/unittest/posix/mqueue/full/It_posix_queue_209.cpp
+0
-0
testsuites/unittest/posix/mqueue/posix_mqueue_test.cpp
testsuites/unittest/posix/mqueue/posix_mqueue_test.cpp
+57
-0
未找到文件。
compat/posix/include/mqueue.h
浏览文件 @
a7a25bb0
...
...
@@ -81,6 +81,11 @@ typedef union send_receive_t {
short
data
;
}
mode_s
;
struct
mqnotify
{
pid_t
pid
;
struct
sigevent
notify
;
};
/* TYPE DEFINITIONS */
struct
mqarray
{
UINT32
mq_id
:
31
;
...
...
@@ -91,6 +96,7 @@ struct mqarray {
uid_t
euid
;
/* euid of mqueue */
gid_t
egid
;
/* egid of mqueue */
fd_set
mq_fdset
;
/* mqueue sysFd bit map */
struct
mqnotify
mq_notify
;
LosQueueCB
*
mqcb
;
struct
mqpersonal
*
mq_personal
;
};
...
...
@@ -418,6 +424,7 @@ extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
unsigned
int
*
msgPrio
,
const
struct
timespec
*
absTimeout
);
extern
void
mqueue_refer
(
int
sysFd
);
extern
int
OsMqNotify
(
mqd_t
personal
,
const
struct
sigevent
*
sigev
);
#ifdef __cplusplus
#if __cplusplus
...
...
compat/posix/src/mqueue.c
浏览文件 @
a7a25bb0
...
...
@@ -120,6 +120,7 @@ STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
mqueueCB
->
mode_data
.
data
=
0
;
mqueueCB
->
euid
=
-
1
;
mqueueCB
->
egid
=
-
1
;
mqueueCB
->
mq_notify
.
pid
=
0
;
ret
=
LOS_QueueDelete
(
mqueueCB
->
mq_id
);
switch
(
ret
)
{
...
...
@@ -204,6 +205,7 @@ STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR
mqueueCB
->
mq_personal
->
mq_flags
=
(
INT32
)((
UINT32
)
openFlag
|
((
UINT32
)
attr
->
mq_flags
&
(
UINT32
)
FNONBLOCK
));
mqueueCB
->
mq_personal
->
mq_mode
=
mode
;
mqueueCB
->
mq_personal
->
mq_refcount
=
0
;
mqueueCB
->
mq_notify
.
pid
=
0
;
return
mqueueCB
->
mq_personal
;
ERROUT:
...
...
@@ -717,6 +719,35 @@ STATIC INLINE BOOL MqParamCheck(mqd_t personal, const char *msg, size_t msgLen)
return
TRUE
;
}
/*
* Send realtime a signal to process which registered itself
* successfully by mq_notify.
*/
static
void
MqSendNotify
(
struct
mqarray
*
mqueueCB
)
{
struct
mqnotify
*
mqnotify
=
&
mqueueCB
->
mq_notify
;
if
((
mqnotify
->
pid
)
&&
(
mqueueCB
->
mqcb
->
readWriteableCnt
[
OS_QUEUE_READ
]
==
0
))
{
siginfo_t
info
;
switch
(
mqnotify
->
notify
.
sigev_notify
)
{
case
SIGEV_SIGNAL
:
/* sends signal */
/* Create the siginfo structure */
info
.
si_signo
=
mqnotify
->
notify
.
sigev_signo
;
info
.
si_code
=
SI_MESGQ
;
info
.
si_value
=
mqnotify
->
notify
.
sigev_value
;
OsDispatch
(
mqnotify
->
pid
,
&
info
,
OS_USER_KILL_PERMISSION
);
break
;
case
SIGEV_NONE
:
default:
break
;
}
/* after notification unregisters process */
mqnotify
->
pid
=
0
;
}
}
#define OS_MQ_GOTO_ERROUT_UNLOCK_IF(expr, errcode) \
if (expr) { \
errno = errcode; \
...
...
@@ -754,6 +785,10 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
mqueueID
=
mqueueCB
->
mq_id
;
(
VOID
)
pthread_mutex_unlock
(
&
g_mqueueMutex
);
if
(
LOS_ListEmpty
(
&
mqueueCB
->
mqcb
->
readWriteList
[
OS_QUEUE_READ
]))
{
MqSendNotify
(
mqueueCB
);
}
err
=
LOS_QueueWriteCopy
(
mqueueID
,
(
VOID
*
)
msg
,
(
UINT32
)
msgLen
,
(
UINT32
)
absTicks
);
if
(
map_errno
(
err
)
!=
ENOERR
)
{
goto
ERROUT
;
...
...
@@ -832,4 +867,82 @@ ssize_t mq_receive(mqd_t personal, char *msg_ptr, size_t msg_len, unsigned int *
return
mq_timedreceive
(
personal
,
msg_ptr
,
msg_len
,
msg_prio
,
NULL
);
}
STATIC
INLINE
BOOL
MqNotifyParamCheck
(
mqd_t
personal
,
const
struct
sigevent
*
sigev
)
{
if
(
personal
<
0
)
{
errno
=
EBADF
;
goto
ERROUT
;
}
if
(
sigev
!=
NULL
)
{
if
(
sigev
->
sigev_notify
!=
SIGEV_NONE
&&
sigev
->
sigev_notify
!=
SIGEV_SIGNAL
)
{
errno
=
EINVAL
;
goto
ERROUT
;
}
if
(
sigev
->
sigev_notify
==
SIGEV_SIGNAL
&&
!
GOOD_SIGNO
(
sigev
->
sigev_signo
))
{
errno
=
EINVAL
;
goto
ERROUT
;
}
}
return
TRUE
;
ERROUT:
return
FALSE
;
}
int
OsMqNotify
(
mqd_t
personal
,
const
struct
sigevent
*
sigev
)
{
struct
mqarray
*
mqueueCB
=
NULL
;
struct
mqnotify
*
mqnotify
=
NULL
;
struct
mqpersonal
*
privateMqPersonal
=
NULL
;
if
(
!
MqNotifyParamCheck
(
personal
,
sigev
))
{
goto
ERROUT
;
}
(
VOID
)
pthread_mutex_lock
(
&
g_mqueueMutex
);
privateMqPersonal
=
MqGetPrivDataBuff
(
personal
);
if
(
privateMqPersonal
==
NULL
)
{
goto
OUT_UNLOCK
;
}
if
(
privateMqPersonal
->
mq_status
!=
MQ_USE_MAGIC
)
{
errno
=
EBADF
;
goto
OUT_UNLOCK
;
}
mqueueCB
=
privateMqPersonal
->
mq_posixdes
;
mqnotify
=
&
mqueueCB
->
mq_notify
;
if
(
sigev
==
NULL
)
{
if
(
mqnotify
->
pid
==
LOS_GetCurrProcessID
())
{
mqnotify
->
pid
=
0
;
}
}
else
if
(
mqnotify
->
pid
!=
0
)
{
errno
=
EBUSY
;
goto
OUT_UNLOCK
;
}
else
{
switch
(
sigev
->
sigev_notify
)
{
case
SIGEV_NONE
:
mqnotify
->
notify
.
sigev_notify
=
SIGEV_NONE
;
break
;
case
SIGEV_SIGNAL
:
mqnotify
->
notify
.
sigev_signo
=
sigev
->
sigev_signo
;
mqnotify
->
notify
.
sigev_value
=
sigev
->
sigev_value
;
mqnotify
->
notify
.
sigev_notify
=
SIGEV_SIGNAL
;
break
;
default:
break
;
}
mqnotify
->
pid
=
LOS_GetCurrProcessID
();
}
(
VOID
)
pthread_mutex_unlock
(
&
g_mqueueMutex
);
return
0
;
OUT_UNLOCK:
(
VOID
)
pthread_mutex_unlock
(
&
g_mqueueMutex
);
ERROUT:
return
-
1
;
}
#endif
syscall/ipc_syscall.c
浏览文件 @
a7a25bb0
...
...
@@ -87,6 +87,18 @@ int SysMqClose(mqd_t personal)
return
ret
;
}
int
SysMqNotify
(
mqd_t
personal
,
const
struct
sigevent
*
sigev
)
{
int
ret
;
MQUEUE_FD_U2K
(
personal
);
ret
=
OsMqNotify
(
personal
,
sigev
);
if
(
ret
<
0
)
{
return
-
get_errno
();
}
return
ret
;
}
int
SysMqGetSetAttr
(
mqd_t
mqd
,
const
struct
mq_attr
*
new
,
struct
mq_attr
*
old
)
{
int
ret
;
...
...
syscall/los_syscall.h
浏览文件 @
a7a25bb0
...
...
@@ -125,6 +125,7 @@ extern int SysMqTimedSend(mqd_t personal, const char *msg, size_t msgLen, unsign
const
struct
timespec
*
absTimeout
);
extern
ssize_t
SysMqTimedReceive
(
mqd_t
personal
,
char
*
msg
,
size_t
msgLen
,
unsigned
int
*
msgPrio
,
const
struct
timespec
*
absTimeout
);
extern
int
SysMqNotify
(
mqd_t
personal
,
const
struct
sigevent
*
sigev
);
#endif
extern
int
SysSigAction
(
int
sig
,
const
sigaction_t
*
restrict
sa
,
sigaction_t
*
restrict
old
,
size_t
sigsetsize
);
...
...
syscall/syscall_lookup.h
浏览文件 @
a7a25bb0
...
...
@@ -216,6 +216,7 @@ SYSCALL_HAND_DEF(__NR_mq_open, SysMqOpen, mqd_t, ARG_NUM_4)
SYSCALL_HAND_DEF
(
__NR_mq_unlink
,
SysMqUnlink
,
int
,
ARG_NUM_1
)
SYSCALL_HAND_DEF
(
__NR_mq_timedsend
,
SysMqTimedSend
,
int
,
ARG_NUM_5
)
SYSCALL_HAND_DEF
(
__NR_mq_timedreceive
,
SysMqTimedReceive
,
ssize_t
,
ARG_NUM_5
)
SYSCALL_HAND_DEF
(
__NR_mq_notify
,
SysMqNotify
,
int
,
ARG_NUM_2
)
SYSCALL_HAND_DEF
(
__NR_mq_getsetattr
,
SysMqGetSetAttr
,
int
,
ARG_NUM_3
)
#ifdef LOSCFG_NET_LWIP_SACK
...
...
testsuites/unittest/posix/mqueue/BUILD.gn
浏览文件 @
a7a25bb0
...
...
@@ -52,11 +52,6 @@ sources_smoke = [
"smoke/It_posix_queue_028.cpp",
"smoke/It_posix_queue_053.cpp",
"smoke/It_posix_queue_062.cpp",
"smoke/It_posix_queue_205.cpp",
"smoke/It_posix_queue_206.cpp",
"smoke/It_posix_queue_207.cpp",
"smoke/It_posix_queue_208.cpp",
"smoke/It_posix_queue_209.cpp",
]
sources_full = [
...
...
@@ -200,6 +195,11 @@ sources_full = [
"full/It_posix_queue_202.cpp",
"full/It_posix_queue_203.cpp",
"full/It_posix_queue_204.cpp",
"full/It_posix_queue_205.cpp",
"full/It_posix_queue_206.cpp",
"full/It_posix_queue_207.cpp",
"full/It_posix_queue_208.cpp",
"full/It_posix_queue_209.cpp",
]
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
...
...
testsuites/unittest/posix/mqueue/It_posix_queue.h
浏览文件 @
a7a25bb0
...
...
@@ -120,11 +120,6 @@ VOID ItPosixQueue001(VOID);
VOID
ItPosixQueue003
(
VOID
);
VOID
ItPosixQueue028
(
VOID
);
VOID
ItPosixQueue062
(
VOID
);
VOID
ItPosixQueue205
(
VOID
);
VOID
ItPosixQueue206
(
VOID
);
VOID
ItPosixQueue207
(
VOID
);
VOID
ItPosixQueue208
(
VOID
);
VOID
ItPosixQueue209
(
VOID
);
VOID
ItPosixQueue053
(
VOID
);
VOID
ItPosixQueue144
(
VOID
);
#endif
...
...
@@ -274,5 +269,10 @@ VOID ItPosixQueue202(VOID);
VOID
ItPosixQueue203
(
VOID
);
VOID
ItPosixQueue204
(
VOID
);
VOID
ItPosixQueue205
(
VOID
);
VOID
ItPosixQueue206
(
VOID
);
VOID
ItPosixQueue207
(
VOID
);
VOID
ItPosixQueue208
(
VOID
);
VOID
ItPosixQueue209
(
VOID
);
#endif
#endif
testsuites/unittest/posix/mqueue/
smoke
/It_posix_queue_205.cpp
→
testsuites/unittest/posix/mqueue/
full
/It_posix_queue_205.cpp
浏览文件 @
a7a25bb0
文件已移动
testsuites/unittest/posix/mqueue/
smoke
/It_posix_queue_206.cpp
→
testsuites/unittest/posix/mqueue/
full
/It_posix_queue_206.cpp
浏览文件 @
a7a25bb0
文件已移动
testsuites/unittest/posix/mqueue/
smoke
/It_posix_queue_207.cpp
→
testsuites/unittest/posix/mqueue/
full
/It_posix_queue_207.cpp
浏览文件 @
a7a25bb0
文件已移动
testsuites/unittest/posix/mqueue/
smoke
/It_posix_queue_208.cpp
→
testsuites/unittest/posix/mqueue/
full
/It_posix_queue_208.cpp
浏览文件 @
a7a25bb0
文件已移动
testsuites/unittest/posix/mqueue/
smoke
/It_posix_queue_209.cpp
→
testsuites/unittest/posix/mqueue/
full
/It_posix_queue_209.cpp
浏览文件 @
a7a25bb0
文件已移动
testsuites/unittest/posix/mqueue/posix_mqueue_test.cpp
浏览文件 @
a7a25bb0
...
...
@@ -1354,6 +1354,63 @@ HWTEST_F(PosixMqueueTest, ItPosixQueue204, TestSize.Level0)
{
ItPosixQueue204
();
}
#endif
/**
* @tc.name: IT_POSIX_QUEUE_205
* @tc.desc: function for mq_notify:Set sigev_notify to SIGEV_NONE
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
PosixMqueueTest
,
ItPosixQueue205
,
TestSize
.
Level0
)
{
ItPosixQueue205
();
}
/**
* @tc.name: IT_POSIX_QUEUE_206
* @tc.desc: function for mq_notify:The function returns a failure and the error code is verified.
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
PosixMqueueTest
,
ItPosixQueue206
,
TestSize
.
Level0
)
{
ItPosixQueue206
();
}
/**
* @tc.name: IT_POSIX_QUEUE_207
* @tc.desc: function for mq_notify:Set sigev_notify to SIGEV_NONE
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
PosixMqueueTest
,
ItPosixQueue207
,
TestSize
.
Level0
)
{
ItPosixQueue207
();
}
/**
* @tc.name: IT_POSIX_QUEUE_208
* @tc.desc: function for mq_notify:The message queue is not empty.
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
PosixMqueueTest
,
ItPosixQueue208
,
TestSize
.
Level0
)
{
ItPosixQueue208
();
}
/**
* @tc.name: IT_POSIX_QUEUE_209
* @tc.desc: function for mq_notify:The message queue has waiters.
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
**/
HWTEST_F
(
PosixMqueueTest
,
ItPosixQueue209
,
TestSize
.
Level0
)
{
ItPosixQueue209
();
}
#endif
}
// namespace OHOS
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录