mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #307, fix some memory leaking
This commit is contained in:
parent
a8cc3a3430
commit
32d5b75d8c
2 changed files with 8 additions and 14 deletions
|
@ -1081,7 +1081,9 @@ SrsRtcServer::~SrsRtcServer()
|
||||||
|
|
||||||
srs_freep(trd);
|
srs_freep(trd);
|
||||||
srs_cond_destroy(cond);
|
srs_cond_destroy(cond);
|
||||||
clear();
|
|
||||||
|
free_messages(mmhdrs);
|
||||||
|
mmhdrs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcServer::initialize()
|
srs_error_t SrsRtcServer::initialize()
|
||||||
|
@ -1335,10 +1337,10 @@ srs_error_t SrsRtcServer::send_and_free_messages(srs_netfd_t stfd, const vector<
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcServer::clear()
|
void SrsRtcServer::free_messages(vector<mmsghdr>& hdrs)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < (int)mmhdrs.size(); i++) {
|
for (int i = 0; i < (int)hdrs.size(); i++) {
|
||||||
msghdr* hdr = &mmhdrs[i].msg_hdr;
|
msghdr* hdr = &hdrs[i].msg_hdr;
|
||||||
for (int j = (int)hdr->msg_iovlen - 1; j >= 0 ; j--) {
|
for (int j = (int)hdr->msg_iovlen - 1; j >= 0 ; j--) {
|
||||||
iovec* iov = hdr->msg_iov + j;
|
iovec* iov = hdr->msg_iov + j;
|
||||||
char* data = (char*)iov->iov_base;
|
char* data = (char*)iov->iov_base;
|
||||||
|
@ -1346,8 +1348,6 @@ void SrsRtcServer::clear()
|
||||||
srs_freep(iov);
|
srs_freep(iov);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mmhdrs.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcServer::cycle()
|
srs_error_t SrsRtcServer::cycle()
|
||||||
|
@ -1396,13 +1396,7 @@ srs_error_t SrsRtcServer::cycle()
|
||||||
srs_trace("-> RTC SEND %d msgs, by sendmmsg %d", mhdrs.size(), max_sendmmsg);
|
srs_trace("-> RTC SEND %d msgs, by sendmmsg %d", mhdrs.size(), max_sendmmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (int)mhdrs.size(); i++) {
|
free_messages(mhdrs);
|
||||||
msghdr* hdr = &mhdrs[i].msg_hdr;
|
|
||||||
for (int i = 0; i < (int)hdr->msg_iovlen; i++) {
|
|
||||||
iovec* iov = hdr->msg_iov + i;
|
|
||||||
delete (char*)iov->iov_base;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -256,7 +256,7 @@ public:
|
||||||
// Internal only.
|
// Internal only.
|
||||||
public:
|
public:
|
||||||
srs_error_t send_and_free_messages(srs_netfd_t stfd, const std::vector<mmsghdr>& msgs);
|
srs_error_t send_and_free_messages(srs_netfd_t stfd, const std::vector<mmsghdr>& msgs);
|
||||||
void clear();
|
void free_messages(std::vector<mmsghdr>& hdrs);
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue