Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Configuration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Application
Configuration
Commits
be48805f
Verified
Commit
be48805f
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: deadlock
#4
parent
85c27d07
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
change.go
+21
-25
21 additions, 25 deletions
change.go
copyable.go
+7
-5
7 additions, 5 deletions
copyable.go
devenv.nix
+28
-28
28 additions, 28 deletions
devenv.nix
http-handler.go
+3
-2
3 additions, 2 deletions
http-handler.go
import.go
+3
-2
3 additions, 2 deletions
import.go
with
62 additions
and
62 deletions
change.go
+
21
−
25
View file @
be48805f
...
@@ -7,25 +7,21 @@ import (
...
@@ -7,25 +7,21 @@ import (
"github.com/r3labs/diff/v3"
"github.com/r3labs/diff/v3"
)
)
func
(
s
*
Settings
[
C
])
setConfigInternal
(
config
C
,
lock
bool
)
*
Settings
[
C
]
{
func
(
s
*
Settings
[
C
])
notifyHooks
(
changelog
diff
.
Changelog
)
{
var
(
changelog
diff
.
Changelog
err
error
)
if
lock
{
s
.
Lock
()
}
defer
func
()
{
if
len
(
changelog
)
>
0
{
if
len
(
changelog
)
>
0
{
s
.
notifyPostprocessingHooks
(
changelog
)
s
.
notifyPostprocessingHooks
(
changelog
)
s
.
notifyChangeHooks
(
changelog
)
s
.
notifyChangeHooks
(
changelog
)
}
}
}()
}
func
(
s
*
Settings
[
C
])
setConfigInternal
(
config
C
)
(
*
Settings
[
C
],
diff
.
Changelog
)
{
var
(
changelog
diff
.
Changelog
err
error
)
errorCount
:=
len
(
s
.
errors
)
errorCount
:=
len
(
s
.
errors
)
defer
func
()
{
defer
func
()
{
...
@@ -34,21 +30,15 @@ func (s *Settings[C]) setConfigInternal(config C, lock bool) *Settings[C] {
...
@@ -34,21 +30,15 @@ func (s *Settings[C]) setConfigInternal(config C, lock bool) *Settings[C] {
}
}
}()
}()
defer
func
()
{
if
lock
{
s
.
Unlock
()
}
}()
if
err
:=
validateConfig
[
C
](
config
);
err
!=
nil
{
if
err
:=
validateConfig
[
C
](
config
);
err
!=
nil
{
s
.
errors
=
append
(
s
.
errors
,
err
)
s
.
errors
=
append
(
s
.
errors
,
err
)
return
s
return
s
,
changelog
}
}
d
,
err
:=
diff
.
NewDiffer
()
d
,
err
:=
diff
.
NewDiffer
()
if
err
!=
nil
{
if
err
!=
nil
{
s
.
errors
=
append
(
s
.
errors
,
err
)
s
.
errors
=
append
(
s
.
errors
,
err
)
return
s
return
s
,
changelog
}
}
d
.
ConvertCompatibleTypes
=
true
d
.
ConvertCompatibleTypes
=
true
...
@@ -57,13 +47,19 @@ func (s *Settings[C]) setConfigInternal(config C, lock bool) *Settings[C] {
...
@@ -57,13 +47,19 @@ func (s *Settings[C]) setConfigInternal(config C, lock bool) *Settings[C] {
changelog
,
err
=
d
.
Diff
(
s
.
config
,
config
)
changelog
,
err
=
d
.
Diff
(
s
.
config
,
config
)
if
err
!=
nil
{
if
err
!=
nil
{
s
.
errors
=
append
(
s
.
errors
,
err
)
s
.
errors
=
append
(
s
.
errors
,
err
)
return
s
return
s
,
changelog
}
}
s
.
config
=
config
s
.
config
=
config
return
s
return
s
,
changelog
}
}
func
(
s
*
Settings
[
C
])
SetConfig
(
config
C
)
*
Settings
[
C
]
{
func
(
s
*
Settings
[
C
])
SetConfig
(
config
C
)
*
Settings
[
C
]
{
return
s
.
setConfigInternal
(
config
,
true
)
s
.
Lock
()
c
,
l
:=
s
.
setConfigInternal
(
config
)
s
.
Unlock
()
s
.
notifyHooks
(
l
)
return
c
}
}
This diff is collapsed.
Click to expand it.
copyable.go
+
7
−
5
View file @
be48805f
...
@@ -7,15 +7,14 @@ import (
...
@@ -7,15 +7,14 @@ import (
"gitlab.schukai.com/oss/libraries/go/utilities/pathfinder"
"gitlab.schukai.com/oss/libraries/go/utilities/pathfinder"
)
)
//
// Copy implements the xflags.Copyable interface.
// Copy implements the xflags.Copyable interface.
func
(
s
*
Settings
[
C
])
Copy
(
m
map
[
string
]
any
)
{
func
(
s
*
Settings
[
C
])
Copy
(
m
map
[
string
]
any
)
{
if
s
==
nil
{
if
s
==
nil
{
panic
(
"
struct is not initialized
"
)
panic
(
"
cannot copy nil
"
)
}
}
s
.
Lock
()
s
.
Lock
()
defer
s
.
Unlock
()
errorCount
:=
len
(
s
.
errors
)
errorCount
:=
len
(
s
.
errors
)
defer
func
()
{
defer
func
()
{
...
@@ -37,6 +36,9 @@ func (s *Settings[C]) Copy(m map[string]any) {
...
@@ -37,6 +36,9 @@ func (s *Settings[C]) Copy(m map[string]any) {
}
}
}
}
s
.
setConfigInternal
(
c
,
false
)
_
,
l
:=
s
.
setConfigInternal
(
c
)
s
.
Unlock
()
s
.
notifyHooks
(
l
)
}
}
This diff is collapsed.
Click to expand it.
devenv.nix
+
28
−
28
View file @
be48805f
...
@@ -3,34 +3,34 @@
...
@@ -3,34 +3,34 @@
{
{
# https://devenv.sh/packages/
# https://devenv.sh/packages/
packages
=
[
packages
=
with
pkgs
;
[
inputs
.
version
.
defaultPackage
.
"
${
builtins
.
currentSystem
}
"
inputs
.
version
.
defaultPackage
.
"
${
builtins
.
currentSystem
}
"
pkgs
.
git
git
pkgs
.
gcc12
gcc12
pkgs
.
go-task
go-task
pkgs
.
blackbox
blackbox
pkgs
.
blackbox-terminal
blackbox-terminal
pkgs
.
jq
jq
pkgs
.
delve
delve
pkgs
.
gdlv
gdlv
pkgs
.
wget
wget
pkgs
.
glab
glab
pkgs
.
unixtools
.
xxd
unixtools
.
xxd
pkgs
.
libffi
libffi
pkgs
.
zlib
zlib
pkgs
.
procps
procps
pkgs
.
php81Extensions
.
xdebug
php81Extensions
.
xdebug
pkgs
.
ranger
ranger
pkgs
.
meld
meld
pkgs
.
gnused
gnused
pkgs
.
coreutils-full
coreutils-full
pkgs
.
gnugrep
gnugrep
pkgs
.
gnumake
gnumake
pkgs
.
util-linux
util-linux
pkgs
.
httpie
httpie
pkgs
.
netcat
netcat
pkgs
.
memcached
memcached
pkgs
.
fd
fd
];
];
...
@@ -65,7 +65,7 @@ PATH="''${PATH}":${pkgs.git}/bin/
...
@@ -65,7 +65,7 @@ PATH="''${PATH}":${pkgs.git}/bin/
PATH="
''$
{PATH}":
${
pkgs
.
gnugrep
}
/bin/
PATH="
''$
{PATH}":
${
pkgs
.
gnugrep
}
/bin/
PATH="
''$
{PATH}":
${
inputs
.
version
.
defaultPackage
.
"
${
builtins
.
currentSystem
}
"
}
/bin/
PATH="
''$
{PATH}":
${
inputs
.
version
.
defaultPackage
.
"
${
builtins
.
currentSystem
}
"
}
/bin/
export
-f
PATH
export PATH
task test
task test
...
...
This diff is collapsed.
Click to expand it.
http-handler.go
+
3
−
2
View file @
be48805f
...
@@ -83,7 +83,6 @@ func (s *Settings[C]) servePost(w http.ResponseWriter, r *http.Request) {
...
@@ -83,7 +83,6 @@ func (s *Settings[C]) servePost(w http.ResponseWriter, r *http.Request) {
}
}
s
.
Lock
()
s
.
Lock
()
defer
s
.
Unlock
()
b
:=
s
.
config
b
:=
s
.
config
s
.
importStream
(
rs
)
s
.
importStream
(
rs
)
...
@@ -91,7 +90,9 @@ func (s *Settings[C]) servePost(w http.ResponseWriter, r *http.Request) {
...
@@ -91,7 +90,9 @@ func (s *Settings[C]) servePost(w http.ResponseWriter, r *http.Request) {
x
:=
s
.
config
x
:=
s
.
config
s
.
config
=
b
s
.
config
=
b
s
.
setConfigInternal
(
x
,
false
)
_
,
l
:=
s
.
setConfigInternal
(
x
)
s
.
Unlock
()
s
.
notifyHooks
(
l
)
}
}
...
...
This diff is collapsed.
Click to expand it.
import.go
+
3
−
2
View file @
be48805f
...
@@ -187,7 +187,6 @@ func (s *Settings[C]) importFiles() {
...
@@ -187,7 +187,6 @@ func (s *Settings[C]) importFiles() {
func
(
s
*
Settings
[
C
])
Import
()
*
Settings
[
C
]
{
func
(
s
*
Settings
[
C
])
Import
()
*
Settings
[
C
]
{
s
.
Lock
()
s
.
Lock
()
defer
s
.
Unlock
()
errorCount
:=
len
(
s
.
errors
)
errorCount
:=
len
(
s
.
errors
)
defer
func
()
{
defer
func
()
{
...
@@ -216,7 +215,9 @@ func (s *Settings[C]) Import() *Settings[C] {
...
@@ -216,7 +215,9 @@ func (s *Settings[C]) Import() *Settings[C] {
x
:=
s
.
config
x
:=
s
.
config
s
.
config
=
defaults
s
.
config
=
defaults
s
.
setConfigInternal
(
x
,
false
)
_
,
l
:=
s
.
setConfigInternal
(
x
)
s
.
Unlock
()
s
.
notifyHooks
(
l
)
return
s
return
s
}
}
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