Commit f41c80aa authored by koennecke's avatar koennecke
Browse files

Fixed a core dump with the new mongo code when not enough parameters were given

Added stick to the motors for TASP
Tried to fix an issue with AsynSrv regarding EAGAIN
parent 6a03dea6
......@@ -709,6 +709,19 @@ int AsynSrv_ChanClose(
AsynSrv_call_depth--;
return status;
}
/*-------------------------------------------------------------------------
A helper wrapper around recv which ignores EAGAIN
--------------------------------------------------------------------------*/
ssize_t recvI(int sockfd, void *buf, size_t len, int flags)
{
ssize_t status = 0;
do {
status = recv(sockfd,buf,len,flags);
} while(status <= 0 && errno ==EAGAIN);
return status;
}
/*
**---------------------------------------------------------------------------
......@@ -821,7 +834,7 @@ int AsynSrv_Close(
send(my_skt, "-001", 4, 0); /* Tell the TCP/IP server that ..
** .. we are about to quit.
*/
recv(my_skt, buff, sizeof(buff), 0); /* And wait for his ack */
recvI(my_skt, buff, sizeof(buff), 0); /* And wait for his ack */
close(my_skt);
for (j = i; j < AsynSrv_n_cnct; j++) {
memcpy((char *) &AsynSrv_HPS_list[j],
......@@ -1562,6 +1575,7 @@ int AsynSrv_OpenNew(
return True;
}
/*
**---------------------------------------------------------------------------
** AsynSrv_SendCmnds: Send commands to RS232C server.
......@@ -1702,7 +1716,7 @@ int AsynSrv_SendCmnds(
memset(rcve_buff, 0, sizeof(*rcve_buff));
size = sizeof(rcve_buff->msg_size);
memset(rcve_buff->msg_size, 0, size);
status = recv(asyn_info->skt, rcve_buff->msg_size, size, 0);
status = recvI(asyn_info->skt, rcve_buff->msg_size, size, 0);
if (status != size) {
GetErrno(&AsynSrv_errno, &AsynSrv_vaxc_errno);
if (status == 0) {
......@@ -1743,7 +1757,7 @@ int AsynSrv_SendCmnds(
bytes_left = bytes_to_come;
if (bytes_left > max_size)
bytes_left = max_size;
status = recv(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
status = recvI(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
if (status <= 0) {
AsynSrv_errcode = ASYNSRV__BAD_FLUSH; /* TCP/IP problem during flush */
GetErrno(&AsynSrv_errno, &AsynSrv_vaxc_errno);
......@@ -1761,7 +1775,7 @@ int AsynSrv_SendCmnds(
nxt_byte_ptr = &rcve_buff->msg_size[size];
bytes_left = bytes_to_come;
while (bytes_left > 0) { /* Read the rest of the response */
status = recv(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
status = recvI(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
if (status <= 0) {
GetErrno(&AsynSrv_errno, &AsynSrv_vaxc_errno);
if (status == 0) {
......@@ -1955,7 +1969,7 @@ int AsynSrv_SendCmndsBig(
}
size = sizeof(rcve_buff->msg_size);
status = recv(asyn_info->skt, rcve_buff->msg_size, size, 0);
status = recvI(asyn_info->skt, rcve_buff->msg_size, size, 0);
if (status != size) {
GetErrno(&AsynSrv_errno, &AsynSrv_vaxc_errno);
if (status == 0) {
......@@ -1997,7 +2011,7 @@ int AsynSrv_SendCmndsBig(
bytes_left = bytes_to_come;
if (bytes_left > max_size)
bytes_left = max_size;
status = recv(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
status = recvI(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
if (status <= 0) {
AsynSrv_errcode = ASYNSRV__BAD_FLUSH; /* TCP/IP problem during flush */
GetErrno(&AsynSrv_errno, &AsynSrv_vaxc_errno);
......@@ -2016,7 +2030,7 @@ int AsynSrv_SendCmndsBig(
nxt_byte_ptr = &rcve_buff->msg_size[size];
bytes_left = bytes_to_come;
while (bytes_left > 0) { /* Read the rest of the response */
status = recv(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
status = recvI(asyn_info->skt, nxt_byte_ptr, bytes_left, 0);
if (status <= 0) {
GetErrno(&AsynSrv_errno, &AsynSrv_vaxc_errno);
if (status == 0) {
......@@ -2129,7 +2143,7 @@ int AsynSrv_SendSpecCmnd(
return False;
}
status = recv(asyn_info->skt, rply, 4, 0);
status = recvI(asyn_info->skt, rply, 4, 0);
if (status != 4) {
GetErrno(&AsynSrv_errno, &AsynSrv_vaxc_errno);
if (status == 0) {
......
......@@ -98,7 +98,7 @@ static int MongoConfigAction(SConnection * pCon, SicsInterp * pSics,
strtolower(argv[1]);
if(strcmp(argv[1],"open") == 0){
if(argc < 4){
if(argc < 5){
SCWrite(pCon,"ERROR: need mongourl, dbName and instrument parameters for open",eError);
return 0;
}
......
......@@ -156,8 +156,9 @@
#define DMF 136
#define DTEM 137
#define DSTICK 138
#define MAXPAR 138
#define MAXPAR 139
#define MAXADD 20
#define MAXEVAR 12
......
......@@ -66,6 +66,7 @@ char *tasMotorOrder[MAXMOT + 1] = { "a1",
"i8",
"mf",
"tem",
"stick",
NULL
};
......@@ -214,6 +215,7 @@ char *tasVariableOrder[MAXPAR + 1] = {
"pfz",
"dmf",
"dtem",
"dstick",
NULL
};
......
......@@ -15,7 +15,7 @@ extern char *tasMotorOrder[];
extern char *tasVariableOrder[];
/* maximum number of motors in the list */
#define MAXMOT 34
#define MAXMOT 35
/* offset to the currents, if available */
#define CURMOT 21
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment