mirror of
https://github.com/containers/podman
synced 2024-10-20 17:23:30 +00:00
Fix the varlink upgraded calls
Although an upgraded call is requested, the server has to send at least one reply (can be an error) and the client has to check the reply, before assuming an upgraded connection. Signed-off-by: Harald Hoyer <harald@redhat.com>
This commit is contained in:
parent
8649dbdc11
commit
90ae7206f3
|
@ -583,7 +583,15 @@ func (r *LocalRuntime) attach(ctx context.Context, stdin, stdout *os.File, cid s
|
|||
|
||||
}
|
||||
// TODO add detach keys support
|
||||
_, err = iopodman.Attach().Send(r.Conn, varlink.Upgrade, cid, detachKeys, start)
|
||||
reply, err := iopodman.Attach().Send(r.Conn, varlink.Upgrade, cid, detachKeys, start)
|
||||
if err != nil {
|
||||
restoreTerminal(oldTermState)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// See if the server accepts the upgraded connection or returns an error
|
||||
_, err = reply()
|
||||
|
||||
if err != nil {
|
||||
restoreTerminal(oldTermState)
|
||||
return nil, err
|
||||
|
|
|
@ -60,7 +60,10 @@ func (i *LibpodAPI) Attach(call iopodman.VarlinkCall, name string, detachKeys st
|
|||
if !start && state != libpod.ContainerStateRunning {
|
||||
return call.ReplyErrorOccurred("container must be running to attach")
|
||||
}
|
||||
call.Reply(nil)
|
||||
|
||||
// ACK the client upgrade request
|
||||
call.ReplyAttach()
|
||||
|
||||
reader, writer, _, pw, streams := setupStreams(call)
|
||||
|
||||
go func() {
|
||||
|
|
|
@ -29,6 +29,12 @@ func (i *LibpodAPI) SendFile(call iopodman.VarlinkCall, ftype string, length int
|
|||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
||||
// FIXME return parameter
|
||||
if err = call.ReplySendFile("FIXME_file_handle"); err != nil {
|
||||
// If an error occurs while sending the reply, return the error
|
||||
return err
|
||||
}
|
||||
|
||||
writer := bufio.NewWriter(outputFile)
|
||||
defer writer.Flush()
|
||||
|
||||
|
@ -60,9 +66,10 @@ func (i *LibpodAPI) ReceiveFile(call iopodman.VarlinkCall, filepath string, dele
|
|||
}
|
||||
|
||||
// Send the file length down to client
|
||||
// Varlink connection upraded
|
||||
// Varlink connection upgraded
|
||||
if err = call.ReplyReceiveFile(fileInfo.Size()); err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
// If an error occurs while sending the reply, return the error
|
||||
return err
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(fs)
|
||||
|
|
Loading…
Reference in a new issue