Bug 1054908 - Ensure socket_child_ is released on main thread. r=mt

This commit is contained in:
Shih-Chiang Chien 2014-08-18 19:14:00 -04:00
Родитель eb440bb46b
Коммит b2c0e8a827
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -1026,12 +1026,13 @@ void NrSocketIpc::create_m(const nsACString &host, const uint16_t port) {
ReentrantMonitorAutoEnter mon(monitor_);
nsresult rv;
socket_child_ = do_CreateInstance("@mozilla.org/udp-socket-child;1", &rv);
nsCOMPtr<nsIUDPSocketChild> socketChild = do_CreateInstance("@mozilla.org/udp-socket-child;1", &rv);
if (NS_FAILED(rv)) {
err_ = true;
MOZ_ASSERT(false, "Failed to create UDPSocketChild");
}
socket_child_ = new nsMainThreadPtrHolder<nsIUDPSocketChild>(socketChild);
socket_child_->SetFilterName(nsCString("stun"));
if (NS_FAILED(socket_child_->Bind(this, host, port))) {

Просмотреть файл

@ -58,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "nsXPCOM.h"
#include "nsIEventTarget.h"
#include "nsIUDPSocketChild.h"
#include "nsProxyRelease.h"
#include "databuffer.h"
#include "m_cpp_utils.h"
@ -233,7 +234,7 @@ private:
NrSocketIpcState state_;
std::queue<RefPtr<nr_udp_message> > received_msgs_;
nsCOMPtr<nsIUDPSocketChild> socket_child_;
nsMainThreadPtrHandle<nsIUDPSocketChild> socket_child_;
nsCOMPtr<nsIEventTarget> sts_thread_;
const nsCOMPtr<nsIEventTarget> main_thread_;
ReentrantMonitor monitor_;