Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
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
opendht
Commits
98cd6cc6
Commit
98cd6cc6
authored
6 years ago
by
Ming Rui Zhang
Browse files
Options
Downloads
Patches
Plain Diff
peerdiscovery: fix memory leakage cased by sbuffer release
parent
092cb955
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/peer_discovery.cpp
+4
-5
4 additions, 5 deletions
src/peer_discovery.cpp
with
4 additions
and
5 deletions
src/peer_discovery.cpp
+
4
−
5
View file @
98cd6cc6
...
...
@@ -162,7 +162,7 @@ PeerDiscovery::recvFrom(size_t &buf_size)
{
sockaddr_storage
storeage_recv
;
socklen_t
sa_len
=
sizeof
(
storeage_recv
);
char
*
recv
=
new
char
[
1024
];
char
recv
[
1024
];
ssize_t
nbytes
=
recvfrom
(
sockfd_
,
...
...
@@ -179,7 +179,6 @@ PeerDiscovery::recvFrom(size_t &buf_size)
rbuf_
.
write
(
recv
,
nbytes
);
buf_size
=
nbytes
;
SockAddr
ret
{
storeage_recv
,
sa_len
};
delete
[]
recv
;
return
ret
;
}
...
...
@@ -242,7 +241,7 @@ PeerDiscovery::listenerpack_thread()
callback
->
second
(
std
::
move
(
o
.
val
),
std
::
move
(
from
));
}
}
rbuf_
.
release
();
::
free
(
rbuf_
.
release
()
)
;
}
}
if
(
stop_readfd
!=
-
1
)
...
...
@@ -269,7 +268,7 @@ void PeerDiscovery::startPublish(const std::string &type, const msgpack::sbuffer
pack_buf_c
.
write
(
pack_buf
.
data
(),
pack_buf
.
size
());
std
::
unique_lock
<
std
::
mutex
>
lck
(
mtx_
);
sbuf_
.
release
();
::
free
(
sbuf_
.
release
()
)
;
messages_
[
type
]
=
std
::
move
(
pack_buf_c
);
msgpack
::
packer
<
msgpack
::
sbuffer
>
pk
(
&
sbuf_
);
pk
.
pack_map
(
messages_
.
size
());
...
...
@@ -318,7 +317,7 @@ PeerDiscovery::stopPublish(const std::string &type)
{
{
std
::
unique_lock
<
std
::
mutex
>
lck
(
mtx_
);
sbuf_
.
release
();
::
free
(
sbuf_
.
release
()
)
;
auto
it
=
messages_
.
find
(
type
);
if
(
it
!=
messages_
.
end
()){
messages_
.
erase
(
it
);
...
...
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