From 2c92f3c44f2e5bcfcabfe7771f17b77368d37b03 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 27 Mar 2020 19:48:42 -0500 Subject: Meas Tools: Avoid unusable terminal in case of error on osmo_sock_init If, as before this patch we call initCDKScreen() before attempting to bind the socket, then the socket bind fails, we exit and the terminal needs a reset. Attempt to open the socket before initCDKScreen() so we don't end up with a messed up terminal if the socket call fails. Change-Id: Ia5148d9ef386df314bc2837b3cb672150250bd2a --- src/utils/meas_vis.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/utils/meas_vis.c b/src/utils/meas_vis.c index aea12bf9b..e10d8148c 100644 --- a/src/utils/meas_vis.c +++ b/src/utils/meas_vis.c @@ -283,6 +283,10 @@ int main(int argc, char **argv) printf("sizeof(gsm_meas_rep)=%u\n", sizeof(struct gsm_meas_rep)); printf("sizeof(meas_feed_meas)=%u\n", sizeof(struct meas_feed_meas)); + g_st.udp_ofd.cb = udp_fd_cb; + rc = osmo_sock_init_ofd(&g_st.udp_ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, 8888, OSMO_SOCK_F_BIND); + if (rc < 0) + exit(1); INIT_LLIST_HEAD(&g_st.ms_list); g_st.curses_win = initscr(); @@ -311,11 +315,6 @@ int main(int argc, char **argv) exit(0); #endif - g_st.udp_ofd.cb = udp_fd_cb; - rc = osmo_sock_init_ofd(&g_st.udp_ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, 8888, OSMO_SOCK_F_BIND); - if (rc < 0) - exit(1); - while (1) { osmo_select_main(0); update_sliders(); -- cgit v1.2.3