]> sigrok.org Git - libsigrokdecode.git/commitdiff
instance: return SRD_ERR_TERM_REQ when execution shall terminate
authorGerhard Sittig <redacted>
Mon, 23 Apr 2018 18:42:54 +0000 (20:42 +0200)
committerGerhard Sittig <redacted>
Mon, 23 Apr 2018 21:25:42 +0000 (23:25 +0200)
The previous implementation internally noticed the "want terminate"
request, and skipped decoder execution to faster get to the end of the
input stream. But an OK return code was provided in that code path, and
more input data was sent by applications (sometimes for many seconds or
few minutes).

Do return a new SRD_ERR_TERM_REQ error code, such that applications can
tell failed execution from requested termination.

instance.c
libsigrokdecode.h

index e470bd14e70ab0a1f0085e1edb20cea3a112e956..f8cd2c68f66804833d0f41e75e885c27c5b86a4d 100644 (file)
@@ -1266,6 +1266,8 @@ SRD_PRIV int srd_inst_decode(struct srd_decoder_inst *di,
                g_cond_wait(&di->handled_all_samples_cond, &di->data_mutex);
        g_mutex_unlock(&di->data_mutex);
 
                g_cond_wait(&di->handled_all_samples_cond, &di->data_mutex);
        g_mutex_unlock(&di->data_mutex);
 
+       if (di->want_wait_terminate)
+               return SRD_ERR_TERM_REQ;
        return SRD_OK;
 }
 
        return SRD_OK;
 }
 
index ee610c939d3398ded1e068953fb3edec0c95eab7..a26bce9a402ba720ac5e8c1141bccdd131b50966 100644 (file)
@@ -71,6 +71,7 @@ enum srd_error_code {
        SRD_ERR_BUG          = -4, /**< Errors hinting at internal bugs */
        SRD_ERR_PYTHON       = -5, /**< Python C API error */
        SRD_ERR_DECODERS_DIR = -6, /**< Protocol decoder path invalid */
        SRD_ERR_BUG          = -4, /**< Errors hinting at internal bugs */
        SRD_ERR_PYTHON       = -5, /**< Python C API error */
        SRD_ERR_DECODERS_DIR = -6, /**< Protocol decoder path invalid */
+       SRD_ERR_TERM_REQ     = -7, /**< Termination requested */
 
        /*
         * Note: When adding entries here, don't forget to also update the
 
        /*
         * Note: When adding entries here, don't forget to also update the