stream_{client,server} example: Cleanup on exit
In order to detect memory leaks while debugging, stream server/client and keyboard is closed on exit. Related: OS#5753 Change-Id: I9dbb7f46b2a798e88ad4df8ff73c6ee40c07b843
This commit is contained in:
parent
e1153bcd37
commit
b06e63b7c7
|
@ -32,10 +32,13 @@ const struct log_info osmo_stream_cli_test_log_info = {
|
|||
|
||||
static struct osmo_stream_cli *conn;
|
||||
|
||||
static bool quit = false;
|
||||
|
||||
void sighandler(int foo)
|
||||
{
|
||||
LOGP(DSTREAMTEST, LOGL_NOTICE, "closing stream.\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
quit = true;
|
||||
signal(SIGINT, SIG_DFL);
|
||||
}
|
||||
|
||||
static int connect_cb(struct osmo_stream_cli *conn)
|
||||
|
@ -162,9 +165,15 @@ int main(int argc, char **argv)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
signal(SIGINT, sighandler);
|
||||
|
||||
LOGP(DSTREAMTEST, LOGL_NOTICE, "Entering main loop\n");
|
||||
|
||||
while(1) {
|
||||
while (!quit) {
|
||||
osmo_select_main(0);
|
||||
}
|
||||
|
||||
osmo_fd_unregister(kbd_ofd);
|
||||
|
||||
osmo_stream_cli_destroy(conn);
|
||||
}
|
||||
|
|
|
@ -35,11 +35,13 @@ const struct log_info osmo_stream_srv_test_log_info = {
|
|||
static struct osmo_stream_srv_link *srv;
|
||||
static struct osmo_stream_srv *conn;
|
||||
|
||||
bool quit = false;
|
||||
|
||||
void sighandler(int foo)
|
||||
{
|
||||
LOGP(DSTREAMTEST, LOGL_NOTICE, "closing STREAMSERVER.\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
quit = true;
|
||||
signal(SIGINT, SIG_DFL);
|
||||
}
|
||||
|
||||
int read_cb(struct osmo_stream_srv *conn, struct msgb *msg)
|
||||
|
@ -181,9 +183,15 @@ int main(int argc, char **argv)
|
|||
osmo_fd_setup(kbd_ofd, STDIN_FILENO, OSMO_FD_READ, kbd_cb, srv, 0);
|
||||
osmo_fd_register(kbd_ofd);
|
||||
|
||||
signal(SIGINT, sighandler);
|
||||
|
||||
LOGP(DSTREAMTEST, LOGL_NOTICE, "Entering main loop on %s\n", osmo_stream_srv_link_get_sockname(srv));
|
||||
|
||||
while(1) {
|
||||
while (!quit) {
|
||||
osmo_select_main(0);
|
||||
}
|
||||
|
||||
osmo_fd_unregister(kbd_ofd);
|
||||
|
||||
osmo_stream_srv_link_destroy(srv);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue