Diff for /libaitrpc/src/blob.c between versions 1.4.4.2 and 1.6.2.1

version 1.4.4.2, 2012/03/14 23:15:33 version 1.6.2.1, 2012/05/11 09:18:13
Line 247  rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_ Line 247  rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
 {  {
         int ret, len;          int ret, len;
         uint8_t *pos;          uint8_t *pos;
        fd_set fds;        struct pollfd pfd;
        struct timeval tv = { DEF_RPC_TIMEOUT, 0 }; 
   
         if (!cli || !blob || !blob->blob_data) {          if (!cli || !blob || !blob->blob_data) {
                 rpc_SetErr(EINVAL, "Invalid arguments");                  rpc_SetErr(EINVAL, "Invalid arguments");
                 return -1;                  return -1;
        } else        }
                tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout; 
   
           pfd.fd = cli->cli_sock;
           pfd.events = POLLIN | POLLPRI;
         for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) {          for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) {
                FD_ZERO(&fds);                if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) == -1 || 
                FD_SET(cli->cli_sock, &fds);                                pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
                len = select(cli->cli_sock + 1, &fds, NULL, NULL, &tv); 
                if (len < 1) { 
                         LOGERR;                          LOGERR;
                         return -1;                          return -1;
                 }                  }
Line 300  rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t Line 298  rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
         } else          } else
                 tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout;                  tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout;
   
        memcpy(&hdr.hdr_session, cli->cli_parent, sizeof(rpc_sess_t));        rpc_addPktSession(&hdr.hdr_session, cli->cli_parent);
         hdr.hdr_cmd = set;          hdr.hdr_cmd = set;
         hdr.hdr_var = 0;          hdr.hdr_var = 0;
         hdr.hdr_ret = 0;          hdr.hdr_ret = 0;
        hdr.hdr_len = htons(AIT_LEN(var));        hdr.hdr_len = htonl(AIT_LEN(var));
         /* calculate CRC */          /* calculate CRC */
         hdr.hdr_crc ^= hdr.hdr_crc;          hdr.hdr_crc ^= hdr.hdr_crc;
        hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, ((sizeof hdr + 1) & ~1) / 2));        hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, sizeof hdr / 2));
   
         /* send SET request */          /* send SET request */
         if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) {          if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) {
Line 340  rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t Line 338  rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
         /* check CRC */          /* check CRC */
         ret = ntohs(hdr.hdr_crc);          ret = ntohs(hdr.hdr_crc);
         hdr.hdr_crc ^= hdr.hdr_crc;          hdr.hdr_crc ^= hdr.hdr_crc;
        if (ret != crcFletcher16((u_short*) &hdr, ((sizeof hdr + 1) & ~1) / 2)) {        if (ret != crcFletcher16((u_short*) &hdr, sizeof hdr / 2)) {
                 rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");                  rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");
                 return 1;                  return 1;
         }          }
Line 387  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t Line 385  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
         } else          } else
                 memset(*data, 0, AIT_LEN(var));                  memset(*data, 0, AIT_LEN(var));
   
        memcpy(&hdr.hdr_session, cli->cli_parent, sizeof(rpc_sess_t));        rpc_addPktSession(&hdr.hdr_session, cli->cli_parent);
         hdr.hdr_cmd = get;          hdr.hdr_cmd = get;
         hdr.hdr_var = htonl((uint32_t) AIT_GET_BLOB(var));          hdr.hdr_var = htonl((uint32_t) AIT_GET_BLOB(var));
         hdr.hdr_ret = 0;          hdr.hdr_ret = 0;
         hdr.hdr_len = 0;          hdr.hdr_len = 0;
         /* calculate CRC */          /* calculate CRC */
         hdr.hdr_crc ^= hdr.hdr_crc;          hdr.hdr_crc ^= hdr.hdr_crc;
        hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, ((sizeof hdr + 1) & ~1) / 2));        hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, sizeof hdr / 2));
   
         /* send GET request */          /* send GET request */
         if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) {          if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) {
Line 448  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t Line 446  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
         /* check CRC */          /* check CRC */
         ret = ntohs(hdr.hdr_crc);          ret = ntohs(hdr.hdr_crc);
         hdr.hdr_crc ^= hdr.hdr_crc;          hdr.hdr_crc ^= hdr.hdr_crc;
        if (ret != crcFletcher16((u_short*) &hdr, ((sizeof hdr + 1) & ~1) / 2)) {        if (ret != crcFletcher16((u_short*) &hdr, sizeof hdr / 2)) {
                 rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");                  rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");
                 free(*data);                  free(*data);
                 *data = NULL;                  *data = NULL;
Line 487  rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t  Line 485  rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t 
         } else          } else
                 tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout;                  tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout;
   
        memcpy(&hdr.hdr_session, cli->cli_parent, sizeof(rpc_sess_t));        rpc_addPktSession(&hdr.hdr_session, cli->cli_parent);
         hdr.hdr_cmd = unset;          hdr.hdr_cmd = unset;
         hdr.hdr_var = htonl((uint32_t) AIT_GET_BLOB(var));          hdr.hdr_var = htonl((uint32_t) AIT_GET_BLOB(var));
         hdr.hdr_ret = 0;          hdr.hdr_ret = 0;
         hdr.hdr_len = 0;          hdr.hdr_len = 0;
         /* calculate CRC */          /* calculate CRC */
         hdr.hdr_crc ^= hdr.hdr_crc;          hdr.hdr_crc ^= hdr.hdr_crc;
        hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, ((sizeof hdr + 1) & ~1) / 2));        hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, sizeof hdr / 2));
   
         /* send UNSET request */          /* send UNSET request */
         if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) {          if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) {
Line 520  rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t  Line 518  rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t 
         /* check CRC */          /* check CRC */
         ret = ntohs(hdr.hdr_crc);          ret = ntohs(hdr.hdr_crc);
         hdr.hdr_crc ^= hdr.hdr_crc;          hdr.hdr_crc ^= hdr.hdr_crc;
        if (ret != crcFletcher16((u_short*) &hdr, ((sizeof hdr + 1) & ~1) / 2)) {        if (ret != crcFletcher16((u_short*) &hdr, sizeof hdr / 2)) {
                 rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");                  rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");
                 return 1;                  return 1;
         }          }

Removed from v.1.4.4.2  
changed lines
  Added in v.1.6.2.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>