-static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/ca/client/caParam.c,v 1.19 2002-06-03 10:47:35 hadaq Exp $";
+static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/ca/client/caParam.c,v 1.20 2002-06-03 17:47:08 hadaq Exp $";
#define _POSIX_C_SOURCE 199509L
#include <unistd.h>
#include <allParam.h>
-#define TIMEOUTEVT 0.0002
-#define TIMEOUTSG 10.0
+#define TIMEOUTEVT 1.0E-09
#define TIMEOUTIO 10.0
static void Param_copyStringsToAllocMem(struct event_handler_args args);
typedef struct CaParamS {
Tcl_Interp *cache;
pthread_mutex_t *cacheLock;
+ pthread_mutex_t *socketLock;
} CaParam;
typedef struct ParamStringResultS {
pthread_mutexattr_create(attr);
pthread_mutex_init(((CaParam *) (my->specParam))->cacheLock, *attr);
pthread_mutexattr_delete(attr);
+
+ ((CaParam *) (my->specParam))->socketLock = malloc(sizeof(pthread_mutex_t));
+ pthread_mutexattr_create(attr);
+ pthread_mutex_init(((CaParam *) (my->specParam))->socketLock, *attr);
+ pthread_mutexattr_delete(attr);
#else
((CaParam *) (my->specParam))->cacheLock = malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(((CaParam *) (my->specParam))->cacheLock, NULL);
+
+ ((CaParam *) (my->specParam))->socketLock = malloc(sizeof(pthread_mutex_t));
+ pthread_mutex_init(((CaParam *) (my->specParam))->socketLock, NULL);
#endif
((CaParam *) (my->specParam))->cache = Tcl_CreateInterp();
- if((status = ca_task_initialize()) != ECA_NORMAL) {
+ if ((status = ca_task_initialize()) != ECA_NORMAL) {
Param_strerror((Param *) my, ca_message(status));
+ pthread_mutex_destroy(((CaParam *) (my->specParam))->cacheLock);
free(((CaParam *) (my->specParam))->cacheLock);
+ pthread_mutex_destroy(((CaParam *) (my->specParam))->socketLock);
+ free(((CaParam *) (my->specParam))->socketLock);
retVal = -1;
} else {
- if(setup != NULL) {
+ if (setup != NULL) {
my->setup = malloc(strlen(setup) + 1);
strcpy(my->setup, setup);
} else {
}
my->basedir = malloc(PARAM_MAX_VALUE_LEN);
uname(buffer);
- if(Param_getString(my, buffer->nodename, "basedir", &row, my->basedir) || (row != 1)) {
+ if (Param_getString(my, buffer->nodename, "basedir", &row, my->basedir) || (row != 1)) {
strcpy(my->basedir, "");
} else if (strlen(my->basedir)) {
strcat(my->basedir, "/");
Tcl_DeleteInterp(((CaParam *) (my->specParam))->cache);
pthread_mutex_destroy(((CaParam *) (my->specParam))->cacheLock);
free(((CaParam *) (my->specParam))->cacheLock);
+ pthread_mutex_destroy(((CaParam *) (my->specParam))->socketLock);
+ free(((CaParam *) (my->specParam))->socketLock);
free(my->basedir);
- if(my->setup != NULL) {
+ if (my->setup != NULL) {
free(my->setup);
}
}
char buf[PARAM_MAX_NAME_LEN];
*rows = 0;
- if(Param_getIntArrayCache(my, name, idx, maxrows, rows, val) || (*rows != maxrows)) {
-#ifdef SYNCHRONOUS_GROUP
- CA_SYNC_GID pgid;
-#endif
+ if (Param_getIntArrayCache(my, name, idx, maxrows, rows, val) || (*rows != maxrows)) {
pPVName = malloc((strlen("HAD:PI:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
Param_returnPVName(my, "PI", name, idx, pPVName);
- if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
- Param_strerror((Param *) my, ca_message(status));
- found = 0;
- } else if (status != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
- retVal = -1;
- } else {
-#ifdef SYNCHRONOUS_GROUP
- ca_sg_create(&pgid);
-#endif
- do {
- status = ca_pend_io(TIMEOUTIO);
- } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
- if(status != ECA_NORMAL) {
+ if (0 == pthread_mutex_lock(((CaParam *) (my->specParam))->socketLock)) {
+ if ((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
Param_strerror((Param *) my, ca_message(status));
found = 0;
- retVal = 0;
- }
- if(found == 1) {
-#ifndef SYNCHRONOUS_GROUP
- ParamIntResult resultS, *result = &resultS;
- result->val = val;
- result->rows = rows;
- result->maxrows = maxrows;
- result->my = my;
- result->retVal = &retVal;
- result->isReady = &isReady;
- isReady = 1;
-
- status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyIntsToAllocMem, result);
-#else
- status = ca_sg_array_get(pgid, ca_field_type(chan), ca_element_count(chan), chan, val);
-#endif
+ } else if (status != ECA_NORMAL) {
Param_strerror((Param *) my, ca_message(status));
-#ifndef SYNCHRONOUS_GROUP
+ retVal = -1;
+ } else {
do {
- ca_pend_event(TIMEOUTEVT);
- } while(isReady == 1);
-#else
- if((status = ca_sg_block(pgid, TIMEOUTSG)) == ECA_TIMEOUT) {
- retVal = 0;
- *rows = 0;
- } else if (status == ECA_NORMAL) {
+ status = ca_pend_io(TIMEOUTIO);
+ } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
+ if (status != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ found = 0;
retVal = 0;
- *rows = maxrows > ca_element_count(chan) ? ca_element_count(chan) : maxrows;
- } else {
- retVal = -1;
- *rows = 0;
}
- ca_sg_delete(pgid);
-#endif
- }
- if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
+ if (found == 1) {
+ ParamIntResult resultS, *result = &resultS;
+ result->val = val;
+ result->rows = rows;
+ result->maxrows = maxrows;
+ result->my = my;
+ result->retVal = &retVal;
+ result->isReady = &isReady;
+ isReady = 1;
+
+ status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyIntsToAllocMem, result);
+ Param_strerror((Param *) my, ca_message(status));
+ do {
+ ca_pend_event(TIMEOUTEVT);
+ } while(isReady == 1);
+ }
+ if ((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ }
}
+ pthread_mutex_unlock(((CaParam *) (my->specParam))->socketLock);
}
-
free(pPVName);
- if(maxrows == 1) {
+ if (maxrows == 1) {
Param_storeIntCache(my, name, idx, *val);
} else {
for (i = 0 ; i < *rows ; i++) {
char buf[PARAM_MAX_NAME_LEN];
*rows = 0;
- if(Param_getStringArrayCache(my, name, idx, maxrows, rows, val) || (*rows != maxrows)) {
-#ifdef SYNCHRONOUS_GROUP
- CA_SYNC_GID pgid;
-#endif
+ if (Param_getStringArrayCache(my, name, idx, maxrows, rows, val) || (*rows != maxrows)) {
pPVName = malloc((strlen("HAD:PS:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
Param_returnPVName(my, "PS", name, idx, pPVName);
- if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
- Param_strerror((Param *) my, ca_message(status));
- found = 0;
- } else if (status != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
- retVal = -1;
- } else {
-#ifdef SYNCHRONOUS_GROUP
- ca_sg_create(&pgid);
-#endif
- do {
- status = ca_pend_io(TIMEOUTIO);
- } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
- if(status != ECA_NORMAL) {
+ if (0 == pthread_mutex_lock(((CaParam *) (my->specParam))->socketLock)) {
+ if ((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
Param_strerror((Param *) my, ca_message(status));
found = 0;
- retVal = 0;
- }
- if(found == 1) {
-#ifndef SYNCHRONOUS_GROUP
- ParamStringResult resultS, *result = &resultS;
- result->val = val;
- result->rows = rows;
- result->maxrows = maxrows;
- result->my = my;
- result->retVal = &retVal;
- result->isReady = &isReady;
- isReady = 1;
-
- status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyStringsToAllocMem, result);
-#else
- status = ca_sg_array_get(pgid, ca_field_type(chan), ca_element_count(chan), chan, val);
-#endif
+ } else if (status != ECA_NORMAL) {
Param_strerror((Param *) my, ca_message(status));
-#ifndef SYNCHRONOUS_GROUP
+ retVal = -1;
+ } else {
do {
- ca_pend_event(TIMEOUTEVT);
- } while(isReady == 1);
-#else
- if((status = ca_sg_block(pgid, TIMEOUTSG)) == ECA_TIMEOUT) {
+ status = ca_pend_io(TIMEOUTIO);
+ } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
+ if (status != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ found = 0;
retVal = 0;
- *rows = 0;
- } else if (status == ECA_NORMAL) {
- retVal = 0;
- *rows = maxrows > ca_element_count(chan) ? ca_element_count(chan) : maxrows;
- } else {
- retVal = -1;
- *rows = 0;
}
- ca_sg_delete(pgid);
-#endif
- }
+ if (found == 1) {
+ ParamStringResult resultS, *result = &resultS;
+ result->val = val;
+ result->rows = rows;
+ result->maxrows = maxrows;
+ result->my = my;
+ result->retVal = &retVal;
+ result->isReady = &isReady;
+ isReady = 1;
+
+ status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyStringsToAllocMem, result);
+ Param_strerror((Param *) my, ca_message(status));
+ do {
+ ca_pend_event(TIMEOUTEVT);
+ } while(isReady == 1);
+ }
- if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
+ if ((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ }
}
+ pthread_mutex_unlock(((CaParam *) (my->specParam))->socketLock);
}
free(pPVName);
- if(maxrows == 1) {
+ if (maxrows == 1) {
Param_storeStringCache(my, name, idx, *val);
} else {
for (i = 0 ; i < *rows ; i++) {
{
int isReady;
int retVal = 0;
- int hasPrefix = 0;
int status;
int found = 1;
chid chan;
int i;
char *prefixVal[PARAM_MAX_ARRAY_LEN];
char buf[PARAM_MAX_NAME_LEN];
- char prefix[PARAM_MAX_VALUE_LEN];
*rows = 0;
- if(Param_getStringArrayCache(my, name, idx, maxrows, rows, val) || (*rows != maxrows)) {
-#ifdef SYNCHRONOUS_GROUP
- CA_SYNC_GID pgid;
-#endif
+ if (Param_getStringArrayCache(my, name, idx, maxrows, rows, val) || (*rows != maxrows)) {
pPVName = malloc((strlen("HAD:PS:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
Param_returnPVName(my, "PS", name, idx, pPVName);
- if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
- Param_strerror((Param *) my, ca_message(status));
- found = 0;
- } else if (status != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
- retVal = -1;
- } else {
-#ifdef SYNCHRONOUS_GROUP
- ca_sg_create(&pgid);
-#endif
- do {
- status = ca_pend_io(TIMEOUTIO);
- } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
- if(status != ECA_NORMAL) {
+ if (0 == pthread_mutex_lock(((CaParam *) (my->specParam))->socketLock)) {
+ if ((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
Param_strerror((Param *) my, ca_message(status));
found = 0;
- retVal = 0;
- }
- if(found == 1) {
-#ifndef SYNCHRONOUS_GROUP
- ParamStringResult resultS, *result = &resultS;
- result->val = prefixVal;
- result->rows = rows;
- result->maxrows = maxrows;
- result->my = my;
- result->retVal = &retVal;
- result->isReady = &isReady;
- isReady = 1;
-
- for (i = 0 ; i < maxrows ; i++) {
- prefixVal[i] = malloc(PARAM_MAX_VALUE_LEN);
- }
- status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyStringsToAllocMem, result);
-#else
- status = ca_sg_array_get(pgid, ca_field_type(chan), ca_element_count(chan), chan, prefixVal);
-#endif
+ } else if (status != ECA_NORMAL) {
Param_strerror((Param *) my, ca_message(status));
-#ifndef SYNCHRONOUS_GROUP
+ retVal = -1;
+ } else {
do {
- ca_pend_event(TIMEOUTEVT);
- } while(isReady == 1);
-#else
- if((status = ca_sg_block(pgid, TIMEOUTSG)) == ECA_TIMEOUT) {
+ status = ca_pend_io(TIMEOUTIO);
+ } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
+ if (status != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ found = 0;
retVal = 0;
- *rows = 0;
- } else if (status == ECA_NORMAL) {
- retVal = 0;
- *rows = maxrows > ca_element_count(chan) ? ca_element_count(chan) : maxrows;
- } else {
- retVal = -1;
- *rows = 0;
}
- ca_sg_delete(pgid);
-#endif
-
- for (i = 0 ; i < *rows ; i++) {
- if (*prefixVal[i] == '/') {
- strcpy(val[i], prefixVal[i]);
- } else {
- strcpy(val[i], my->basedir);
- strcat(val[i], prefixVal[i]);
+ if (found == 1) {
+ ParamStringResult resultS, *result = &resultS;
+ result->val = prefixVal;
+ result->rows = rows;
+ result->maxrows = maxrows;
+ result->my = my;
+ result->retVal = &retVal;
+ result->isReady = &isReady;
+ isReady = 1;
+
+ for (i = 0 ; i < maxrows ; i++) {
+ prefixVal[i] = malloc(PARAM_MAX_VALUE_LEN);
+ }
+ status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyStringsToAllocMem, result);
+ Param_strerror((Param *) my, ca_message(status));
+ do {
+ ca_pend_event(TIMEOUTEVT);
+ } while(isReady == 1);
+
+ for (i = 0 ; i < *rows ; i++) {
+ if (*prefixVal[i] == '/') {
+ strcpy(val[i], prefixVal[i]);
+ } else {
+ strcpy(val[i], my->basedir);
+ strcat(val[i], prefixVal[i]);
+ }
+ }
+ for (i = 0 ; i < maxrows ; i++) {
+ free(prefixVal[i]);
}
}
- for (i = 0 ; i < maxrows ; i++) {
- free(prefixVal[i]);
+ if ((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
}
}
- if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
- }
+ pthread_mutex_unlock(((CaParam *) (my->specParam))->socketLock);
}
free(pPVName);
- if(maxrows == 1) {
+ if (maxrows == 1) {
Param_storeStringCache(my, name, idx, *val);
} else {
for (i = 0 ; i < *rows ; i++) {
int Param_getBlob(const Param *my, const char *name, const char *idx, size_t *size, FILE **val)
{
-#ifdef SYNCHRONOUS_GROUP
- CA_SYNC_GID pgid;
-#endif
int isReady;
int retVal = 0;
int status;
pPVName = malloc((strlen("HAD:PB:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
Param_returnPVName(my, "PB", name, idx, pPVName);
- if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
- Param_strerror((Param *) my, ca_message(status));
- found = 0;
- } else if (status != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
- retVal = -1;
- } else {
-#ifdef SYNCHRONOUS_GROUP
- ca_sg_create(&pgid);
-#endif
- do {
- status = ca_pend_io(TIMEOUTIO);
- } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
- if(status != ECA_NORMAL) {
+ if (0 == pthread_mutex_lock(((CaParam *) (my->specParam))->socketLock)) {
+ if ((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
Param_strerror((Param *) my, ca_message(status));
found = 0;
- retVal = 0;
- }
- if((*val = tmpfile()) == NULL) {
- Param_strerror((Param *) my, strerror(errno));
- found = 0;
+ } else if (status != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
retVal = -1;
- }
+ } else {
+ do {
+ status = ca_pend_io(TIMEOUTIO);
+ } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
+ if (status != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ found = 0;
+ retVal = 0;
+ }
+ if ((*val = tmpfile()) == NULL) {
+ Param_strerror((Param *) my, strerror(errno));
+ found = 0;
+ retVal = -1;
+ }
- if(found == 1) {
-#ifndef SYNCHRONOUS_GROUP
- ParamBlobResult resultS, *result = &resultS;
- result->val = val;
- result->size = size;
- result->my = my;
- result->retVal = &retVal;
- result->isReady = &isReady;
- isReady = 1;
-
- status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyBlobToAllocMem, result);
-#else
- status = ca_sg_array_get(pgid, ca_field_type(chan), ca_element_count(chan), chan, val);
-#endif
- Param_strerror((Param *) my, ca_message(status));
-#ifndef SYNCHRONOUS_GROUP
- do {
- ca_pend_event(TIMEOUTEVT);
- } while(isReady == 1);
-#else
- if((status = ca_sg_block(pgid, TIMEOUTSG)) == ECA_TIMEOUT) {
- retVal = 0;
- *size = 0;
- } else if (status == ECA_NORMAL) {
- retVal = 0;
- *size = ca_element_count(chan) * sizeof(DBR_LONG);
- } else {
- retVal = -1;
- *size = 0;
- }
- ca_sg_delete(pgid);
-#endif
- }
- if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
+ if (found == 1) {
+ ParamBlobResult resultS, *result = &resultS;
+ result->val = val;
+ result->size = size;
+ result->my = my;
+ result->retVal = &retVal;
+ result->isReady = &isReady;
+ isReady = 1;
+
+ status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyBlobToAllocMem, result);
+ Param_strerror((Param *) my, ca_message(status));
+ do {
+ ca_pend_event(TIMEOUTEVT);
+ } while(isReady == 1);
+ }
+ if ((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ }
}
+ pthread_mutex_unlock(((CaParam *) (my->specParam))->socketLock);
}
free(pPVName);
int Param_storeInt(const Param *my, const char *name, const char *idx, unsigned long int value)
{
-#ifdef SYNCHRONOUS_GROUP
- CA_SYNC_GID pgid;
-#endif
int retVal = 0;
int status;
int found = 1;
pPVName = malloc((strlen("HAD:PI:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
Param_returnPVName(my, "PI", name, idx, pPVName);
- if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
- Param_strerror((Param *) my, ca_message(status));
- found = 0;
- } else if (status != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
- retVal = -1;
- } else {
-#ifdef SYNCHRONOUS_GROUP
- ca_sg_create(&pgid);
-#endif
- do {
- status = ca_pend_io(TIMEOUTIO);
- } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
- if(status != ECA_NORMAL) {
+ if (0 == pthread_mutex_lock(((CaParam *) (my->specParam))->socketLock)) {
+ if ((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
Param_strerror((Param *) my, ca_message(status));
found = 0;
- retVal = 0;
- }
- if(found == 1) {
-#ifndef SYNCHRONOUS_GROUP
- ParamConfirmStoreStruct confirmS, *confirm = &confirmS;
- int isReady = 1;
- confirm->isReady = &isReady;
-
- status = ca_array_put_callback(DBR_LONG, 1, chan, &value, Param_confirmStore, confirm);
-#else
- status = ca_sg_array_put(pgid, DBR_LONG, 1, chan, &value);
-#endif
+ } else if (status != ECA_NORMAL) {
Param_strerror((Param *) my, ca_message(status));
-#ifndef SYNCHRONOUS_GROUP
+ retVal = -1;
+ } else {
do {
- ca_pend_event(TIMEOUTEVT);
- } while(isReady == 1);
-#else
- if((status = ca_sg_block(pgid, TIMEOUTSG)) == ECA_NORMAL) {
+ status = ca_pend_io(TIMEOUTIO);
+ } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
+ if (status != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ found = 0;
retVal = 0;
- } else {
- retVal = -1;
}
- ca_sg_delete(pgid);
-#endif
- }
+ if (found == 1) {
+ ParamConfirmStoreStruct confirmS, *confirm = &confirmS;
+ int isReady = 1;
+ confirm->isReady = &isReady;
+
+ status = ca_array_put_callback(DBR_LONG, 1, chan, &value, Param_confirmStore, confirm);
+ Param_strerror((Param *) my, ca_message(status));
+ do {
+ ca_pend_event(TIMEOUTEVT);
+ } while(isReady == 1);
+ }
- if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
+ if ((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ }
}
+ pthread_mutex_unlock(((CaParam *) (my->specParam))->socketLock);
}
free(pPVName);
int Param_storeString(const Param *my, const char *name, const char *idx, const char *value)
{
-#ifdef SYNCHRONOUS_GROUP
- CA_SYNC_GID pgid;
-#endif
int retVal = 0;
int status;
int found = 1;
pPVName = malloc((strlen("HAD:PS:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
Param_returnPVName(my, "PS", name, idx, pPVName);
- if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
- Param_strerror((Param *) my, ca_message(status));
- found = 0;
- } else if (status != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
- retVal = -1;
- } else {
-#ifdef SYNCHRONOUS_GROUP
- ca_sg_create(&pgid);
-#endif
- do {
- status = ca_pend_io(TIMEOUTIO);
- } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
- if(status != ECA_NORMAL) {
+ if (0 == pthread_mutex_lock(((CaParam *) (my->specParam))->socketLock)) {
+ if ((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
Param_strerror((Param *) my, ca_message(status));
found = 0;
- retVal = 0;
- }
- if(found == 1) {
-#ifndef SYNCHRONOUS_GROUP
- ParamConfirmStoreStruct confirmS, *confirm = &confirmS;
- int isReady = 1;
- confirm->isReady = &isReady;
-
- status = ca_array_put_callback(DBR_STRING, 1, chan, value, Param_confirmStore, confirm);
-#else
- status = ca_sg_array_put(pgid, DBR_STRING, 1, chan, &value);
-#endif
+ } else if (status != ECA_NORMAL) {
Param_strerror((Param *) my, ca_message(status));
-#ifndef SYNCHRONOUS_GROUP
+ retVal = -1;
+ } else {
do {
- ca_pend_event(TIMEOUTEVT);
- } while(isReady == 1);
-#else
- if((status = ca_sg_block(pgid, TIMEOUTSG)) == ECA_NORMAL) {
+ status = ca_pend_io(TIMEOUTIO);
+ } while ((ca_state(chan) != cs_conn) && (status != ECA_TIMEOUT));
+ if (status != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ found = 0;
retVal = 0;
- } else {
- retVal = -1;
}
- ca_sg_delete(pgid);
-#endif
- }
+ if (found == 1) {
+ ParamConfirmStoreStruct confirmS, *confirm = &confirmS;
+ int isReady = 1;
+ confirm->isReady = &isReady;
- if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
- Param_strerror((Param *) my, ca_message(status));
+ status = ca_array_put_callback(DBR_STRING, 1, chan, value, Param_confirmStore, confirm);
+ Param_strerror((Param *) my, ca_message(status));
+ do {
+ ca_pend_event(TIMEOUTEVT);
+ } while(isReady == 1);
+ }
+
+ if ((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+ Param_strerror((Param *) my, ca_message(status));
+ }
}
+ pthread_mutex_unlock(((CaParam *) (my->specParam))->socketLock);
}
free(pPVName);
*(result->rows) = (args.count > result->maxrows) ?
result->maxrows :
args.count;
- if(args.type == DBR_STRING && args.status == ECA_NORMAL) {
+ if (args.type == DBR_STRING && args.status == ECA_NORMAL) {
for(i = 0 ; i < *(result->rows) ; i++) {
strcpy((result->val)[i], buffer[i]);
}
if (args.count == 1) {
*(result->rows) = 1;
- if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
+ if (args.type == DBR_LONG && args.status == ECA_NORMAL) {
memcpy(result->val, buffer, sizeof(dbr_long_t));
} else {
Param_strerror((Param *) result->my, ca_message(args.status));
} else {
*(result->rows) = result->maxrows;
}
- if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
+ if (args.type == DBR_LONG && args.status == ECA_NORMAL) {
memcpy(result->val, buffer + 2, (sizeof(dbr_long_t) * *(result->rows)));
} else {
Param_strerror((Param *) result->my, ca_message(args.status));
{
ParamBlobResult *result = args.usr;
dbr_long_t *buffer = (dbr_long_t *) args.dbr;
- if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
+ if (args.type == DBR_LONG && args.status == ECA_NORMAL) {
*(result->size) = *buffer;
fwrite(buffer + 1, 1, *(result->size), *(result->val));
fflush(*(result->val));
static void Param_strerror(Param *my, const char *strerror)
{
my->strerror = realloc(my->strerror, strlen(strerror) + 1);
- if(my->strerror != NULL) {
+ if (my->strerror != NULL) {
strcpy(my->strerror, strerror);
}
}
strval[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
}
*rows = 0;
- if((retVal |= Param_getStringArrayCache(my, name, idx, maxrows, rows, strval)) == 0) {
+ if ((retVal |= Param_getStringArrayCache(my, name, idx, maxrows, rows, strval)) == 0) {
for (i = 0 ; i < *rows ; i++) {
val[i] = strtoul(strval[i], &endptr, 0);
if (*endptr != '\0') {
}
*rows = 0;
- if(Tcl_GetVar2(((CaParam *) (my->specParam))->cache, lname, lidx, 0) != 0) {
+ if (Tcl_GetVar2(((CaParam *) (my->specParam))->cache, lname, lidx, 0) != 0) {
strcpy(val[0], Tcl_GetVar2(((CaParam *) (my->specParam))->cache, lname, lidx, 0));
*rows = 1;
} else {
char index[PARAM_MAX_NAME_LEN];
for (i = 0 ; i < maxrows ; i++) {
sprintf(index,"%s%d", lidx, i);
- if(Tcl_GetVar2(((CaParam *) (my->specParam))->cache, lname, index, 0) != 0) {
+ if (Tcl_GetVar2(((CaParam *) (my->specParam))->cache, lname, index, 0) != 0) {
strcpy(val[i], Tcl_GetVar2(((CaParam *) (my->specParam))->cache, lname, index, 0));
(*rows)++;
} else {