Skip to content

Commit

Permalink
fixed zombie process issue
Browse files Browse the repository at this point in the history
  • Loading branch information
plutoless committed Jan 22, 2019
1 parent 2ec9902 commit aa6687b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ void AgoraSdk::onJoinChannelSuccessImpl(const char * channelId, agora::linuxsdk:

void AgoraSdk::onLeaveChannelImpl(agora::linuxsdk::LEAVE_PATH_CODE code) {
cout << "leave channel with code:" << code << endl;
agora::recording::node_async_call::async_call([this]() {
MAKE_JS_CALL_0(REC_EVENT_LEAVE_CHANNEL);
});
}

void AgoraSdk::onUserJoinedImpl(unsigned uid, agora::linuxsdk::UserJoinInfos &infos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct MixModeSettings {

class AgoraSdk : virtual public agora::recording::IRecordingEngineEventHandler {
#define REC_EVENT_JOIN_CHANNEL "joinchannel"
#define REC_EVENT_LEAVE_CHANNEL "leavechannel"
#define REC_EVENT_ERROR "error"
#define REC_EVENT_USER_JOIN "userjoin"
#define REC_EVENT_USER_LEAVE "userleave"
Expand Down
88 changes: 44 additions & 44 deletions Agora-Restful-Recording-Nodejs/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions Agora-Restful-Recording-Nodejs/server/recordManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RecordManager{
console.error(`sdk stopped due to err code: ${err} stat: ${stat}`);
console.log(`stop recorder ${appid} ${channel} ${sid}`)
//clear recorder if error received
delete this.recorders[`${sid}`];
this.onCleanup(sid)
});
sdk.on("userleave", (uid) => {
console.log(`user leave ${uid}`);
Expand Down Expand Up @@ -134,9 +134,21 @@ class RecordManager{
stop(sid) {
let recorder = this.recorders[sid];
if(recorder) {
let {sdk, appid, channel} = recorder;
sdk.leaveChannel();
let {appid, channel} = recorder;
console.log(`stop recorder ${appid} ${channel} ${sid}`)
this.onCleanup(sid);
} else {
throw new Error('recorder not exists');
}
}

onCleanup(sid) {
let recorder = this.recorders[sid];
if(recorder) {
let {sdk} = recorder;
console.log(`releasing ${sid}`)
sdk.leaveChannel()
sdk.release()
delete this.recorders[`${sid}`];
} else {
throw new Error('recorder not exists');
Expand Down

0 comments on commit aa6687b

Please sign in to comment.