- Added triple axis scan command.

- Introduced simulation mode to simdriv and simcter, i.e they never fail and
  finish at once.
- Started defining MAD compatibility commands in Tcl
- Fixed a bug in FOCUS_src which caused it to leak sockets.
- Introduced setsockopt SO_REUSEADDR to all new sockets in sinqhm in order
  to loose the next sinqhm error.
This commit is contained in:
cvs
2000-12-05 09:05:03 +00:00
parent e83d3e6946
commit 876396bb7e
22 changed files with 2000 additions and 58 deletions

View File

@@ -245,8 +245,12 @@
&FS_bytes_got, &FS_bytes_put, FS_name[index]);
if (!status || (ntohl (my_rply_bf.status) != KER__SUCCESS)) {
if (ntohl (my_rply_bf.status) != KER__SUCCESS) {
printf ("\n%s: error response to SQHM_CNCT request to %s.\n",
FS_name[index], FS_slaves[i]);
printf (
"\n%s: %s to %s.\n, status = %d, substatus = %d ",
"error response to SINQHM_CNCT",
FS_name[index], FS_slaves[i],
ntohl(my_rply_bf.status),
ntohl(my_rply_bf.sub_status));
}
*iret = -6; /* Tell our parent we've given up */
close (clnt_skt);
@@ -1765,14 +1769,77 @@
/*
**--------------------------------------------------------------------------
** FS_do_zero: Action routine for SQHM_ZERO command.
*
* This is only partially functional. The definition for SQHM_ZERO states
* that it is possible to zero only parts of the histogram. The version
* below just forwards a full zero request to all slaves and thus fits
* the bill for FOCUS. Probably for any other instrument as well.
*
* Mark Koennecke, November 2000
*/
int FS_do_zero (
/* ===========
*/ struct rply_buff_struct *reply,
int index,
int indx,
int nbins,
int first_bin,
int hist_no) {
int i, iret, all_ok = True;
struct req_buff_struct request;
/*
set up the request structure which zeros the whole histogram
*/
request.bigend = htonl(0x12345678);
request.cmnd = htonl(SQHM_ZERO);
request.u.zero.hist_no = htonl(-1);
request.u.zero.first_bin = htonl(-1);
request.u.zero.n_bins = htonl(-1);
/*
** Claim the sem to avoid race conditions with other threads
*/
if (FS_use_sem_tmo) {
iret = semTake (FS_sem_daq, FS_sem_tmo);
}else {
iret = semTake (FS_sem_daq, WAIT_FOREVER);
}
/*
send the request to all known slaves
*/
for (i = 0; i < FS_n_slaves; i++) {
if (FS_slv_active[i]) {
if (indx == 0) { /* If we are the master-server, send it to the
** master-servers in the slaves. */
iret = FS_send_cmnd_to_mstr (&FS_rmt_socknam[i],
&request, sizeof (request), reply,
&FS_bytes_got, &FS_bytes_put);
if (!iret || (ntohl (reply->status) != KER__SUCCESS)) all_ok=False;
}else {
iret = rqst_send_get (FS_skt[indx][i], &request, sizeof (request),
reply, sizeof (*reply),
&FS_bytes_got, &FS_bytes_put, FS_name[indx]);
if (!iret || (ntohl (reply->status) != KER__SUCCESS)) all_ok=False;
}
}
}
if (!all_ok) { /* If error, go no further! */
printf("Error zeroing histogram no %d\n", i);
semGive (FS_sem_daq);
return all_ok;
}
/*
tell the world about our success
*/
reply->status = htonl (KER__SUCCESS);
/* release semaphore */
semGive (FS_sem_daq);
return True;
}
/*
@@ -2134,7 +2201,7 @@
uint *in_cntr,
uint *out_cntr) {
int status, cnct_skt, rmt_sockname_len;
int status, cnct_skt, rmt_sockname_len, i;
int bytes_to_come, nbytes;
char *p_nxt_byte;
struct sockaddr_in lcl_sockname;
@@ -2142,12 +2209,20 @@
** Create a TCP/IP socket for connecting to SINQHM_SRV root and bind it.
*/
cnct_skt = socket (AF_INET, SOCK_STREAM, 0);
if (cnct_skt == -1) failInet ("\nFS_send_cmnd_to_mstr: socket error.");
i = 1;
setsockopt(cnct_skt,SOL_SOCKET, SO_REUSEADDR, &i,sizeof(int));
if (cnct_skt == -1) {
close(cnct_skt);
failInet ("\nFS_send_cmnd_to_mstr: socket error.");
}
setup_host (NULL, &lcl_sockname, 0, False);
status = bind (cnct_skt, (struct sockaddr *) &lcl_sockname,
sizeof (lcl_sockname));
if (status == -1) failInet ("\nFS_send_cmnd_to_mstr: bind error.");
if (status == -1){
close(cnct_skt);
failInet ("\nFS_send_cmnd_to_mstr: bind error.");
}
/*
** Connect to SINQHM_SRV root.
*/
@@ -2155,6 +2230,7 @@
status = connect (cnct_skt, (struct sockaddr *) rmt_sockname,
rmt_sockname_len);
if (status == -1) {
close(cnct_skt);
getErrno (&FS_errno);
failInet ("\nFS_send_cmnd_to_mstr: connect error");
}
@@ -2162,10 +2238,14 @@
** Send the request to the server
*/
status = send (cnct_skt, (char *) request, requ_len, 0);
if (status == -1) failInet ("\nFS_send_cmnd_to_mstr -- send error");
if (status == -1) {
close(cnct_skt);
failInet ("\nFS_send_cmnd_to_mstr -- send error");
}
if (status != requ_len) {
printf ("\nFS_send_cmnd_to_mstr -- wrong number of bytes sent: %d %d\n",
status, requ_len);
close(cnct_skt);
return False;
}
*out_cntr += requ_len;
@@ -2182,17 +2262,21 @@
p_nxt_byte += nbytes;
}
if (nbytes == -1) {
close(cnct_skt);
failInet ("\nFS_send_cmnd_to_mstr -- recv error");
return False;
}else if (nbytes == 0) {
printf ("\nFS_send_cmnd_to_mstr -- server has closed connection!\n");
close(cnct_skt);
return False;
}else if (ntohl (reply->bigend) != 0x12345678) {
/* Network byte-order wrong! */
printf ("\nFS_send_cmnd_to_mstr -- big-endian/little-endian problem!\n"
" Buffer received in non-network byte order!\n");
close(cnct_skt);
return False;
}
close(cnct_skt);
return True;
}
/*
@@ -2333,6 +2417,8 @@
" -- socket error in socket_bind"));
return skt;
}
status = 1;
setsockopt(skt,SOL_SOCKET, SO_REUSEADDR, &status, sizeof(int));
setup_host (NULL, &sockname, port, False);
status = bind (skt, (struct sockaddr *) &sockname, sizeof (sockname));
@@ -2513,6 +2599,8 @@
sprintf (buff, "\n%s -- Cnct-Socket socket error", FS_name[0]);
failInet (buff);
}
status = 1;
setsockopt(FS_cnct_skt, SOL_SOCKET, SO_REUSEADDR, &status, sizeof(int));
setup_host (NULL, &lcl_sockname, FS_port, False);
status = bind (FS_cnct_skt, (struct sockaddr *) &lcl_sockname,
sizeof (lcl_sockname));