Skip to content

Commit 3ffa564

Browse files
committed
fix(ssp_connector): Remove graceful disconnect to close faster
Newer version libssp caused close slowly. Since we are using stand- alone process to run libssp, just ignore closing the client. Signed-off-by: Yibai Zhang <xm1994@gmail.com>
1 parent 70a23e0 commit 3ffa564

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

ssp_connector/main.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void on_general_message(MessageType type)
108108
int sz = msg_write((char *)&msg, sizeof(msg));
109109
if (sz != sizeof(msg)) {
110110
log_conn("stopped.");
111-
gSspClient->stop();
111+
//gSspClient->stop();
112112
gLoop->quit();
113113
}
114114
}
@@ -130,7 +130,7 @@ static void on_video(imf::SspH264Data *video)
130130
free(msg);
131131
if (sz != len) {
132132
log_conn("stopped.");
133-
gSspClient->stop();
133+
//gSspClient->stop();
134134
gLoop->quit();
135135
}
136136
}
@@ -151,7 +151,7 @@ static void on_audio(imf::SspAudioData *audio)
151151
free(msg);
152152
if (sz != len) {
153153
log_conn("stopped.");
154-
gSspClient->stop();
154+
//gSspClient->stop();
155155
gLoop->quit();
156156
}
157157
}
@@ -186,7 +186,7 @@ static void on_meta(imf::SspVideoMeta *vmeta, struct imf::SspAudioMeta *ameta,
186186
free(msg);
187187
if (sz != len) {
188188
log_conn("stopped sz != len %d != %d.", sz, len);
189-
gSspClient->stop();
189+
//gSspClient->stop();
190190
gLoop->quit();
191191
}
192192
}
@@ -206,7 +206,7 @@ static void on_exception(int code, const char *description)
206206
if (sz != len) {
207207
log_conn("exception error.");
208208
}
209-
gSspClient->stop();
209+
//gSspClient->stop();
210210
gLoop->quit();
211211
}
212212

@@ -226,7 +226,7 @@ static void setup(imf::Loop *loop)
226226
std::bind(on_general_message, RecvBufferFullMsg));
227227
client->setOnDisconnectedCallback([=]() {
228228
on_general_message(DisconnectMsg);
229-
client->stop();
229+
//client->stop();
230230
loop->quit();
231231
});
232232
client->start();
@@ -238,7 +238,7 @@ static void setup(imf::Loop *loop)
238238

239239
if (sz != sizeof(msg)) {
240240
log_conn("stopped.");
241-
client->stop();
241+
//client->stop();
242242
gLoop->quit();
243243
}
244244
}
@@ -254,6 +254,7 @@ int main(int argc, char **argv)
254254
_setmode(_fileno(stdout), O_BINARY);
255255
#endif
256256
setvbuf(stdout, NULL, _IONBF, 0);
257+
setvbuf(logfile, NULL, _IONBF, 0);
257258
//setbuf(stdout, nullptr); // unbuffered stdout
258259

259260
log_conn("host: %s\nport: %d\nuuid: %s\n", address, port, uuid);
@@ -263,9 +264,10 @@ int main(int argc, char **argv)
263264
setup(gLoop);
264265
loop->loop();
265266
log_conn("loop finished");
267+
// gSspClient->stop();
266268
delete loop;
267-
if (gSspClient) {
268-
delete gSspClient;
269-
}
269+
// if (gSspClient) {
270+
// delete gSspClient;
271+
// }
270272
return 0;
271273
}

ssp_connector/main.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828

29+
#ifndef logfile
30+
#define logfile stderr
31+
#endif
32+
2933
#define log_conn(fmt, ...) \
30-
fprintf(stderr, "%s:%d " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__)
34+
fprintf(logfile, "%s:%d " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__)
3135

3236
// #define log_conn(fmt, ...) (void *)0;

0 commit comments

Comments
 (0)