Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
81de9fb6
Commit
81de9fb6
authored
Aug 10, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the message shrinking API less confusing.
parent
9a7512aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
conversions.go
conversions.go
+3
-3
internal/buffer/out_message.go
internal/buffer/out_message.go
+6
-5
No files found.
conversions.go
View file @
81de9fb6
...
...
@@ -448,7 +448,7 @@ func (c *Connection) kernelResponse(
// the header, because on OS X the kernel otherwise returns EINVAL when we
// attempt to write an error response with a length that extends beyond the
// header.
m
.
Shrink
(
uintptr
(
m
.
Len
()
-
int
(
buffer
.
OutMessageInitialSize
))
)
m
.
Shrink
To
(
buffer
.
OutMessageInitialSize
)
}
// Otherwise, fill in the rest of the response.
...
...
@@ -522,7 +522,7 @@ func (c *Connection) kernelResponseForOp(
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m
.
Shrink
(
uintptr
(
m
.
Len
()
-
(
int
(
buffer
.
OutMessageInitialSize
)
+
o
.
BytesRead
)
))
m
.
Shrink
To
(
buffer
.
OutMessageInitialSize
+
uintptr
(
o
.
BytesRead
))
case
*
fuseops
.
ReleaseDirHandleOp
:
// Empty response
...
...
@@ -539,7 +539,7 @@ func (c *Connection) kernelResponseForOp(
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m
.
Shrink
(
uintptr
(
m
.
Len
()
-
(
int
(
buffer
.
OutMessageInitialSize
)
+
o
.
BytesRead
)
))
m
.
Shrink
To
(
buffer
.
OutMessageInitialSize
+
uintptr
(
o
.
BytesRead
))
case
*
fuseops
.
WriteFileOp
:
out
:=
(
*
fusekernel
.
WriteOut
)(
m
.
Grow
(
unsafe
.
Sizeof
(
fusekernel
.
WriteOut
{})))
...
...
internal/buffer/out_message.go
View file @
81de9fb6
...
...
@@ -90,13 +90,14 @@ func (b *OutMessage) GrowNoZero(size uintptr) (p unsafe.Pointer) {
return
}
// Throw away the last n bytes. Panics if n is out of range.
func
(
b
*
OutMessage
)
Shrink
(
n
uintptr
)
{
if
n
>
b
.
offset
-
OutMessageInitialSize
{
panic
(
fmt
.
Sprintf
(
"Shrink(%d) out of range for offset %d"
,
n
,
b
.
offset
))
// Shrink to the supplied size. Panic if the size is greater than Len() or less
// than OutMessageInitialSize.
func
(
b
*
OutMessage
)
ShrinkTo
(
n
uintptr
)
{
if
n
<
OutMessageInitialSize
||
n
>
b
.
offset
{
panic
(
fmt
.
Sprintf
(
"ShrinkTo(%d) out of range for offset %d"
,
n
,
b
.
offset
))
}
b
.
offset
-
=
n
b
.
offset
=
n
}
// Equivalent to growing by the length of p, then copying p over the new
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment