-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
SmartPtr: Use shared ptr in RTC TCP connection. v6.0.127 #4083
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix compiling error, when rtc is off.
./configure -rtc=off; make
f414449
to
f3fda03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wild pointer problem of SrsRtcTcpConn
instance in conn_manager
, the tcp connection resource manager.
@@ -1227,11 +1226,26 @@ srs_error_t SrsServer::do_on_tcp_client(ISrsListener* listener, srs_netfd_t& stf | |||
} | |||
} | |||
|
|||
// For RTC TCP connection, use resource executor to manage the resource. | |||
SrsRtcTcpConn* raw_conn = dynamic_cast<SrsRtcTcpConn*>(resource); | |||
if (raw_conn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful the raw_conn (SrsRtcTcpConn resource)
and its conn (SrsSharedResource wrapper)
, the raw_conn
will be add to conn_manager
, the tcp connection resource manager of SrsServer
, in line 1244, and its wrapper, a SrsSharedResource, will created below in line 1233, this wrapper didn't added to any resource manager, but it will be released by _srs_rtc_manager
in SrsExecutorCoroutine
's destructor. Then the raw_conn
stored in conn_manager
will became a wild pointer, the good news is that the conn_manager
will never remove it, so the process will never crash, but it's still a problem, is it?
So, there are two problem:
- the
raw_conn
will be added toconn_manager
, which will never remove it; - the
raw_conn
insideconn_manager
will became wild pointer once its wapper, theSrsSharedResource
released by_srs_rtc_manager
insideSrsExecutorCoroutine
's desctructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nop, manager never adds raw_conn:
// For RTC TCP connection, use resource executor to manage the resource.
SrsRtcTcpConn* raw_conn = dynamic_cast<SrsRtcTcpConn*>(resource);
if (raw_conn) {
// ......
return err;
}
Won't fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it.
@@ -436,19 +436,19 @@ srs_error_t SrsRtcUdpNetwork::write(void* buf, size_t size, ssize_t* nwrite) | |||
return sendonly_skt_->sendto(buf, size, SRS_UTIME_NO_TIMEOUT); | |||
} | |||
|
|||
SrsRtcTcpNetwork::SrsRtcTcpNetwork(SrsRtcConnection* conn, SrsEphemeralDelta* delta) | |||
SrsRtcTcpNetwork::SrsRtcTcpNetwork(SrsRtcConnection* conn, SrsEphemeralDelta* delta) : owner_(new SrsRtcTcpConn()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current branch seems rebased on the #4084 now, which already supported constructor the SrsSharedResource
instance from a NULL pointer, so I guess this initialization can be improved by:
SrsRtcTcpNetwork::SrsRtcTcpNetwork(SrsRtcConnection* conn, SrsEphemeralDelta* delta) : owner_(new SrsRtcTcpConn()) | |
SrsRtcTcpNetwork::SrsRtcTcpNetwork(SrsRtcConnection* conn, SrsEphemeralDelta* delta) : owner_(NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, reconsider this suggestion and let SrsSharedResource
accept NULL pointer constructor, because
srs/trunk/src/app/srs_app_conn.hpp
Lines 163 to 165 in 7b9c52b
T* operator->() { | |
return ptr_.operator->(); | |
} |
in this case, it's owner_->interrupt()
.
Fix issue #3784