Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
b2faf630
Verified
Commit
b2faf630
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
Revert DatabaseAccessManager to buggy implementation
parent
7f4e421b
No related branches found
No related tags found
1 merge request
!4
f-fix-deadlock -> dev
Pipeline
#5392
failed
4 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/caosdb/server/database/DatabaseAccessManager.java
+6
-4
6 additions, 4 deletions
...ava/org/caosdb/server/database/DatabaseAccessManager.java
with
6 additions
and
4 deletions
src/main/java/org/caosdb/server/database/DatabaseAccessManager.java
+
6
−
4
View file @
b2faf630
...
...
@@ -26,7 +26,6 @@
package
org.caosdb.server.database
;
import
java.util.concurrent.Semaphore
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.locks.ReentrantLock
;
import
org.caosdb.server.database.access.Access
;
import
org.caosdb.server.database.access.AccessControlAccess
;
...
...
@@ -57,7 +56,7 @@ import org.caosdb.server.utils.Releasable;
class
ReadAccessSemaphore
extends
Semaphore
implements
Releasable
{
private
static
final
long
serialVersionUID
=
4384921156838881337L
;
private
AtomicInteger
acquired
=
new
AtomicInteger
(
0
)
;
// how many threads have read access
private
int
acquired
=
0
;
// how many threads have read access
Semaphore
writersBlock
=
new
Semaphore
(
1
,
true
);
// This semaphore is blocked as long as there are any
// unreleased read permits.
...
...
@@ -74,9 +73,10 @@ class ReadAccessSemaphore extends Semaphore implements Releasable {
@Override
public
void
acquire
()
throws
InterruptedException
{
super
.
acquire
();
// Protect the next few lines
if
(
this
.
acquired
.
getAndIncrement
()
==
0
)
{
if
(
this
.
acquired
==
0
)
{
this
.
writersBlock
.
acquire
();
}
this
.
acquired
++;
super
.
release
();
}
...
...
@@ -87,7 +87,9 @@ class ReadAccessSemaphore extends Semaphore implements Releasable {
*/
@Override
public
void
release
()
{
if
(
this
.
acquired
.
decrementAndGet
()
==
0
)
{
// Last permit: release
this
.
acquired
--;
if
(
this
.
acquired
<=
0
)
{
// Last permit: release
this
.
acquired
=
0
;
if
(
this
.
writersBlock
.
availablePermits
()
<=
0
)
{
this
.
writersBlock
.
release
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment