Commit 5c41d82a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2493c259
...@@ -181,6 +181,8 @@ ...@@ -181,6 +181,8 @@
// files to @<revX>/bigfile/<bigfileX> drops to zero, and automatically // files to @<revX>/bigfile/<bigfileX> drops to zero, and automatically
// destroys @<revX>/bigfile/<bigfileX> after reasonable timeout. // destroys @<revX>/bigfile/<bigfileX> after reasonable timeout.
// //
// XXX document "bye"
//
// //
// Protection against slow or faulty clients // Protection against slow or faulty clients
// //
...@@ -1883,7 +1885,7 @@ func (wlink *WatchLink) _serve() (err error) { ...@@ -1883,7 +1885,7 @@ func (wlink *WatchLink) _serve() (err error) {
// XXX recheck that it is safe to handle multiple simultaneous watch requests. // XXX recheck that it is safe to handle multiple simultaneous watch requests.
for { 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 { if err != nil {
// r.Read is woken up by sk.CloseRead when serve decides to exit // r.Read is woken up by sk.CloseRead when serve decides to exit
if err == io.ErrClosedPipe || err == io.EOF { if err == io.ErrClosedPipe || err == io.EOF {
...@@ -1957,7 +1959,8 @@ func (wlink *WatchLink) _handleWatch(ctx context.Context, msg string) error { ...@@ -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. // sendReq sends wcfs-originated request to client and returns client response.
func (wlink *WatchLink) sendReq(ctx context.Context, req string) (reply string, err error) { 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 var stream uint64
for stream == 0 { for stream == 0 {
stream = atomic.AddUint64(&wlink.reqNext, +2) stream = atomic.AddUint64(&wlink.reqNext, +2)
...@@ -1986,16 +1989,20 @@ func (wlink *WatchLink) sendReq(ctx context.Context, req string) (reply string, ...@@ -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. // send sends a message to client over specified stream ID.
// //
// Multiple send can be called simultaneously; send serializes writes. // Multiple send can be called simultaneously; send serializes writes.
func (wlink *WatchLink) send(ctx context.Context, stream uint64, msg string) error { func (wlink *WatchLink) send(ctx context.Context, stream uint64, msg string) (err error) {
// XXX err ctx defer xerr.Contextf(&err, "send .%d", stream) // wlink is already put into ctx by caller
// XXX assert '\n' not in msg
// assert '\n' not in msg
if strings.ContainsRune(msg, '\n') {
panicf("BUG: msg contains \\n ; msg: %q", msg)
}
wlink.txMu.Lock() wlink.txMu.Lock()
defer wlink.txMu.Unlock() defer wlink.txMu.Unlock()
pkt := []byte(fmt.Sprintf("%d %s\n", stream, msg)) pkt := []byte(fmt.Sprintf("%d %s\n", stream, msg))
traceIso("S: wlink%d: tx: %q\n", wlink.id, pkt) 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 { if err != nil {
return err return err
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment