Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
9b3b9df3
Commit
9b3b9df3
authored
1 month ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
namedirectory: catch parsing errors
Change-Id: Ia92378315f88051de76311d23156c1eb85c07770
parent
f4993c88
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/jamidht/namedirectory.cpp
+18
-7
18 additions, 7 deletions
src/jamidht/namedirectory.cpp
with
18 additions
and
7 deletions
src/jamidht/namedirectory.cpp
+
18
−
7
View file @
9b3b9df3
...
...
@@ -476,6 +476,10 @@ NameDirectory::saveCache()
dhtnet
::
fileutils
::
recursive_mkdir
(
fileutils
::
get_cache_dir
()
/
CACHE_DIRECTORY
);
std
::
lock_guard
lock
(
dhtnet
::
fileutils
::
getFileLock
(
cachePath_
));
std
::
ofstream
file
(
cachePath_
,
std
::
ios
::
trunc
|
std
::
ios
::
binary
);
if
(
!
file
.
is_open
())
{
JAMI_ERROR
(
"Unable to save cache to {}"
,
cachePath_
);
return
;
}
{
std
::
lock_guard
l
(
cacheLock_
);
msgpack
::
pack
(
file
,
nameCache_
);
...
...
@@ -505,13 +509,20 @@ NameDirectory::loadCache()
}
}
// load values
std
::
lock_guard
l
(
cacheLock_
);
msgpack
::
object_handle
oh
;
if
(
pac
.
next
(
oh
))
oh
.
get
().
convert
(
nameCache_
);
for
(
const
auto
&
m
:
nameCache_
)
addrCache_
.
emplace
(
m
.
second
.
second
,
m
.
second
);
try
{
// load values
std
::
lock_guard
l
(
cacheLock_
);
msgpack
::
object_handle
oh
;
if
(
pac
.
next
(
oh
))
oh
.
get
().
convert
(
nameCache_
);
for
(
const
auto
&
m
:
nameCache_
)
addrCache_
.
emplace
(
m
.
second
.
second
,
m
.
second
);
}
catch
(
const
msgpack
::
parse_error
&
e
)
{
JAMI_ERROR
(
"Error when parsing msgpack object: {}"
,
e
.
what
());
}
catch
(
const
std
::
bad_cast
&
e
)
{
JAMI_ERROR
(
"Error when loading cache: {}"
,
e
.
what
());
}
JAMI_DEBUG
(
"Loaded {:d} name-address mappings"
,
nameCache_
.
size
());
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment