Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
HR_Socket_Msg_Demo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马伊齐
HR_Socket_Msg_Demo
Commits
5571d66a
Commit
5571d66a
authored
Dec 20, 2023
by
马伊齐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动格式化
parent
41a4b49e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
sock_msg.c
lib/sock_msg.c
+14
-14
No files found.
lib/sock_msg.c
View file @
5571d66a
...
...
@@ -16,14 +16,11 @@
#include <sys/shm.h>
#define SHM_KEY 1234
int
msgid
=
-
1
;
// 全局变量,用于存储消息队列ID
int
shmid
;
messageQueue
*
queue
;
// 全局数组来保存socket信息
socket_info_t
sockets
[
MAX_CLIENTS
+
1
]
=
{
0
};
...
...
@@ -286,7 +283,8 @@ int msg_local_ssignal_init(void)
{
// 获取已存在的共享内存
if
((
shmid
=
shmget
(
SHM_KEY
,
sizeof
(
int
),
IPC_CREAT
|
0666
))
<
0
)
{
if
((
shmid
=
shmget
(
SHM_KEY
,
sizeof
(
int
),
IPC_CREAT
|
0666
))
<
0
)
{
perror
(
"shmget"
);
return
-
1
;
}
...
...
@@ -304,7 +302,8 @@ int msg_local_rsignal_init(void)
{
shmid
=
shmget
(
SHM_KEY
,
sizeof
(
int
),
0666
);
// 获取已存在的共享内存
if
((
shmid
=
shmget
(
SHM_KEY
,
sizeof
(
int
),
0666
))
<
0
)
{
if
((
shmid
=
shmget
(
SHM_KEY
,
sizeof
(
int
),
0666
))
<
0
)
{
perror
(
"shmget"
);
return
-
1
;
}
...
...
@@ -316,7 +315,8 @@ int msg_local_rsignal_init(void)
}
}
int
msg_local_send_pulse
(
uint16_t
type
,
uint32_t
code
)
{
int
msg_local_send_pulse
(
uint16_t
type
,
uint32_t
code
)
{
if
(
queue
->
rear
==
queue
->
front
)
{
...
...
@@ -340,7 +340,8 @@ int msg_local_send_pulse(uint16_t type, uint32_t code) {
}
}
int
msg_local_recv_pulse
(
uint16_t
*
type
,
uint32_t
*
code
)
{
int
msg_local_recv_pulse
(
uint16_t
*
type
,
uint32_t
*
code
)
{
if
(
queue
->
rear
==
-
1
)
{
...
...
@@ -361,7 +362,6 @@ int msg_local_recv_pulse(uint16_t *type, uint32_t *code) {
queue
->
rear
=
(
queue
->
rear
+
1
)
%
MAX_QSIZE
;
return
0
;
}
}
int
msg_recv
(
int
channel
,
msg_data_t
*
msg
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment