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
ee3905f6
Commit
ee3905f6
authored
May 16, 2020
by
houkime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make locks honor TMPDIR
parent
ad0faecb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
src/lib/rt/src/rt_lck.c
src/lib/rt/src/rt_lck.c
+21
-4
src/lib/rt/src/rt_lck.h
src/lib/rt/src/rt_lck.h
+2
-0
No files found.
src/lib/rt/src/rt_lck.c
View file @
ee3905f6
...
@@ -42,13 +42,26 @@
...
@@ -42,13 +42,26 @@
#include "rt_lck.h"
#include "rt_lck.h"
static
char
lck_cName
[
lck_eLock__
][
40
]
static
char
lck_cName
[
lck_eLock__
][
40
]
=
{
"
/tmp/pwr_nmps_lock"
,
"/tmp/pwr_time_lock"
,
"/tmp/
pwr_str_lock"
};
=
{
"
pwr_nmps_lock"
,
"pwr_time_lock"
,
"
pwr_str_lock"
};
sect_sHead
*
lck_locksect
[
lck_eLock__
]
=
{
0
,
0
,
0
};
sect_sHead
*
lck_locksect
[
lck_eLock__
]
=
{
0
,
0
,
0
};
static
void
appendTmpdirPrefix
(
pwr_tFileName
segname
,
char
*
name
)
{
char
*
tmpdir
=
getenv
(
"TMPDIR"
);
if
(
!
tmpdir
)
{
tmpdir
=
lck_cDefaultTmpDir
;
}
sprintf
(
segname
,
"%s/%s"
,
tmpdir
,
name
);
}
void
lck_Create
(
pwr_tStatus
*
sts
,
lck_eLock
lock
)
void
lck_Create
(
pwr_tStatus
*
sts
,
lck_eLock
lock
)
{
{
pwr_tBoolean
created
;
pwr_tBoolean
created
;
pwr_tFileName
segname
;
if
(
lock
>=
lck_eLock__
)
{
if
(
lock
>=
lck_eLock__
)
{
*
sts
=
0
;
*
sts
=
0
;
...
@@ -60,8 +73,10 @@ void lck_Create(pwr_tStatus* sts, lck_eLock lock)
...
@@ -60,8 +73,10 @@ void lck_Create(pwr_tStatus* sts, lck_eLock lock)
return
;
return
;
}
}
appendTmpdirPrefix
(
segname
,
lck_cName
[
lock
]);
lck_locksect
[
lock
]
=
sect_Alloc
(
sts
,
&
created
,
0
,
sizeof
(
sect_sMutex
),
lck_locksect
[
lock
]
=
sect_Alloc
(
sts
,
&
created
,
0
,
sizeof
(
sect_sMutex
),
lck_cName
[
lock
]
,
sect_mFlags_Create
);
segname
,
sect_mFlags_Create
);
if
(
ODD
(
*
sts
)
&&
created
)
if
(
ODD
(
*
sts
)
&&
created
)
sect_InitLock
(
sect_InitLock
(
sts
,
lck_locksect
[
lock
],
(
sect_sMutex
*
)
lck_locksect
[
lock
]
->
base
);
sts
,
lck_locksect
[
lock
],
(
sect_sMutex
*
)
lck_locksect
[
lock
]
->
base
);
...
@@ -87,7 +102,8 @@ void lck_Delete(pwr_tStatus* sts, lck_eLock lock)
...
@@ -87,7 +102,8 @@ void lck_Delete(pwr_tStatus* sts, lck_eLock lock)
return
;
return
;
}
}
char
segname
[
128
];
pwr_tFileName
proto_segname
;
pwr_tFileName
segname
;
char
busid
[
8
];
char
busid
[
8
];
char
*
str
=
getenv
(
pwr_dEnvBusId
);
char
*
str
=
getenv
(
pwr_dEnvBusId
);
key_t
key
;
key_t
key
;
...
@@ -97,7 +113,8 @@ void lck_Delete(pwr_tStatus* sts, lck_eLock lock)
...
@@ -97,7 +113,8 @@ void lck_Delete(pwr_tStatus* sts, lck_eLock lock)
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
busid
[
3
]
=
'\0'
;
busid
[
3
]
=
'\0'
;
sprintf
(
segname
,
"%s_%.3s"
,
lck_cName
[
lock
],
busid
);
appendTmpdirPrefix
(
proto_segname
,
lck_cName
[
lock
]);
sprintf
(
segname
,
"%s_%.3s"
,
proto_segname
,
busid
);
key
=
ftok
(
segname
,
'P'
);
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shm_id
=
shmget
(
key
,
0
,
0660
);
...
...
src/lib/rt/src/rt_lck.h
View file @
ee3905f6
...
@@ -50,6 +50,8 @@ typedef enum {
...
@@ -50,6 +50,8 @@ typedef enum {
lck_eLock__
lck_eLock__
}
lck_eLock
;
}
lck_eLock
;
#define lck_cDefaultTmpDir "/tmp/"
#define lck_Lock(lock) \
#define lck_Lock(lock) \
sect_Lock(NULL, lck_locksect[lock], (sect_sMutex*)lck_locksect[lock]->base);
sect_Lock(NULL, lck_locksect[lock], (sect_sMutex*)lck_locksect[lock]->base);
#define lck_Unlock(lock) \
#define lck_Unlock(lock) \
...
...
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