Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
51464b43
Commit
51464b43
authored
Dec 14, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/nfs/Connection: add assertions
parent
2fec4635
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
Connection.cxx
src/lib/nfs/Connection.cxx
+31
-0
No files found.
src/lib/nfs/Connection.cxx
View file @
51464b43
...
@@ -39,6 +39,8 @@ NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
...
@@ -39,6 +39,8 @@ NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
const
char
*
path
,
const
char
*
path
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
int
result
=
nfs_stat_async
(
ctx
,
path
,
Callback
,
this
);
int
result
=
nfs_stat_async
(
ctx
,
path
,
Callback
,
this
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
error
.
Format
(
nfs_domain
,
"nfs_stat_async() failed: %s"
,
error
.
Format
(
nfs_domain
,
"nfs_stat_async() failed: %s"
,
...
@@ -54,6 +56,8 @@ NfsConnection::CancellableCallback::OpenDirectory(nfs_context *ctx,
...
@@ -54,6 +56,8 @@ NfsConnection::CancellableCallback::OpenDirectory(nfs_context *ctx,
const
char
*
path
,
const
char
*
path
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
int
result
=
nfs_opendir_async
(
ctx
,
path
,
Callback
,
this
);
int
result
=
nfs_opendir_async
(
ctx
,
path
,
Callback
,
this
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
error
.
Format
(
nfs_domain
,
"nfs_opendir_async() failed: %s"
,
error
.
Format
(
nfs_domain
,
"nfs_opendir_async() failed: %s"
,
...
@@ -69,6 +73,8 @@ NfsConnection::CancellableCallback::Open(nfs_context *ctx,
...
@@ -69,6 +73,8 @@ NfsConnection::CancellableCallback::Open(nfs_context *ctx,
const
char
*
path
,
int
flags
,
const
char
*
path
,
int
flags
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
int
result
=
nfs_open_async
(
ctx
,
path
,
flags
,
int
result
=
nfs_open_async
(
ctx
,
path
,
flags
,
Callback
,
this
);
Callback
,
this
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
...
@@ -85,6 +91,8 @@ NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
...
@@ -85,6 +91,8 @@ NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
struct
nfsfh
*
fh
,
struct
nfsfh
*
fh
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
int
result
=
nfs_fstat_async
(
ctx
,
fh
,
Callback
,
this
);
int
result
=
nfs_fstat_async
(
ctx
,
fh
,
Callback
,
this
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
error
.
Format
(
nfs_domain
,
"nfs_fstat_async() failed: %s"
,
error
.
Format
(
nfs_domain
,
"nfs_fstat_async() failed: %s"
,
...
@@ -100,6 +108,8 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
...
@@ -100,6 +108,8 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
uint64_t
offset
,
size_t
size
,
uint64_t
offset
,
size_t
size
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
int
result
=
nfs_pread_async
(
ctx
,
fh
,
offset
,
size
,
Callback
,
this
);
int
result
=
nfs_pread_async
(
ctx
,
fh
,
offset
,
size
,
Callback
,
this
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
error
.
Format
(
nfs_domain
,
"nfs_pread_async() failed: %s"
,
error
.
Format
(
nfs_domain
,
"nfs_pread_async() failed: %s"
,
...
@@ -113,6 +123,7 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
...
@@ -113,6 +123,7 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
inline
void
inline
void
NfsConnection
::
CancellableCallback
::
CancelAndScheduleClose
(
struct
nfsfh
*
fh
)
NfsConnection
::
CancellableCallback
::
CancelAndScheduleClose
(
struct
nfsfh
*
fh
)
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
assert
(
!
open
);
assert
(
!
open
);
assert
(
close_fh
==
nullptr
);
assert
(
close_fh
==
nullptr
);
assert
(
fh
!=
nullptr
);
assert
(
fh
!=
nullptr
);
...
@@ -124,6 +135,8 @@ NfsConnection::CancellableCallback::CancelAndScheduleClose(struct nfsfh *fh)
...
@@ -124,6 +135,8 @@ NfsConnection::CancellableCallback::CancelAndScheduleClose(struct nfsfh *fh)
inline
void
inline
void
NfsConnection
::
CancellableCallback
::
Callback
(
int
err
,
void
*
data
)
NfsConnection
::
CancellableCallback
::
Callback
(
int
err
,
void
*
data
)
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
if
(
!
IsCancelled
())
{
if
(
!
IsCancelled
())
{
assert
(
close_fh
==
nullptr
);
assert
(
close_fh
==
nullptr
);
...
@@ -209,6 +222,7 @@ NfsConnection::RemoveLease(NfsLease &lease)
...
@@ -209,6 +222,7 @@ NfsConnection::RemoveLease(NfsLease &lease)
bool
bool
NfsConnection
::
Stat
(
const
char
*
path
,
NfsCallback
&
callback
,
Error
&
error
)
NfsConnection
::
Stat
(
const
char
*
path
,
NfsCallback
&
callback
,
Error
&
error
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
!
callbacks
.
Contains
(
callback
));
assert
(
!
callbacks
.
Contains
(
callback
));
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
false
);
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
false
);
...
@@ -225,6 +239,7 @@ bool
...
@@ -225,6 +239,7 @@ bool
NfsConnection
::
OpenDirectory
(
const
char
*
path
,
NfsCallback
&
callback
,
NfsConnection
::
OpenDirectory
(
const
char
*
path
,
NfsCallback
&
callback
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
!
callbacks
.
Contains
(
callback
));
assert
(
!
callbacks
.
Contains
(
callback
));
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
true
);
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
true
);
...
@@ -240,12 +255,16 @@ NfsConnection::OpenDirectory(const char *path, NfsCallback &callback,
...
@@ -240,12 +255,16 @@ NfsConnection::OpenDirectory(const char *path, NfsCallback &callback,
const
struct
nfsdirent
*
const
struct
nfsdirent
*
NfsConnection
::
ReadDirectory
(
struct
nfsdir
*
dir
)
NfsConnection
::
ReadDirectory
(
struct
nfsdir
*
dir
)
{
{
assert
(
GetEventLoop
().
IsInside
());
return
nfs_readdir
(
context
,
dir
);
return
nfs_readdir
(
context
,
dir
);
}
}
void
void
NfsConnection
::
CloseDirectory
(
struct
nfsdir
*
dir
)
NfsConnection
::
CloseDirectory
(
struct
nfsdir
*
dir
)
{
{
assert
(
GetEventLoop
().
IsInside
());
return
nfs_closedir
(
context
,
dir
);
return
nfs_closedir
(
context
,
dir
);
}
}
...
@@ -253,6 +272,7 @@ bool
...
@@ -253,6 +272,7 @@ bool
NfsConnection
::
Open
(
const
char
*
path
,
int
flags
,
NfsCallback
&
callback
,
NfsConnection
::
Open
(
const
char
*
path
,
int
flags
,
NfsCallback
&
callback
,
Error
&
error
)
Error
&
error
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
!
callbacks
.
Contains
(
callback
));
assert
(
!
callbacks
.
Contains
(
callback
));
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
true
);
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
true
);
...
@@ -268,6 +288,7 @@ NfsConnection::Open(const char *path, int flags, NfsCallback &callback,
...
@@ -268,6 +288,7 @@ NfsConnection::Open(const char *path, int flags, NfsCallback &callback,
bool
bool
NfsConnection
::
Stat
(
struct
nfsfh
*
fh
,
NfsCallback
&
callback
,
Error
&
error
)
NfsConnection
::
Stat
(
struct
nfsfh
*
fh
,
NfsCallback
&
callback
,
Error
&
error
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
!
callbacks
.
Contains
(
callback
));
assert
(
!
callbacks
.
Contains
(
callback
));
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
false
);
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
false
);
...
@@ -284,6 +305,7 @@ bool
...
@@ -284,6 +305,7 @@ bool
NfsConnection
::
Read
(
struct
nfsfh
*
fh
,
uint64_t
offset
,
size_t
size
,
NfsConnection
::
Read
(
struct
nfsfh
*
fh
,
uint64_t
offset
,
size_t
size
,
NfsCallback
&
callback
,
Error
&
error
)
NfsCallback
&
callback
,
Error
&
error
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
!
callbacks
.
Contains
(
callback
));
assert
(
!
callbacks
.
Contains
(
callback
));
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
false
);
auto
&
c
=
callbacks
.
Add
(
callback
,
*
this
,
false
);
...
@@ -310,6 +332,8 @@ DummyCallback(int, struct nfs_context *, void *, void *)
...
@@ -310,6 +332,8 @@ DummyCallback(int, struct nfs_context *, void *, void *)
void
void
NfsConnection
::
Close
(
struct
nfsfh
*
fh
)
NfsConnection
::
Close
(
struct
nfsfh
*
fh
)
{
{
assert
(
GetEventLoop
().
IsInside
());
nfs_close_async
(
context
,
fh
,
DummyCallback
,
nullptr
);
nfs_close_async
(
context
,
fh
,
DummyCallback
,
nullptr
);
ScheduleSocket
();
ScheduleSocket
();
}
}
...
@@ -341,6 +365,7 @@ NfsConnection::DestroyContext()
...
@@ -341,6 +365,7 @@ NfsConnection::DestroyContext()
inline
void
inline
void
NfsConnection
::
DeferClose
(
struct
nfsfh
*
fh
)
NfsConnection
::
DeferClose
(
struct
nfsfh
*
fh
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
in_event
);
assert
(
in_event
);
assert
(
in_service
);
assert
(
in_service
);
...
@@ -350,6 +375,7 @@ NfsConnection::DeferClose(struct nfsfh *fh)
...
@@ -350,6 +375,7 @@ NfsConnection::DeferClose(struct nfsfh *fh)
void
void
NfsConnection
::
ScheduleSocket
()
NfsConnection
::
ScheduleSocket
()
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
!=
nullptr
);
assert
(
context
!=
nullptr
);
if
(
!
SocketMonitor
::
IsDefined
())
{
if
(
!
SocketMonitor
::
IsDefined
())
{
...
@@ -367,6 +393,7 @@ NfsConnection::ScheduleSocket()
...
@@ -367,6 +393,7 @@ NfsConnection::ScheduleSocket()
bool
bool
NfsConnection
::
OnSocketReady
(
unsigned
flags
)
NfsConnection
::
OnSocketReady
(
unsigned
flags
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
deferred_close
.
empty
());
assert
(
deferred_close
.
empty
());
bool
closed
=
false
;
bool
closed
=
false
;
...
@@ -444,6 +471,7 @@ inline void
...
@@ -444,6 +471,7 @@ inline void
NfsConnection
::
MountCallback
(
int
status
,
gcc_unused
nfs_context
*
nfs
,
NfsConnection
::
MountCallback
(
int
status
,
gcc_unused
nfs_context
*
nfs
,
gcc_unused
void
*
data
)
gcc_unused
void
*
data
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
==
nfs
);
assert
(
context
==
nfs
);
mount_finished
=
true
;
mount_finished
=
true
;
...
@@ -468,6 +496,7 @@ NfsConnection::MountCallback(int status, nfs_context *nfs, void *data,
...
@@ -468,6 +496,7 @@ NfsConnection::MountCallback(int status, nfs_context *nfs, void *data,
inline
bool
inline
bool
NfsConnection
::
MountInternal
(
Error
&
error
)
NfsConnection
::
MountInternal
(
Error
&
error
)
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
==
nullptr
);
assert
(
context
==
nullptr
);
context
=
nfs_init_context
();
context
=
nfs_init_context
();
...
@@ -538,6 +567,8 @@ NfsConnection::BroadcastError(Error &&error)
...
@@ -538,6 +567,8 @@ NfsConnection::BroadcastError(Error &&error)
void
void
NfsConnection
::
RunDeferred
()
NfsConnection
::
RunDeferred
()
{
{
assert
(
GetEventLoop
().
IsInside
());
if
(
context
==
nullptr
)
{
if
(
context
==
nullptr
)
{
Error
error
;
Error
error
;
if
(
!
MountInternal
(
error
))
{
if
(
!
MountInternal
(
error
))
{
...
...
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