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
947bc0f2
Commit
947bc0f2
authored
1 year ago
by
Sébastien Blin
Committed by
Adrien Béraud
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
sync_module: reserve unpacker buffer
Change-Id: I80aebbc7cfe97b257571a13a07eff00dab0b2a2c
parent
36c29555
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/sync_module.cpp
+25
-11
25 additions, 11 deletions
src/jamidht/sync_module.cpp
with
25 additions
and
11 deletions
src/jamidht/sync_module.cpp
+
25
−
11
View file @
947bc0f2
...
...
@@ -173,26 +173,40 @@ SyncModule::cacheSyncConnection(std::shared_ptr<dhtnet::ChannelSocket>&& socket,
}
});
socket
->
setOnRecv
([
acc
=
pimpl_
->
account_
.
lock
(),
device
,
peerId
](
const
uint8_t
*
buf
,
size_t
len
)
{
struct
DecodingContext
{
msgpack
::
unpacker
pac
{[](
msgpack
::
type
::
object_type
,
std
::
size_t
,
void
*
)
{
return
true
;
},
nullptr
,
512
};
};
socket
->
setOnRecv
([
acc
=
pimpl_
->
account_
.
lock
(),
device
,
peerId
,
ctx
=
std
::
make_shared
<
DecodingContext
>
()
](
const
uint8_t
*
buf
,
size_t
len
)
{
if
(
!
buf
||
!
acc
)
return
len
;
ctx
->
pac
.
reserve_buffer
(
len
);
std
::
copy_n
(
buf
,
len
,
ctx
->
pac
.
buffer
());
ctx
->
pac
.
buffer_consumed
(
len
);
msgpack
::
object_handle
oh
;
SyncMsg
msg
;
try
{
msgpack
::
unpacked
result
;
msgpack
::
object_handle
oh
=
msgpack
::
unpack
(
reinterpret_cast
<
const
char
*>
(
buf
),
len
);
oh
.
get
().
convert
(
msg
);
while
(
ctx
->
pac
.
next
(
oh
))
{
oh
.
get
().
convert
(
msg
);
if
(
auto
manager
=
acc
->
accountManager
())
manager
->
onSyncData
(
std
::
move
(
msg
.
ds
),
false
);
if
(
!
msg
.
c
.
empty
()
||
!
msg
.
cr
.
empty
()
||
!
msg
.
p
.
empty
()
||
!
msg
.
ld
.
empty
())
acc
->
convModule
()
->
onSyncData
(
msg
,
peerId
,
device
.
toString
());
}
}
catch
(
const
std
::
exception
&
e
)
{
JAMI_WARNING
(
"[convInfo] error on sync: {:s}"
,
e
.
what
());
return
len
;
}
if
(
auto
manager
=
acc
->
accountManager
())
manager
->
onSyncData
(
std
::
move
(
msg
.
ds
),
false
);
if
(
!
msg
.
c
.
empty
()
||
!
msg
.
cr
.
empty
()
||
!
msg
.
p
.
empty
()
||
!
msg
.
ld
.
empty
())
acc
->
convModule
()
->
onSyncData
(
msg
,
peerId
,
device
.
toString
());
return
len
;
});
}
...
...
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