Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit acbb773

Browse files
committed
Resolve comments
1 parent daf245c commit acbb773

26 files changed

+110
-124
lines changed

doc/design/owt-internal-transport.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Internal Transport
22

33
# 1 Overview
44

5-
Internal transport use client-server model.
5+
Internal transport uses client-server model.
66

77
An internal server for each process and one server can host multiple streams.
88

source/agent/addons/internalIO/InternalClientWrapper.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ InternalClient::InternalClient() {
2222

2323
static void destroyAsyncHandle(uv_handle_t *handle) {
2424
delete handle;
25+
handle = nullptr;
2526
}
2627

2728
InternalClient::~InternalClient() {
28-
boost::mutex::scoped_lock lock(mutex);
29+
boost::mutex::scoped_lock lock(stats_lock);
2930
if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(async_stats_))) {
3031
ELOG_DEBUG("Closing Stats handle");
3132
uv_close(reinterpret_cast<uv_handle_t*>(async_stats_), destroyAsyncHandle);
@@ -132,7 +133,7 @@ NAUV_WORK_CB(InternalClient::statsCallback) {
132133
return;
133134
}
134135

135-
boost::mutex::scoped_lock lock(obj->mutex);
136+
boost::mutex::scoped_lock lock(obj->stats_lock);
136137
while (!obj->stats_messages.empty()) {
137138
Local<Value> args[] = {
138139
Nan::New(obj->stats_messages.front().c_str()).ToLocalChecked()
@@ -146,7 +147,7 @@ NAUV_WORK_CB(InternalClient::statsCallback) {
146147
}
147148

148149
void InternalClient::onConnected() {
149-
boost::mutex::scoped_lock lock(mutex);
150+
boost::mutex::scoped_lock lock(stats_lock);
150151
if (!async_stats_ || !stats_callback_) {
151152
return;
152153
}
@@ -156,7 +157,7 @@ void InternalClient::onConnected() {
156157
}
157158

158159
void InternalClient::onDisconnected() {
159-
boost::mutex::scoped_lock lock(mutex);
160+
boost::mutex::scoped_lock lock(stats_lock);
160161
if (!async_stats_ || !stats_callback_) {
161162
return;
162163
}

source/agent/addons/internalIO/InternalClientWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class InternalClient : public FrameSource,
2020
static NAN_MODULE_INIT(Init);
2121

2222
owt_base::InternalClient* me;
23-
boost::mutex mutex;
23+
boost::mutex stats_lock;
2424
std::queue<std::string> stats_messages;
2525

2626
// Implements owt_base::InternalClient::Listener

source/agent/addons/internalIO/InternalServerWrapper.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ InternalServer::InternalServer() {
2222

2323
static void destroyAsyncHandle(uv_handle_t *handle) {
2424
delete handle;
25+
handle = nullptr;
2526
}
2627

2728
InternalServer::~InternalServer() {
28-
boost::mutex::scoped_lock lock(mutex);
29+
boost::mutex::scoped_lock lock(stats_lock);
2930
if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(async_stats_))) {
3031
ELOG_DEBUG("Closing Stats handle");
3132
uv_close(reinterpret_cast<uv_handle_t*>(async_stats_), destroyAsyncHandle);
@@ -65,7 +66,7 @@ NAN_METHOD(InternalServer::New) {
6566
InternalServer* obj = new InternalServer();
6667
obj->me = new owt_base::InternalServer(
6768
protocol, minPort, maxPort, obj);
68-
if (info.Length() > 3) {
69+
if (info.Length() > 3 && info[3]->IsFunction()) {
6970
obj->stats_callback_ = new Nan::Callback(info[3].As<Function>());
7071
}
7172
obj->Wrap(info.This());
@@ -122,7 +123,7 @@ NAUV_WORK_CB(InternalServer::statsCallback) {
122123
if (!obj || !obj->me || !obj->stats_callback_) {
123124
return;
124125
}
125-
boost::mutex::scoped_lock lock(obj->mutex);
126+
boost::mutex::scoped_lock lock(obj->stats_lock);
126127
while (!obj->stats_messages.empty()) {
127128
Local<Value> args[] = {
128129
Nan::New(obj->stats_messages.front().first.c_str()).ToLocalChecked(),
@@ -137,7 +138,7 @@ NAUV_WORK_CB(InternalServer::statsCallback) {
137138
}
138139

139140
void InternalServer::onConnected(const std::string& id) {
140-
boost::mutex::scoped_lock lock(mutex);
141+
boost::mutex::scoped_lock lock(stats_lock);
141142
if (!async_stats_ || !stats_callback_) {
142143
return;
143144
}
@@ -147,7 +148,7 @@ void InternalServer::onConnected(const std::string& id) {
147148
}
148149

149150
void InternalServer::onDisconnected(const std::string& id) {
150-
boost::mutex::scoped_lock lock(mutex);
151+
boost::mutex::scoped_lock lock(stats_lock);
151152
if (!async_stats_ || !stats_callback_) {
152153
return;
153154
}

source/agent/addons/internalIO/InternalServerWrapper.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <logger.h>
1111
#include <nan.h>
1212

13+
#include <queue>
14+
#include <string>
15+
1316
/*
1417
* Wrapper class of owt_base::InternalServer
1518
*/
@@ -20,7 +23,7 @@ class InternalServer : public node::ObjectWrap,
2023
static NAN_MODULE_INIT(Init);
2124

2225
owt_base::InternalServer* me;
23-
boost::mutex mutex;
26+
boost::mutex stats_lock;
2427
std::queue<std::pair<std::string, std::string>> stats_messages;
2528

2629
// Implements owt_base::InternalServer::Listener

source/agent/audio/dist.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"selectiveMixer.js",
3131
"activeAudioSelector.js",
3232
"../connections.js",
33-
"../InternalConnectionFactory.js",
3433
"../internalConnectionRouter.js"
3534
]
3635
}

source/agent/audio/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var logger = require('../logger').logger;
1616

1717
// Logger
1818
var log = logger.getLogger('AudioNode');
19-
var InternalConnectionFactory = require('./InternalConnectionFactory');
2019
var {InternalConnectionRouter} = require('./internalConnectionRouter');
2120

2221

@@ -51,10 +50,7 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
5150
*/
5251
connections = {},
5352

54-
router = new InternalConnectionRouter(global.config.internal),
55-
56-
// For internal SCTP connection creation
57-
internalConnFactory = new InternalConnectionFactory;
53+
router = new InternalConnectionRouter(global.config.internal);
5854

5955
var addInput = function (stream_id, owner, codec, options, on_ok, on_error) {
6056
if (engine) {

source/agent/recording/dist.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"recording": [
2929
"index.js",
3030
"../connections.js",
31-
"../InternalConnectionFactory.js",
3231
"../internalConnectionRouter.js"
3332
]
3433
}

source/agent/recording/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ var Connections = require('./connections');
1818
// Logger
1919
var log = logger.getLogger('RecordingNode');
2020

21-
var InternalConnectionFactory = require('./InternalConnectionFactory');
2221
var {InternalConnectionRouter} = require('./internalConnectionRouter');
2322

2423

@@ -28,7 +27,6 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
2827
clusterIP: clusterWorkerIP
2928
};
3029
var connections = new Connections;
31-
var internalConnFactory = new InternalConnectionFactory;
3230
var router = new InternalConnectionRouter(global.config.internal);
3331

3432
var notifyStatus = (controller, sessionId, direction, status) => {

source/agent/sip/dist.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"index.js",
2828
"sipCallConnection.js",
2929
"../connections.js",
30-
"../internalConnectionRouter.js",
31-
"../InternalConnectionFactory.js"
30+
"../internalConnectionRouter.js"
3231
]
3332
}
3433
},

0 commit comments

Comments
 (0)