rpc/stream/vom: change to open vom.encorder first
This changes to open vom.encoder first before vom.decoder
so that we can save the wait time for a magic byte.
Change-Id: Ia72d5800a5b7590de3a6578ee4d2ea68f5df6c68
diff --git a/profiles/internal/rpc/server.go b/profiles/internal/rpc/server.go
index 0d5a11c..3516796 100644
--- a/profiles/internal/rpc/server.go
+++ b/profiles/internal/rpc/server.go
@@ -957,26 +957,26 @@
discharges: make(map[string]security.Discharge),
}
var err error
- typedec := flow.VCDataCache().Get(vc.TypeDecoderKey{})
- if typedec == nil {
- if fs.dec, err = vom.NewDecoder(flow); err != nil {
- flow.Close()
- return nil, err
- }
+ typeenc := flow.VCDataCache().Get(vc.TypeEncoderKey{})
+ if typeenc == nil {
if fs.enc, err = vom.NewEncoder(flow); err != nil {
flow.Close()
return nil, err
}
- } else {
- if fs.dec, err = vom.NewDecoderWithTypeDecoder(flow, typedec.(*vom.TypeDecoder)); err != nil {
+ if fs.dec, err = vom.NewDecoder(flow); err != nil {
flow.Close()
return nil, err
}
- typeenc := flow.VCDataCache().Get(vc.TypeEncoderKey{})
+ } else {
if fs.enc, err = vom.NewEncoderWithTypeEncoder(flow, typeenc.(*vom.TypeEncoder)); err != nil {
flow.Close()
return nil, err
}
+ typedec := flow.VCDataCache().Get(vc.TypeDecoderKey{})
+ if fs.dec, err = vom.NewDecoderWithTypeDecoder(flow, typedec.(*vom.TypeDecoder)); err != nil {
+ flow.Close()
+ return nil, err
+ }
}
return fs, nil
}