Better explain what 1<<22-24 means for packet length

This commit is contained in:
Yuriy Taraday 2018-05-05 22:27:31 +04:00
parent 8965adaafb
commit b27200c99b
2 changed files with 26 additions and 1 deletions

3
rpc.go
View File

@ -364,7 +364,8 @@ func (l *Libvirt) requestStream(proc uint32, program uint32, payload []byte, out
}
func (l *Libvirt) sendStream(serial uint32, proc uint32, program uint32, stream io.Reader, abort chan bool) error {
buf := make([]byte, 1<<22-24)
// Keep total packet length under 4 MiB to follow possible limitation in libvirt server code
buf := make([]byte, 4*MiB-constants.HeaderSize)
for {
select {
case <-abort:

24
units.go Normal file
View File

@ -0,0 +1,24 @@
// Copyright 2016 The go-libvirt Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This module provides different units of measurement to make other
// code more readable.
package libvirt
const (
B = 1
KiB = 1024 * B
MiB = 1024 * KiB
)