Fix issue #87: Hangs at 100% on Arch Linux

This commit is contained in:
DreamSourceLab 2017-06-01 13:31:35 +08:00
parent 79fdd36d5a
commit 45abe48a91
3 changed files with 24 additions and 22 deletions

View File

@ -160,11 +160,16 @@ bool StoreSession::save_start()
_error = tr("Generate temp file failed."); _error = tr("Generate temp file failed.");
return false; return false;
} else { } else {
sr_session_save_init(_file_name.toLocal8Bit().data(), int ret = sr_session_save_init(_file_name.toLocal8Bit().data(),
meta_file.toLocal8Bit().data(), meta_file.toLocal8Bit().data(),
decoders_file.toLocal8Bit().data()); decoders_file.toLocal8Bit().data());
_thread = boost::thread(&StoreSession::save_proc, this, snapshot); if (ret != SR_OK) {
return !_has_error; _error = tr("Failed to create zip file. Please check write permission of this path.");
return false;
} else {
_thread = boost::thread(&StoreSession::save_proc, this, snapshot);
return !_has_error;
}
} }
} }
@ -239,7 +244,7 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
{ {
GSList *l; GSList *l;
GVariant *gvar; GVariant *gvar;
FILE *meta; FILE *meta = NULL;
struct sr_channel *probe; struct sr_channel *probe;
int probecnt; int probecnt;
char *s; char *s;
@ -262,6 +267,11 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
const sr_dev_inst *sdi = _session.get_device()->dev_inst(); const sr_dev_inst *sdi = _session.get_device()->dev_inst();
meta = fopen(metafile.toLocal8Bit().data(), "wb"); meta = fopen(metafile.toLocal8Bit().data(), "wb");
if (meta == NULL) {
qDebug() << "Failed to create temp meta file.";
return NULL;
}
fprintf(meta, "[version]\n"); fprintf(meta, "[version]\n");
if (sdi->mode == DSO) if (sdi->mode == DSO)
fprintf(meta, "version = %d\n", 1); // should be updated in next version fprintf(meta, "version = %d\n", 1); // should be updated in next version

View File

@ -2532,7 +2532,7 @@ static unsigned int get_number_of_transfers(struct DSL_context *devc)
total_buffer_time * to_bytes_per_ms(devc)); total_buffer_time * to_bytes_per_ms(devc));
/* Total buffer size should be able to hold about 500ms of data. */ /* Total buffer size should be able to hold about 500ms of data. */
//n = 500 * to_bytes_per_ms(devc) / get_buffer_size(devc); //n = 500 * to_bytes_per_ms(devc) / get_buffer_size(devc);
n = ceil(total_size * 1.0 / get_buffer_size(devc)); n = ceil(total_size * 1.0f / get_buffer_size(devc));
if (n > NUM_SIMUL_TRANSFERS) if (n > NUM_SIMUL_TRANSFERS)
return NUM_SIMUL_TRANSFERS; return NUM_SIMUL_TRANSFERS;
@ -2620,15 +2620,12 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
struct timeval tv; struct timeval tv;
struct drv_context *drvc; struct drv_context *drvc;
struct DSL_context *devc; struct DSL_context *devc;
struct sr_usb_dev_inst *usb;
int ret;
(void)fd; (void)fd;
(void)revents; (void)revents;
drvc = di->priv; drvc = di->priv;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn;
tv.tv_sec = tv.tv_usec = 0; tv.tv_sec = tv.tv_usec = 0;
libusb_handle_events_timeout_completed(drvc->sr_ctx->libusb_ctx, &tv, &completed); libusb_handle_events_timeout_completed(drvc->sr_ctx->libusb_ctx, &tv, &completed);
@ -2638,19 +2635,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
} }
if (devc->status == DSL_FINISH) { if (devc->status == DSL_FINISH) {
if (libusb_try_lock_events(drvc->sr_ctx->libusb_ctx) == 0) { remove_sources(devc);
if (libusb_event_handling_ok(drvc->sr_ctx->libusb_ctx)) {
/* Stop GPIF acquisition */
usb = ((struct sr_dev_inst *)devc->cb_data)->conn;
if ((ret = command_stop_acquisition (usb->devhdl)) != SR_OK)
sr_err("%s: Sent acquisition stop command failed!", __func__);
else
sr_info("%s: Sent acquisition stop command!", __func__);
remove_sources(devc);
}
libusb_unlock_events(drvc->sr_ctx->libusb_ctx);
}
} }
return TRUE; return TRUE;
@ -2841,6 +2826,7 @@ static int dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data)
struct DSL_context *devc; struct DSL_context *devc;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
int ret;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn; usb = sdi->conn;
@ -2848,6 +2834,12 @@ static int dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data)
if (!devc->abort) { if (!devc->abort) {
devc->abort = TRUE; devc->abort = TRUE;
command_wr_reg(usb->devhdl, bmFORCE_RDY, EEWP_ADDR); command_wr_reg(usb->devhdl, bmFORCE_RDY, EEWP_ADDR);
} else if (devc->status == DSL_FINISH) {
/* Stop GPIF acquisition */
if ((ret = command_stop_acquisition (usb->devhdl)) != SR_OK)
sr_err("%s: Sent acquisition stop command failed!", __func__);
else
sr_info("%s: Sent acquisition stop command!", __func__);
} }
return SR_OK; return SR_OK;

View File

@ -2352,7 +2352,7 @@ static unsigned int get_number_of_transfers(struct DSL_context *devc)
{ {
unsigned int n; unsigned int n;
/* Total buffer size should be able to hold about 100ms of data. */ /* Total buffer size should be able to hold about 100ms of data. */
n = total_buffer_time * to_bytes_per_ms(devc) / get_buffer_size(devc); n = ceil(total_buffer_time * 1.0f * to_bytes_per_ms(devc) / get_buffer_size(devc));
if (n > NUM_SIMUL_TRANSFERS) if (n > NUM_SIMUL_TRANSFERS)
return NUM_SIMUL_TRANSFERS; return NUM_SIMUL_TRANSFERS;