Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
5c41d82a
Commit
5c41d82a
authored
Oct 21, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2493c259
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
wcfs/wcfs.go
wcfs/wcfs.go
+13
-6
No files found.
wcfs/wcfs.go
View file @
5c41d82a
...
...
@@ -181,6 +181,8 @@
// files to @<revX>/bigfile/<bigfileX> drops to zero, and automatically
// destroys @<revX>/bigfile/<bigfileX> after reasonable timeout.
//
// XXX document "bye"
//
//
// Protection against slow or faulty clients
//
...
...
@@ -1883,7 +1885,7 @@ func (wlink *WatchLink) _serve() (err error) {
// XXX recheck that it is safe to handle multiple simultaneous watch requests.
for
{
l
,
err
:=
r
.
ReadString
(
'\n'
)
// XXX
limit accepted line len to prevent DOS
l
,
err
:=
r
.
ReadString
(
'\n'
)
// TODO
limit accepted line len to prevent DOS
if
err
!=
nil
{
// r.Read is woken up by sk.CloseRead when serve decides to exit
if
err
==
io
.
ErrClosedPipe
||
err
==
io
.
EOF
{
...
...
@@ -1957,7 +1959,8 @@ func (wlink *WatchLink) _handleWatch(ctx context.Context, msg string) error {
// sendReq sends wcfs-originated request to client and returns client response.
func
(
wlink
*
WatchLink
)
sendReq
(
ctx
context
.
Context
,
req
string
)
(
reply
string
,
err
error
)
{
// XXX err ctx
defer
xerr
.
Context
(
&
err
,
"sendReq"
)
// wlink is already put into ctx by caller
var
stream
uint64
for
stream
==
0
{
stream
=
atomic
.
AddUint64
(
&
wlink
.
reqNext
,
+
2
)
...
...
@@ -1986,16 +1989,20 @@ func (wlink *WatchLink) sendReq(ctx context.Context, req string) (reply string,
// send sends a message to client over specified stream ID.
//
// Multiple send can be called simultaneously; send serializes writes.
func
(
wlink
*
WatchLink
)
send
(
ctx
context
.
Context
,
stream
uint64
,
msg
string
)
error
{
// XXX err ctx
// XXX assert '\n' not in msg
func
(
wlink
*
WatchLink
)
send
(
ctx
context
.
Context
,
stream
uint64
,
msg
string
)
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"send .%d"
,
stream
)
// wlink is already put into ctx by caller
// assert '\n' not in msg
if
strings
.
ContainsRune
(
msg
,
'\n'
)
{
panicf
(
"BUG: msg contains
\\
n ; msg: %q"
,
msg
)
}
wlink
.
txMu
.
Lock
()
defer
wlink
.
txMu
.
Unlock
()
pkt
:=
[]
byte
(
fmt
.
Sprintf
(
"%d %s
\n
"
,
stream
,
msg
))
traceIso
(
"S: wlink%d: tx: %q
\n
"
,
wlink
.
id
,
pkt
)
_
,
err
:
=
wlink
.
sk
.
Write
(
ctx
,
pkt
)
_
,
err
=
wlink
.
sk
.
Write
(
ctx
,
pkt
)
if
err
!=
nil
{
return
err
}
...
...
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