Commit 5edeec62 authored by Peter-Jan Brone's avatar Peter-Jan Brone

Merge branch 'read-cancellation-token' of https://gitlab.com/NebulousLabs/Sia into pt-duration

parents f13a84d7 bd920e93
Pipeline #152315905 failed with stages
in 30 minutes and 34 seconds
......@@ -445,7 +445,7 @@ func (p *renterHostPair) managedExecuteProgram(epr modules.RPCExecuteProgramRequ
// Read the cancellation token.
ct := make([]byte, modules.MDMCancellationTokenLen)
_, err = io.ReadFull(stream, ct)
err = modules.RPCRead(stream, &ct)
if err != nil {
return nil, limit, err
}
......
......@@ -109,12 +109,8 @@ func (h *Host) managedRPCExecuteProgram(stream siamux.Stream) error {
}
// Return 16 bytes of data as a placeholder for a future cancellation token.
// NOTE: We write this to a buffer to save one call to `Write`. In the
// future we might reconsider this once we actually implement cancellation
// since this means the token is only returned after the first instruction
// is done executing.
buffer := bytes.NewBuffer(nil)
_, err = buffer.Write(make([]byte, modules.MDMCancellationTokenLen))
token := make([]byte, modules.MDMCancellationTokenLen)
err = modules.RPCWrite(stream, token)
if err != nil {
return errors.AddContext(err, "Failed to write cancellation token")
}
......@@ -159,6 +155,9 @@ func (h *Host) managedRPCExecuteProgram(stream siamux.Stream) error {
// Remember that the execution wasn't successful.
executionFailed = output.Error != nil
// Create a buffer
buffer := bytes.NewBuffer(nil)
// Send the response to the peer.
err = modules.RPCWrite(buffer, resp)
if err != nil {
......
......@@ -86,7 +86,7 @@ func (w *worker) managedExecuteProgram(p modules.Program, data []byte, fcid type
// read the cancellation token.
ct := make([]byte, modules.MDMCancellationTokenLen)
_, err = io.ReadFull(stream, ct)
err = modules.RPCRead(stream, &ct)
if err != nil {
return
}
......
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