kopia lustrzana https://github.com/Hamlib/Hamlib
Fix the easy parts of missing thread locks
- Fix depth initialization so LOCK() at least calls rig_lock() - Add message showing why rig_lock() does nothing - Add missing LOCK(0)spull/1675/head
rodzic
3d46647808
commit
439bd96b5d
27
src/rig.c
27
src/rig.c
|
@ -621,7 +621,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
|||
rs->rig_model = caps->rig_model;
|
||||
rs->priv = NULL;
|
||||
rs->async_data_enabled = 0;
|
||||
rs->depth = 1;
|
||||
// rs->depth = 1;
|
||||
rs->comm_state = 0;
|
||||
rs->comm_status = RIG_COMM_STATUS_CONNECTING;
|
||||
rs->tuner_control_pathname = DEFAULT_TUNER_CONTROL_PATHNAME;
|
||||
|
@ -2494,14 +2494,6 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s: depth=%d\n", __func__, rs->depth);
|
||||
|
||||
if (rs->depth == 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s: %s\n", 1 ? "lock" : "unlock", __func__);
|
||||
// rig_lock(rig, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// there are some rigs that can't get VFOA freq while VFOB is transmitting
|
||||
// so we'll return the cached VFOA freq for them
|
||||
// should we use the cached ptt maybe? No -- we have to be 100% sure we're in PTT to ignore this request
|
||||
|
@ -2789,6 +2781,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
if (locked_mode)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
|
@ -2797,6 +2790,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s PTT on so set_mode ignored\n", __func__);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
|
@ -2805,6 +2799,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
if (caps->set_mode == NULL)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
|
@ -3504,6 +3499,7 @@ int HAMLIB_API rig_get_vfo(RIG *rig, vfo_t *vfo)
|
|||
{
|
||||
rig->caps->get_vfo = NULL;
|
||||
*vfo = RIG_VFO_A;
|
||||
LOCK(0);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
|
@ -3724,6 +3720,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
__func__,
|
||||
pttp->pathname);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_EIO);
|
||||
}
|
||||
|
||||
|
@ -3735,6 +3732,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
if (RIG_OK != retcode)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
}
|
||||
|
@ -3774,6 +3772,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
__func__,
|
||||
pttp->pathname);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_EIO);
|
||||
}
|
||||
|
||||
|
@ -3786,6 +3785,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: ser_set_dtr retcode=%d\n", __func__, retcode);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
}
|
||||
|
@ -3825,6 +3825,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
rig_debug(RIG_DEBUG_WARN, "%s: unknown PTT type=%d\n", __func__,
|
||||
pttp->type.ptt);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
|
@ -3849,7 +3850,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
if (rs->post_ptt_delay > 0) { hl_usleep(rs->post_ptt_delay * 1000); }
|
||||
|
||||
ELAPSED2;
|
||||
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -8364,7 +8365,11 @@ void rig_lock(RIG *rig, int lock)
|
|||
|
||||
struct rig_state *rs = STATE(rig);
|
||||
|
||||
if (rs->multicast == NULL) { return; } // not initialized yet
|
||||
if (rs->multicast == NULL)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_BUG, "%s: locking skipped, lock = %d\n", __func__, lock);
|
||||
return;
|
||||
} // not initialized yet
|
||||
|
||||
if (!rs->multicast->mutex_initialized)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue