aboutsummaryrefslogtreecommitdiffstats
path: root/src/fl2k_tcp.c
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2019-08-26 19:26:30 +0200
committerSteve Markgraf <steve@steve-m.de>2019-08-26 19:26:30 +0200
commit077613efc501195f4ad0018e9d94f848654f6c3e (patch)
treeed59d9ef7ad448e6dae7fbac35daafa4b219e556 /src/fl2k_tcp.c
parentb8d33bfd820953982093b7a7db154a58d7f7bd9e (diff)
downloadosmo-fl2k-077613efc501195f4ad0018e9d94f848654f6c3e.tar.gz
osmo-fl2k-077613efc501195f4ad0018e9d94f848654f6c3e.tar.bz2
osmo-fl2k-077613efc501195f4ad0018e9d94f848654f6c3e.zip
improve exit handling on device removal
Diffstat (limited to 'src/fl2k_tcp.c')
-rw-r--r--src/fl2k_tcp.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fl2k_tcp.c b/src/fl2k_tcp.c
index bd01758..1fa9e5d 100644
--- a/src/fl2k_tcp.c
+++ b/src/fl2k_tcp.c
@@ -107,6 +107,12 @@ void fl2k_callback(fl2k_data_info_t *data_info)
int r;
struct timeval tv = { 1, 0 };
+ if (data_info->device_error) {
+ fprintf(stderr, "Device error, exiting.\n");
+ do_exit = 1;
+ return;
+ }
+
if (!connected)
return;
@@ -122,6 +128,12 @@ void fl2k_callback(fl2k_data_info_t *data_info)
if (r) {
received = recv(sock, txbuf + (FL2K_BUF_LEN - left), left, 0);
+ if (!received) {
+ fprintf(stderr, "Connection was closed!\n");
+ fl2k_stop_tx(dev);
+ do_exit = 1;
+ }
+
left -= received;
}
}