Diff for /libaitrpc/src/cli.c between versions 1.9.2.17 and 1.9.2.18

version 1.9.2.17, 2012/05/18 15:37:58 version 1.9.2.18, 2012/05/18 23:03:00
Line 290  rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short  Line 290  rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short 
   
         pfd.fd = cli->cli_sock;          pfd.fd = cli->cli_sock;
         pfd.events = POLLOUT;          pfd.events = POLLOUT;
           if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || 
                           pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
                   if (ret)
                           LOGERR;
                   else
                           rpc_SetErr(ETIMEDOUT, "Timeout, can't send to RPC server");
                   return -1;
           }
         do {          do {
                if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 ||                 if ((ret = send(cli->cli_sock, buf, wlen, MSG_NOSIGNAL)) == -1) {
                                pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {                        if (errno == EAGAIN)
                        if (ret) {                                continue;
                                if (errno == EAGAIN)                        LOGERR;
                                        continue; 
                                else 
                                        LOGERR; 
                        } else 
                                rpc_SetErr(ETIMEDOUT, "Timeout, can't send to RPC server"); 
                         return -1;                          return -1;
                   } else if (ret != wlen) {
                           rpc_SetErr(EPROCUNAVAIL, "RPC request, should be send %d bytes, "
                                           "really sended %d bytes", wlen, ret);
                           return -1;
                 }                  }
         } while (0);          } while (0);
         if ((ret = send(cli->cli_sock, buf, wlen, MSG_NOSIGNAL)) == -1) {  
                 LOGERR;  
                 return -1;  
         } else if (ret != wlen) {  
                 rpc_SetErr(EPROCUNAVAIL, "RPC request, should be send %d bytes, "  
                                 "really sended %d bytes", wlen, ret);  
                 return -1;  
         }  
   
         if (noreply)    /* we not want reply */          if (noreply)    /* we not want reply */
                 return 0;                  return 0;
Line 321  rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short  Line 320  rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short 
         do {          do {
                 if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 ||                   if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || 
                                 pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {                                  pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
                           if (ret)
                                   LOGERR;
                           else {
                                   if (wlen++ < 7)
                                           continue;
                                   else
                                           rpc_SetErr(ETIMEDOUT, "Timeout, no answer from RPC server");
                           }
                           return -1;
                   }
           } while (0);
           do {
                   memset(buf, 0, AIT_LEN(&cli->cli_buf));
                   if ((ret = recv(cli->cli_sock, buf, AIT_LEN(&cli->cli_buf), 0)) < 1) {
                         if (ret) {                          if (ret) {
                                 if (errno == EAGAIN)                                  if (errno == EAGAIN)
                                         continue;                                          continue;
                                 else                                  else
                                         LOGERR;                                          LOGERR;
                         } else {  
                                 if (wlen++ < 7)  
                                         continue;  
                                 else  
                                         rpc_SetErr(ETIMEDOUT, "Timeout, no answer from RPC server");  
                         }                          }
                         return -1;                          return -1;
                 }                  }
         } while (0);          } while (0);
         memset(buf, 0, AIT_LEN(&cli->cli_buf));  
         if ((ret = recv(cli->cli_sock, buf, AIT_LEN(&cli->cli_buf), 0)) < 1) {  
                 if (ret)  
                         LOGERR;  
                 return -1;  
         }  
         if (ret < sizeof(struct tagRPCCall)) {          if (ret < sizeof(struct tagRPCCall)) {
                rpc_SetErr(ERPCMISMATCH, "Short RPC packet");                rpc_SetErr(ERPCMISMATCH, "Short RPC packet %d bytes", ret);
                 return -1;                  return -1;
         }          }
   
         /* calculate CRC */          /* calculate CRC */
         crc = ntohs(rpc->call_crc);          crc = ntohs(rpc->call_crc);
         rpc->call_crc ^= rpc->call_crc;          rpc->call_crc ^= rpc->call_crc;
        if (crc != crcFletcher16((u_short*) buf, ret / 2)) {        if (crc != crcFletcher16((u_short*) buf, ntohs(rpc->call_len) / 2)) {
                 rpc_SetErr(ERPCMISMATCH, "Bad CRC RPC packet");                  rpc_SetErr(ERPCMISMATCH, "Bad CRC RPC packet");
                 return -1;                  return -1;
         }          }

Removed from v.1.9.2.17  
changed lines
  Added in v.1.9.2.18


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