MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / morse_data_handler_stop

Function morse_data_handler_stop

src/rig.c:8603–8655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8601}
8602
8603static int morse_data_handler_stop(RIG *rig)
8604{
8605 struct rig_state *rs = STATE(rig);
8606 morse_data_handler_priv_data *morse_data_handler_priv;
8607
8608 ENTERFUNC;
8609
8610 rs->morse_data_handler_thread_run = 0;
8611
8612 morse_data_handler_priv = (morse_data_handler_priv_data *)
8613 rs->morse_data_handler_priv_data;
8614
8615 // wait until fifo queue is flushed
8616 //HAMLIB_TRACE;
8617 hl_usleep(100 * 1000);
8618
8619 //HAMLIB_TRACE;
8620 while (hl_peek(rs->fifo_morse) >= 0)
8621 {
8622 HAMLIB_TRACE;
8623 rig_debug(RIG_DEBUG_TRACE, "%s: waiting for fifo queue to flush\n", __func__);
8624 hl_usleep(100 * 1000);
8625 }
8626
8627 //HAMLIB_TRACE;
8628 hl_usleep(100 * 1000);
8629
8630 //HAMLIB_TRACE;
8631 if (morse_data_handler_priv != NULL)
8632 {
8633 if (morse_data_handler_priv->thread_id != 0)
8634 {
8635 // all cleanup is done in this function so we can kill thread
8636 // Windows was taking 30 seconds to stop without this
8637 pthread_cancel(morse_data_handler_priv->thread_id);
8638 int err = pthread_join(morse_data_handler_priv->thread_id, NULL);
8639
8640 if (err)
8641 {
8642 rig_debug(RIG_DEBUG_ERR, "%s: pthread_join error: %s\n", __func__,
8643 strerror(errno));
8644 // just ignore the error
8645 }
8646
8647 morse_data_handler_priv->thread_id = 0;
8648 }
8649
8650 free(rs->morse_data_handler_priv_data);
8651 rs->morse_data_handler_priv_data = NULL;
8652 }
8653
8654 RETURNFUNC(RIG_OK);
8655}
8656
8657static void *async_data_handler(void *arg)
8658{

Callers 1

rig_closeFunction · 0.85

Calls 5

hl_usleepFunction · 0.85
hl_peekFunction · 0.85
rig_debugFunction · 0.85
pthread_cancelFunction · 0.85
pthread_joinFunction · 0.85

Tested by

no test coverage detected