From 3371ab70ac1596e043c3a9a4375c407964ef3e6f Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 28 Jul 2015 16:06:23 +1000 Subject: [PATCH] Redefined the contents of OutMessage. --- internal/buffer/out_message.go | 10 +++++++--- internal/buffer/out_message_darwin.go | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 internal/buffer/out_message_darwin.go diff --git a/internal/buffer/out_message.go b/internal/buffer/out_message.go index 0fe8ef4..2edbc8a 100644 --- a/internal/buffer/out_message.go +++ b/internal/buffer/out_message.go @@ -21,14 +21,18 @@ import ( "github.com/jacobsa/fuse/internal/fusekernel" ) +// We size out messages to be large enough to hold a header for the response +// plus the largest read that may come in. +const outMessageSize = unsafe.Sizeof(fusekernel.OutHeader{}) + MaxReadSize + // OutMessage provides a mechanism for constructing a single contiguous fuse // message from multiple segments, where the first segment is always a // fusekernel.OutHeader message. // -// Must be created with NewOutMessage. Exception: the zero value has -// Bytes() == nil. +// Must be initialized with Reset. type OutMessage struct { - slice []byte + offset uintptr + storage [outMessageSize]byte } // Create a new buffer whose initial contents are a zeroed fusekernel.OutHeader diff --git a/internal/buffer/out_message_darwin.go b/internal/buffer/out_message_darwin.go new file mode 100644 index 0000000..cf42466 --- /dev/null +++ b/internal/buffer/out_message_darwin.go @@ -0,0 +1,21 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// 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. + +package buffer + +// The maximum read size that we expect to ever see from the kernel, used for +// calculating the size of out messages. +// +// Experimentally determined on OS X. +const MaxReadSize = 1 << 20