summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vxi11_server.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/vxi11_server.c b/vxi11_server.c
index b1f7c41..1d66688 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -84,7 +84,7 @@ create_link_1_svc(Create_LinkParms *argp, struct svc_req *rqstp) {
result.error = ERR_OUTOFRESOURCES;
}
else {
- if (argp->lockDevice && isLocked()) {
+ if (argp->lockDevice && isLocked() && !waitForLock(argp->lock_timeout)) {
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
}
else {
@@ -125,7 +125,7 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
else {
- if (isLocked(argp->lid) && !haveLock(argp->lid))
+ if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
printf("%s\n", argp->data.data_val);
@@ -145,15 +145,13 @@ device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
- if (isLocked(argp->lid) && !haveLock(argp->lid))
- result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
- else {
- result.data.data_val = "HELLO!";
- result.data.data_len = 7;
- result.error = 0;
- result.reason = 0x4;
- }
+ result.data.data_val = "HELLO!";
+ result.data.data_len = 7;
+ result.error = 0;
+ result.reason = 0x4;
}
return &result;
}
@@ -166,6 +164,8 @@ device_readstb_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.error = 0;
result.stb = 0;
@@ -181,6 +181,8 @@ device_trigger_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.error = 0;
}
@@ -195,6 +197,8 @@ device_clear_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.error = 0;
}
@@ -209,6 +213,8 @@ device_remote_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
if (isLocked() && !haveLock(argp->lid))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
@@ -226,6 +232,8 @@ device_local_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
if (isLocked() && !haveLock(argp->lid))
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
@@ -299,6 +307,8 @@ device_docmd_1_svc(Device_DocmdParms *argp, struct svc_req *rqstp) {
#endif
if (!isValidLink(argp->lid))
result.error = ERR_INVALIDLINKINDENTIFIER;
+ else if (isLocked() && !haveLock(argp->lid) && !waitForLock(argp->lock_timeout))
+ result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
result.data_out.data_out_len = 0;
result.data_out.data_out_val = NULL;