Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

srt publish core dump bug #2429

Merged
merged 5 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion trunk/src/srt/srt_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SRT_DATA_MSG::SRT_DATA_MSG(unsigned char* data_p, unsigned int len, const std::s

SRT_DATA_MSG::~SRT_DATA_MSG() {
if (_data_p && (_len > 0)) {
delete _data_p;
delete[] _data_p;
}
}

Expand Down
7 changes: 7 additions & 0 deletions trunk/src/srt/srt_to_rtmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,14 @@ srs_error_t rtmp_client::connect() {
_rtmp_conn_ptr = std::make_shared<SrsSimpleRtmpClient>(_url, cto, sto);

if ((err = _rtmp_conn_ptr->connect()) != srs_success) {
srs_error("rtmp client in srt2rtmp connect fail url:%s", _url.c_str());
Copy link
Member

@winlinvip winlinvip Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this print statement for debugging purposes? It might be better to print it in the outer layer, because here err is returned, and there might be duplicate logging outside as well.

If you need the information of _url, it is already included when wrapping err.

TRANS_BY_GPT3

close();
return srs_error_wrap(err, "connect %s failed, cto=%dms, sto=%dms.",
_url.c_str(), srsu2msi(cto), srsu2msi(sto));
}

if ((err = _rtmp_conn_ptr->publish(SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE)) != srs_success) {
srs_error("rtmp client in srt2rtmp publish fail url:%s", _url.c_str());
close();
return srs_error_wrap(err, "publish error, url:%s", _url.c_str());
}
Expand Down Expand Up @@ -406,13 +408,18 @@ srs_error_t rtmp_client::rtmp_write_packet(char type, uint32_t timestamp, char*
srs_error_t err = srs_success;
SrsSharedPtrMessage* msg = NULL;

if (!_rtmp_conn_ptr) {
return srs_error_wrap(err, "rtmp connection is close");
Copy link
Member

@winlinvip winlinvip Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this time, when err is success, wrap(success) will cause the code outside to be success, which is incorrect.

Here, the error should be created using srs_error_new.

TRANS_BY_GPT3

}

if ((err = srs_rtmp_create_msg(type, timestamp, data, size, _rtmp_conn_ptr->sid(), &msg)) != srs_success) {
return srs_error_wrap(err, "create message");
}
srs_assert(msg);

// send out encoded msg.
if ((err = _rtmp_conn_ptr->send_and_free_message(msg)) != srs_success) {
srs_error("rtmp client in srt2rtmp send message fail, url:%s", _url.c_str());
close();
return srs_error_wrap(err, "send messages");
}
Expand Down