Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
acfa2b94
Unverified
Commit
acfa2b94
authored
Mar 24, 2024
by
Blake Mizerany
Committed by
GitHub
Mar 24, 2024
Browse files
llm: prevent race appending to slice (#3320)
parent
2c390a73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
llm/payload_common.go
llm/payload_common.go
+6
-2
No files found.
llm/payload_common.go
View file @
acfa2b94
...
...
@@ -11,6 +11,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
...
...
@@ -147,9 +148,10 @@ func extractDynamicLibs(payloadsDir, glob string) ([]string, error) {
if
err
!=
nil
||
len
(
files
)
==
0
{
return
nil
,
payloadMissing
}
libs
:=
[]
string
{}
g
:=
new
(
errgroup
.
Group
)
var
mu
sync
.
Mutex
var
libs
[]
string
var
g
errgroup
.
Group
for
_
,
file
:=
range
files
{
pathComps
:=
strings
.
Split
(
file
,
"/"
)
if
len
(
pathComps
)
!=
pathComponentCount
{
...
...
@@ -182,7 +184,9 @@ func extractDynamicLibs(payloadsDir, glob string) ([]string, error) {
destFile
:=
filepath
.
Join
(
targetDir
,
filepath
.
Base
(
filename
))
if
strings
.
Contains
(
destFile
,
"server"
)
{
mu
.
Lock
()
libs
=
append
(
libs
,
destFile
)
mu
.
Unlock
()
}
destFp
,
err
:=
os
.
OpenFile
(
destFile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0
o755
)
...
...
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