]> sigrok.org Git - libsigrok.git/commitdiff
scpi_libgpib: Add mutex to SPoll.
authorFrank Stettner <redacted>
Thu, 11 Apr 2019 12:33:19 +0000 (14:33 +0200)
committerUwe Hermann <redacted>
Wed, 17 Apr 2019 15:44:51 +0000 (17:44 +0200)
src/scpi/scpi_libgpib.c

index 26fcadac9df66626b4c7e04ef43f55670ceef442..5c82bd6f3dee6edd2e27a25292d16667d10fad27 100644 (file)
@@ -169,13 +169,16 @@ SR_PRIV int sr_scpi_gpib_spoll(struct sr_scpi_dev_inst *scpi, char *buf)
 {
        struct scpi_gpib *gscpi = scpi->priv;
 
+       g_mutex_lock(&scpi->scpi_mutex);
        ibrsp(gscpi->descriptor, buf);
 
        if (ibsta & ERR) {
                sr_err("Error while serial polling: iberr = %s.",
                        gpib_error_string(iberr));
+               g_mutex_unlock(&scpi->scpi_mutex);
                return SR_ERR;
        }
+       g_mutex_unlock(&scpi->scpi_mutex);
        sr_spew("Successful serial poll: 0x%x", (uint8_t)buf[0]);
 
        return SR_OK;