summaryrefslogtreecommitdiff
path: root/vxi11_server.c
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-24 22:33:40 +0900
committerdaniel <danieruru@gmail.com>2013-01-24 22:33:40 +0900
commit24ce34333674e918b86727d2b84be79af268ab2e (patch)
treeed9da1c0a2232e4e2e6ad3bcaca559da70c5194e /vxi11_server.c
parente613d8991b8613e7f4081b56082bb37ff8b9a4db (diff)
fix logic for io wait
Diffstat (limited to 'vxi11_server.c')
-rw-r--r--vxi11_server.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/vxi11_server.c b/vxi11_server.c
index 0a243b7..6f8c487 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -75,12 +75,12 @@ static bool waitForLock(Device_Flags flags, long timeout) {
static bool waitforio(long timeout) {
if (!globals.VxiLocks.command_in_progress)
return true;
- while (timeout < 0 && !globals.VxiLocks.command_in_progress) {
+ while (timeout < 0) {
+ if (!globals.VxiLocks.command_in_progress)
+ return true;
usleep(250);
timeout -= 250;
}
- if (timeout > 0)
- return true;
#ifdef DEBUG
printf("timeout waiting for command to finish\n");
#endif
@@ -157,6 +157,7 @@ create_link_1_svc(Create_LinkParms *argp, struct svc_req *rqstp) {
Device_WriteResp *
device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
static Device_WriteResp result;
+ memset(&result, 0, sizeof(result));
#ifdef DEBUG
printf("device_write_1_svc()\n");
#endif
@@ -164,17 +165,14 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
result.error = ERR_INVALIDLINKINDENTIFIER;
else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->flags, argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
- else if (!waitforio(argp->io_timeout)) {
- result.size = 0;
+ else if (!waitforio(argp->io_timeout))
result.error = ERR_IOTIMEOUT;
- }
else {
#ifdef DEBUG
printf("got %s on link %d\n", argp->data.data_val, (int) argp->lid);
#endif
Parser_main(argp->data.data_val, 0, GPIB_and_VXI_start_query_response, NULL);
result.size = argp->data.data_len;
- result.error = 0;
}
return &result;