Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
bbe2e951
Commit
bbe2e951
authored
Mar 07, 2019
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GdhServer 64-bit refid tree was not treadsafe
parent
294272ba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.c
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.c
+15
-2
No files found.
java/exe/jpwr_rt_gdh/src/jpwr_rt_gdh.c
View file @
bbe2e951
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
#include "rt_cbuf.h"
#include "rt_cbuf.h"
#include "rt_gdh.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "rt_gdh_msg.h"
#include "rt_thread.h"
#include "jpwr_rt_gdh.h"
#include "jpwr_rt_gdh.h"
...
@@ -80,6 +81,7 @@ typedef struct {
...
@@ -80,6 +81,7 @@ typedef struct {
#if defined HW_X86_64
#if defined HW_X86_64
static
tree_sTable
*
jid_table
=
0
;
static
tree_sTable
*
jid_table
=
0
;
static
int
jid_next
=
1
;
static
int
jid_next
=
1
;
static
thread_sMutex
jid_mutex
;
#endif
#endif
static
int
gdh_ExtractNameSuffix
(
char
*
Name
,
static
int
gdh_ExtractNameSuffix
(
char
*
Name
,
...
@@ -3124,8 +3126,13 @@ static int gdh_JidToPointer( int id, void **p)
...
@@ -3124,8 +3126,13 @@ static int gdh_JidToPointer( int id, void **p)
pwr_tStatus
sts
;
pwr_tStatus
sts
;
sJid
*
jp
;
sJid
*
jp
;
thread_MutexLock
(
&
jid_mutex
);
jp
=
tree_Find
(
&
sts
,
jid_table
,
&
id
);
jp
=
tree_Find
(
&
sts
,
jid_table
,
&
id
);
if
(
!
jp
)
return
0
;
thread_MutexUnlock
(
&
jid_mutex
);
if
(
!
jp
)
{
printf
(
"** Jid not found %d %d %lu
\n
"
,
id
,
sts
,
(
unsigned
long
)
jid_table
);
return
0
;
}
*
p
=
jp
->
p
;
*
p
=
jp
->
p
;
return
1
;
return
1
;
...
@@ -3142,19 +3149,22 @@ static int gdh_JidStore( void *p, pwr_tRefId r, int *id)
...
@@ -3142,19 +3149,22 @@ static int gdh_JidStore( void *p, pwr_tRefId r, int *id)
pwr_tStatus
sts
;
pwr_tStatus
sts
;
if
(
!
jid_table
)
{
if
(
!
jid_table
)
{
sts
=
thread_MutexInit
(
&
jid_mutex
);
jid_table
=
tree_CreateTable
(
&
sts
,
sizeof
(
int
),
offsetof
(
sJid
,
jid
),
jid_table
=
tree_CreateTable
(
&
sts
,
sizeof
(
int
),
offsetof
(
sJid
,
jid
),
sizeof
(
sJid
),
10
,
tree_Comp_int32
);
sizeof
(
sJid
),
10
,
tree_Comp_int32
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
}
}
*
id
=
jid_next
++
;
*
id
=
jid_next
++
;
thread_MutexLock
(
&
jid_mutex
);
jp
=
tree_Insert
(
&
sts
,
jid_table
,
id
);
jp
=
tree_Insert
(
&
sts
,
jid_table
,
id
);
thread_MutexUnlock
(
&
jid_mutex
);
if
(
!
jp
)
return
sts
;
if
(
!
jp
)
return
sts
;
jp
->
p
=
p
;
jp
->
p
=
p
;
jp
->
refid
=
r
;
jp
->
refid
=
r
;
// printf( "Jid store: %d
\n", *id
);
// printf( "Jid store: %d
%lu\n", *id, (unsigned long)jid_table
);
return
1
;
return
1
;
#else
#else
*
id
=
(
int
)
p
;
*
id
=
(
int
)
p
;
...
@@ -3168,13 +3178,16 @@ static int gdh_JidRemove( pwr_tRefId r)
...
@@ -3168,13 +3178,16 @@ static int gdh_JidRemove( pwr_tRefId r)
sJid
*
jp
;
sJid
*
jp
;
pwr_tStatus
sts
;
pwr_tStatus
sts
;
thread_MutexLock
(
&
jid_mutex
);
for
(
jp
=
tree_Minimum
(
&
sts
,
jid_table
);
jp
!=
NULL
;
jp
=
tree_Successor
(
&
sts
,
jid_table
,
jp
))
{
for
(
jp
=
tree_Minimum
(
&
sts
,
jid_table
);
jp
!=
NULL
;
jp
=
tree_Successor
(
&
sts
,
jid_table
,
jp
))
{
if
(
jp
->
refid
.
nid
==
r
.
nid
&&
jp
->
refid
.
rix
==
r
.
rix
)
{
if
(
jp
->
refid
.
nid
==
r
.
nid
&&
jp
->
refid
.
rix
==
r
.
rix
)
{
// printf( "Jid remove: %d\n", jp->jid);
// printf( "Jid remove: %d\n", jp->jid);
tree_Remove
(
&
sts
,
jid_table
,
jp
);
tree_Remove
(
&
sts
,
jid_table
,
jp
);
thread_MutexUnlock
(
&
jid_mutex
);
return
1
;
return
1
;
}
}
}
}
thread_MutexUnlock
(
&
jid_mutex
);
return
0
;
return
0
;
#else
#else
return
1
;
return
1
;
...
...
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