summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2018-04-23 20:42:54 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2018-04-23 23:25:42 +0200
commit3f3c4614b551855d7cf56e83ec7fb883592050ab (patch)
treecbb437be87f0b530e6e36802e09af913ef26ae6a
parentf8d25d1f7256a4515b7fb972e3302be2138c8ee1 (diff)
downloadlibsigrokdecode-3f3c4614b551855d7cf56e83ec7fb883592050ab.tar.gz
libsigrokdecode-3f3c4614b551855d7cf56e83ec7fb883592050ab.zip
instance: return SRD_ERR_TERM_REQ when execution shall terminate
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.
-rw-r--r--instance.c2
-rw-r--r--libsigrokdecode.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/instance.c b/instance.c
index e470bd1..f8cd2c6 100644
--- a/instance.c
+++ b/instance.c
@@ -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);
+ if (di->want_wait_terminate)
+ return SRD_ERR_TERM_REQ;
return SRD_OK;
}
diff --git a/libsigrokdecode.h b/libsigrokdecode.h
index ee610c9..a26bce9 100644
--- a/libsigrokdecode.h
+++ b/libsigrokdecode.h
@@ -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_TERM_REQ = -7, /**< Termination requested */
/*
* Note: When adding entries here, don't forget to also update the