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
0becfa3d
Commit
0becfa3d
authored
Jul 28, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Began fixing Connection.
parent
c0e60edb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
23 deletions
+51
-23
connection.go
connection.go
+2
-1
conversions.go
conversions.go
+13
-17
freelists.go
freelists.go
+36
-5
No files found.
connection.go
View file @
0becfa3d
...
@@ -80,6 +80,7 @@ type Connection struct {
...
@@ -80,6 +80,7 @@ type Connection struct {
// Freelists, serviced by freelists.go.
// Freelists, serviced by freelists.go.
inMessages
freelist
.
Freelist
// GUARDED_BY(mu)
inMessages
freelist
.
Freelist
// GUARDED_BY(mu)
outMessages
freelist
.
Freelist
// GUARDED_BY(mu)
}
}
// State that is maintained for each in-flight op. This is stuffed into the
// State that is maintained for each in-flight op. This is stuffed into the
...
...
conversions.go
View file @
0becfa3d
...
@@ -387,35 +387,31 @@ func convertInMessage(
...
@@ -387,35 +387,31 @@ func convertInMessage(
// Outgoing messages
// Outgoing messages
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// Return the response that should be sent to the kernel
. If the op requires no
// Return the response that should be sent to the kernel
, or nil if the op
// re
sponse, return a nil
response.
// re
quires no
response.
func
kernelResponse
(
func
(
c
*
Connection
)
kernelResponse
(
fuseID
uint64
,
fuseID
uint64
,
op
interface
{},
op
interface
{},
opErr
error
,
opErr
error
)
(
m
*
buffer
.
OutMessage
)
{
protocol
fusekernel
.
Protocol
)
(
msg
[]
byte
)
{
// If the user replied with an error, create a response containing just the
// If the user replied with an error, create room enough just for the result
// result header with the error filled in. Otherwise create an appropriate
// header and fill it in with an error. Otherwise create an appropriate
// response.
// response.
var
b
buffer
.
OutMessage
if
opErr
!=
nil
{
if
opErr
!=
nil
{
b
=
buffer
.
NewOutMessage
(
0
)
m
=
c
.
getOutMessage
(
)
if
errno
,
ok
:=
opErr
.
(
syscall
.
Errno
);
ok
{
if
errno
,
ok
:=
opErr
.
(
syscall
.
Errno
);
ok
{
b
.
OutHeader
()
.
Error
=
-
int32
(
errno
)
m
.
OutHeader
()
.
Error
=
-
int32
(
errno
)
}
else
{
}
else
{
b
.
OutHeader
()
.
Error
=
-
int32
(
syscall
.
EIO
)
m
.
OutHeader
()
.
Error
=
-
int32
(
syscall
.
EIO
)
}
}
}
else
{
}
else
{
b
=
kernelResponseForOp
(
op
,
protocol
)
m
=
c
.
kernelResponseForOp
(
op
)
}
}
msg
=
b
.
Bytes
()
// Fill in the rest of the header, if a response is required.
// Fill in the rest of the header, if a response is required.
if
m
sg
!=
nil
{
if
m
!=
nil
{
h
:=
b
.
OutHeader
()
h
:=
m
.
OutHeader
()
h
.
Unique
=
fuseID
h
.
Unique
=
fuseID
h
.
Len
=
uint32
(
len
(
msg
))
h
.
Len
=
uint32
(
m
.
Len
(
))
}
}
return
return
...
...
freelists.go
View file @
0becfa3d
...
@@ -20,14 +20,20 @@ import (
...
@@ -20,14 +20,20 @@ import (
"github.com/jacobsa/fuse/internal/buffer"
"github.com/jacobsa/fuse/internal/buffer"
)
)
////////////////////////////////////////////////////////////////////////
// buffer.InMessage
////////////////////////////////////////////////////////////////////////
// LOCKS_EXCLUDED(c.mu)
// LOCKS_EXCLUDED(c.mu)
func
(
c
*
Connection
)
getInMessage
()
(
m
*
buffer
.
InMessage
)
{
func
(
c
*
Connection
)
getInMessage
()
(
x
*
buffer
.
InMessage
)
{
c
.
mu
.
Lock
()
c
.
mu
.
Lock
()
m
=
(
*
buffer
.
InMessage
)(
c
.
inMessages
.
Get
())
x
=
(
*
buffer
.
InMessage
)(
c
.
inMessages
.
Get
())
if
m
==
nil
{
m
=
new
(
buffer
.
InMessage
)
}
c
.
mu
.
Unlock
()
c
.
mu
.
Unlock
()
if
x
==
nil
{
x
=
new
(
buffer
.
InMessage
)
}
return
return
}
}
...
@@ -37,3 +43,28 @@ func (c *Connection) putInMessage(x *buffer.InMessage) {
...
@@ -37,3 +43,28 @@ func (c *Connection) putInMessage(x *buffer.InMessage) {
c
.
inMessages
.
Put
(
unsafe
.
Pointer
(
x
))
c
.
inMessages
.
Put
(
unsafe
.
Pointer
(
x
))
c
.
mu
.
Unlock
()
c
.
mu
.
Unlock
()
}
}
////////////////////////////////////////////////////////////////////////
// buffer.OutMessage
////////////////////////////////////////////////////////////////////////
// LOCKS_EXCLUDED(c.mu)
func
(
c
*
Connection
)
getOutMessage
()
(
x
*
buffer
.
OutMessage
)
{
c
.
mu
.
Lock
()
x
=
(
*
buffer
.
OutMessage
)(
c
.
outMessages
.
Get
())
c
.
mu
.
Unlock
()
if
x
==
nil
{
x
=
new
(
buffer
.
OutMessage
)
}
x
.
Reset
()
return
}
// LOCKS_EXCLUDED(c.mu)
func
(
c
*
Connection
)
putOutMessage
(
x
*
buffer
.
OutMessage
)
{
c
.
mu
.
Lock
()
c
.
outMessages
.
Put
(
unsafe
.
Pointer
(
x
))
c
.
mu
.
Unlock
()
}
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