]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
debug crash test
authorhadaq <hadaq>
Tue, 26 Oct 2010 15:28:07 +0000 (15:28 +0000)
committerhadaq <hadaq>
Tue, 26 Oct 2010 15:28:07 +0000 (15:28 +0000)
trbnetd/server/trbnetd.c
trbnetd/trbnetrpc.c

index ff73fdeab2b935cd9ba90e065ffe41a854acfc00..5019e4621d5985f75cffae1205b8e01d070eb1ab 100644 (file)
@@ -17,11 +17,9 @@ int trbnetrpcprog_1_freeresult(SVCXPRT * transp,
                                xdrproc_t xdr_result, caddr_t result)
 {
   xdr_free(xdr_result, result);
-
   /*
    * Insert additional freeing code here, if needed
    */
-
   return 1;
 }
 
@@ -45,7 +43,10 @@ bool_t register_read_1_svc(uint16_t trb_address,
   /* allocate buffer memory */
   retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize);
   if (retVal->data.Buffer_val == NULL) {
-    return FALSE;
+    fprintf(stderr, "register_read: malloc failed\n");
+    retVal->status.retVal = -1;
+    retVal->status.trb_errno = TRB_RPC_ERROR;
+    return TRUE;
   }
   
   status = trb_register_read(trb_address, reg_address,
@@ -64,13 +65,17 @@ bool_t registertime_read_1_svc(uint16_t trb_address,
                                struct svc_req * rqstp)
 {
   int status;
-  
+  fprintf(stderr, "read: Len: %d, dsize: %d\n",
+          retVal->data.Buffer_len, dsize);
   /* allocate buffer memory */
   retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize);
   if (retVal->data.Buffer_val == NULL) {
-    return FALSE;
+    fprintf(stderr, "registertime_read: malloc failed\n");
+    retVal->status.trb_errno = TRB_RPC_ERROR;
+    retVal->status.retVal = -1;
+    return TRUE;
   }
-  
+
   status = trb_registertime_read(trb_address, reg_address,
                                  (uint32_t *) retVal->data.Buffer_val, dsize);
   retVal->data.Buffer_len = status == -1 ? 0 : status;
@@ -92,9 +97,13 @@ bool_t register_read_mem_1_svc(uint16_t trb_address,
 
   /* allocate buffer memory */
   retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize);
-  if (retVal->data.Buffer_val == NULL)
-    return FALSE;
-
+  if (retVal->data.Buffer_val == NULL) {
+    fprintf(stderr, "register_read_mem: malloc failed\n");
+    retVal->status.trb_errno = TRB_RPC_ERROR;
+    retVal->status.retVal = -1;
+    return TRUE;
+  }
+  
   status = trb_register_read_mem(trb_address, reg_address, option, size,
                                  (uint32_t *) retVal->data.Buffer_val, dsize);
 
@@ -117,8 +126,12 @@ bool_t registertime_read_mem_1_svc(uint16_t trb_address,
 
   /* allocate buffer memory */
   retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize);
-  if (retVal->data.Buffer_val == NULL)
-    return FALSE;
+  if (retVal->data.Buffer_val == NULL) {
+    fprintf(stderr, "registertime_read_mem: malloc failed\n");
+    retVal->status.trb_errno = TRB_RPC_ERROR;
+    retVal->status.retVal = -1;
+    return TRUE;
+  }
 
   status = trb_registertime_read_mem(trb_address, reg_address, option, size,
                                  (uint32_t *) retVal->data.Buffer_val, dsize);
@@ -163,18 +176,26 @@ bool_t read_uid_1_svc(uint16_t trb_address,
                       struct svc_req* rqstp)
 {
   int status;
+
   /* allocate buffer memory */
-  retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize);
+  retVal->data.Buffer_val = NULL;
+  retVal->data.Buffer_len = 0;
+  retVal->data.Buffer_val = (uint32_t*)malloc(sizeof(uint32_t) * dsize);
+  
   if (retVal->data.Buffer_val == NULL) {
-    return FALSE;
+    fprintf(stderr, "read_uid: malloc failed\n");
+    retVal->status.trb_errno = TRB_RPC_ERROR;
+    retVal->status.retVal = -1;
+    return TRUE;
   }
-  
+    
   status = trb_read_uid(trb_address, 
                         (uint32_t*)retVal->data.Buffer_val,
                         dsize);
   retVal->status.retVal = status;
   retVal->data.Buffer_len = status == -1 ? 0 : status;
   copyStatus(&retVal->status);
+  
   return TRUE;
 }
 
@@ -239,8 +260,12 @@ bool_t ipu_data_read_1_svc(uint8_t type,
   
   /* allocate buffer memory */
   retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize);
-  if (retVal->data.Buffer_val == NULL)
-    return FALSE;
+  if (retVal->data.Buffer_val == NULL) {
+    fprintf(stderr, "ipu_data_read: malloc failed\n");
+    retVal->status.trb_errno = TRB_RPC_ERROR;
+    retVal->status.retVal = -1;
+    return TRUE;
+  }
 
   status = trb_ipu_data_read(type, trg_info, trg_random, trg_number,
                              (uint32_t *)retVal->data.Buffer_val, dsize);
@@ -260,8 +285,12 @@ bool_t fpga_register_read_1_svc(uint16_t reg_address,
   
   /* allocate buffer memory */
   retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * 1);
-  if (retVal->data.Buffer_val == NULL)
-    return FALSE;
+  if (retVal->data.Buffer_val == NULL) {
+    fprintf(stderr, "fpga_register_read: malloc failed\n");
+    retVal->status.trb_errno = TRB_RPC_ERROR;
+    retVal->status.retVal = -1;
+    return TRUE;
+  }
   
   status = fpga_register_read(reg_address,
                               (uint32_t *)retVal->data.Buffer_val);
@@ -319,8 +348,7 @@ bool_t register_modify_1_svc(uint16_t trb_address,
   return TRUE; 
 }
 
-void trbnetrpcprog_1(struct svc_req *rqstp, register SVCXPRT * transp);
-
+extern void trbnetrpcprog_1(struct svc_req *rqstp, register SVCXPRT * transp);
 
 /* ------ MAIN ---------------------------------------------------------- */
 
index 042fe2a3658786f1a0f51628b913862121d7bc9b..c229dca3fcde213c19ef79de23aea136c7d3962c 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "trbnet.h"
 
-const char trbnet_version[] = "$Revision: 1.4 $";
+const char trbnet_version[] = "$Revision: 1.5 $";
 unsigned int trb_debug = 0;
 unsigned int trb_dma = 0;
 
@@ -68,7 +68,6 @@ int trb_register_read(uint16_t trb_address,
   status =
     register_read_1(trb_address, reg_address, dsize, 
                     &retVal, trb_client);
-  copyStatus(&retVal.status);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -78,7 +77,8 @@ int trb_register_read(uint16_t trb_address,
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal.status);
   return retVal.status.retVal;
 }
 
@@ -97,7 +97,6 @@ int trb_registertime_read(uint16_t trb_address,
   status =
     registertime_read_1(trb_address, reg_address, dsize, 
                         &retVal, trb_client);
-  copyStatus(&retVal.status);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -107,7 +106,8 @@ int trb_registertime_read(uint16_t trb_address,
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal.status);
   return retVal.status.retVal;
 }
 
@@ -129,7 +129,6 @@ int trb_register_read_mem(uint16_t trb_address,
   status =
     register_read_mem_1(trb_address, reg_address, option, size, dsize,
                         &retVal, trb_client);
-  copyStatus(&retVal.status);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -140,6 +139,7 @@ int trb_register_read_mem(uint16_t trb_address,
     return -1;
   }
   
+  copyStatus(&retVal.status);
   return retVal.status.retVal;
 }
 
@@ -161,7 +161,6 @@ int trb_registertime_read_mem(uint16_t trb_address,
   status =
     registertime_read_mem_1(trb_address, reg_address, option, size, dsize,
                             &retVal, trb_client);
-  copyStatus(&retVal.status);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -171,7 +170,8 @@ int trb_registertime_read_mem(uint16_t trb_address,
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal.status);
   return retVal.status.retVal;
 }
 
@@ -189,7 +189,6 @@ int trb_read_uid(uint16_t trb_address,
   retVal.data.Buffer_len = dsize;
   
   status = read_uid_1(trb_address, dsize, &retVal, trb_client);
-  copyStatus(&retVal.status);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -200,6 +199,7 @@ int trb_read_uid(uint16_t trb_address,
     return -1;
   }
   
+  copyStatus(&retVal.status);
   return retVal.status.retVal;
 }
 
@@ -215,8 +215,7 @@ int trb_register_write(uint16_t trb_address,
 
   status = register_write_1(trb_address, reg_address, value,
                             &retVal, trb_client);
-  copyStatus(&retVal);
-  
+    
   if (status != RPC_SUCCESS) {
     /*
      * An error occurred while calling the server.
@@ -226,6 +225,7 @@ int trb_register_write(uint16_t trb_address,
     return -1;
   }
   
+  copyStatus(&retVal);
   return retVal.retVal;
 }
 
@@ -246,7 +246,6 @@ int trb_register_write_mem(uint16_t trb_address,
   
   status = register_write_mem_1(trb_address, reg_address, option, buffer,
                                 &retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -256,7 +255,8 @@ int trb_register_write_mem(uint16_t trb_address,
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal);
   return retVal.retVal;
 }
 
@@ -271,7 +271,6 @@ int trb_set_address(uint64_t uid,
 
   status = set_address_1(uid, endpoint, trb_address,
                          &retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -282,6 +281,7 @@ int trb_set_address(uint64_t uid,
     return -1;
   }
   
+  copyStatus(&retVal);
   return retVal.retVal;
 }
 
@@ -304,7 +304,6 @@ int trb_ipu_data_read(uint8_t type,
   status =
     ipu_data_read_1(type, trg_info, trg_random, trg_number, dsize,
                     &retVal, trb_client);
-  copyStatus(&retVal.status);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -314,7 +313,8 @@ int trb_ipu_data_read(uint8_t type,
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal.status);
   return retVal.status.retVal;
 }
 
@@ -329,7 +329,6 @@ int trb_send_trigger(uint8_t type,
   if (trb_client == NULL) return -1;
   
   status = send_trigger_1(type, info, random, number, &retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -340,6 +339,7 @@ int trb_send_trigger(uint8_t type,
     return -1;
   }
   
+  copyStatus(&retVal);
   return retVal.retVal; 
 }
 
@@ -356,7 +356,6 @@ int trb_send_trigger_rich(uint8_t input,
   
   status = send_trigger_rich_1(input, type, info, random, number,
                                &retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -366,7 +365,8 @@ int trb_send_trigger_rich(uint8_t input,
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal);
   return retVal.retVal; 
 }
 
@@ -384,7 +384,6 @@ int fpga_register_write(uint16_t reg_address, uint32_t value)
   if (trb_client == NULL) return -1;
   
   status = fpga_register_write_1(reg_address, value, &retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -394,7 +393,8 @@ int fpga_register_write(uint16_t reg_address, uint32_t value)
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal);
   return retVal.retVal; 
 }
 
@@ -406,7 +406,6 @@ int trb_fifo_flush(uint8_t channel)
   if (trb_client == NULL) return -1;
   
   status = trb_fifo_flush_1(channel, &retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -416,7 +415,8 @@ int trb_fifo_flush(uint8_t channel)
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal);
   return retVal.retVal;
 }
 
@@ -428,7 +428,6 @@ int network_reset()
   if (trb_client == NULL) return -1;
 
   status = network_reset_1(&retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -438,7 +437,8 @@ int network_reset()
     clnt_perror(trb_client, trb_server);
     return -1;
   }
-  
+
+  copyStatus(&retVal);
   return retVal.retVal;
 }
 
@@ -461,7 +461,6 @@ int trb_register_modify(uint16_t trb_address,
   status =
     register_modify_1(trb_address, reg_address, mode, bitMask, bitValue, 
                       &retVal, trb_client);
-  copyStatus(&retVal);
   
   if (status != RPC_SUCCESS) {
     /*
@@ -472,5 +471,6 @@ int trb_register_modify(uint16_t trb_address,
     return -1;
   }
   
+  copyStatus(&retVal);
   return retVal.retVal;
 }