Diff for /libaitrpc/src/blob.c between versions 1.7 and 1.7.2.3

version 1.7, 2012/05/14 08:39:05 version 1.7.2.3, 2012/05/16 08:20:26
Line 47  SUCH DAMAGE. Line 47  SUCH DAMAGE.
   
   
 /*  /*
 * rpc_srv_blobCreate() - Create map blob to memory region and return object * rpc_srv_blobCreate() - Create and map blob to memory region and return object
  *   *
  * @srv = RPC Server instance   * @srv = RPC Server instance
  * @len = BLOB length object   * @len = BLOB length object
Line 81  again: Line 81  again:
                 LOGERR;                  LOGERR;
                 return NULL;                  return NULL;
         }          }
        if (lseek(f, len - 1, SEEK_SET) == -1) {        if (ftruncate(f, len) == -1) {
                 LOGERR;                  LOGERR;
                 close(f);                  close(f);
                 unlink(szFName);                  unlink(szFName);
                 return NULL;                  return NULL;
        } else        }
                write(f, "", 1); 
   
         blob = malloc(sizeof(rpc_blob_t));          blob = malloc(sizeof(rpc_blob_t));
         if (!blob) {          if (!blob) {
Line 166  rpc_srv_blobMap(rpc_srv_t * __restrict srv, rpc_blob_t Line 165  rpc_srv_blobMap(rpc_srv_t * __restrict srv, rpc_blob_t
 inline void  inline void
 rpc_srv_blobUnmap(rpc_blob_t * __restrict blob)  rpc_srv_blobUnmap(rpc_blob_t * __restrict blob)
 {  {
        if (!blob || !blob->blob_data)        if (blob && blob->blob_data) {
                rpc_SetErr(EINVAL, "Invalid arguments"); 
        else { 
                 munmap(blob->blob_data, blob->blob_len);                  munmap(blob->blob_data, blob->blob_len);
                 blob->blob_data = NULL;                  blob->blob_data = NULL;
         }          }
Line 189  rpc_srv_blobFree(rpc_srv_t * __restrict srv, rpc_blob_ Line 186  rpc_srv_blobFree(rpc_srv_t * __restrict srv, rpc_blob_
         if (!blob) {          if (!blob) {
                 rpc_SetErr(EINVAL, "Invalid argument BLOB");                  rpc_SetErr(EINVAL, "Invalid argument BLOB");
                 return -1;                  return -1;
        }        } else
 
        if (blob->blob_data) 
                 rpc_srv_blobUnmap(blob);                  rpc_srv_blobUnmap(blob);
   
         memset(szFName, 0, sizeof szFName);          memset(szFName, 0, sizeof szFName);
Line 204  rpc_srv_blobFree(rpc_srv_t * __restrict srv, rpc_blob_ Line 199  rpc_srv_blobFree(rpc_srv_t * __restrict srv, rpc_blob_
         return 0;          return 0;
 }  }
   
// ------------------------------------------------------------/* ------------------------------------------------------------ */
   
 /*  /*
  * rpc_srv_sendBLOB() - Send mapped BLOB to client   * rpc_srv_sendBLOB() - Send mapped BLOB to client
Line 225  rpc_srv_sendBLOB(rpc_cli_t * __restrict cli, rpc_blob_ Line 220  rpc_srv_sendBLOB(rpc_cli_t * __restrict cli, rpc_blob_
         }          }
   
         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) {
                len = send(cli->cli_sock, pos, ret, 0);                len = send(cli->cli_sock, pos, ret, MSG_NOSIGNAL);
                 if (len == -1) {                  if (len == -1) {
                         LOGERR;                          LOGERR;
                         return -1;                          return -1;
Line 257  rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_ Line 252  rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
         pfd.fd = cli->cli_sock;          pfd.fd = cli->cli_sock;
         pfd.events = POLLIN | POLLPRI;          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) {
                if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 ||                 if ((len = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || 
                                 pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {                                  pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
                         LOGERR;                          LOGERR;
                         return -1;                          return -1;
Line 273  rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_ Line 268  rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
         return ret;          return ret;
 }  }
   
// ------------------------------------------------------------/* ------------------------------------------------------------ */
   
 /*  /*
  * rpc_cli_sendBLOB() - Send BLOB to server   * rpc_cli_sendBLOB() - Send BLOB to server
Line 321  rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t Line 316  rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
         /* wait for reply */          /* wait for reply */
         pfd.fd = cli->cli_sock;          pfd.fd = cli->cli_sock;
         pfd.events = POLLIN | POLLPRI;          pfd.events = POLLIN | POLLPRI;
        if ((ret = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_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)                  if (ret)
                         LOGERR;                          LOGERR;
Line 402  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t Line 397  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
         pfd.fd = cli->cli_sock;          pfd.fd = cli->cli_sock;
         pfd.events = POLLIN | POLLPRI;          pfd.events = POLLIN | POLLPRI;
         for (ret = AIT_LEN(var), pos = *data; ret > 0; ret -= len, pos += len) {          for (ret = AIT_LEN(var), pos = *data; ret > 0; ret -= len, pos += len) {
                if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 ||                 if ((len = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || 
                                 pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {                                  pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
                         LOGERR;                          LOGERR;
                         free(*data);                          free(*data);
Line 419  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t Line 414  rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
         }          }
   
         /* wait for reply */          /* wait for reply */
        if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 ||         if ((len = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || 
                         pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {                          pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
                 if (len)                  if (len)
                         LOGERR;                          LOGERR;
Line 493  rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t  Line 488  rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t 
         /* wait for reply */          /* wait for reply */
         pfd.fd = cli->cli_sock;          pfd.fd = cli->cli_sock;
         pfd.events = POLLIN | POLLPRI;          pfd.events = POLLIN | POLLPRI;
        if ((ret = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_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)                  if (ret)
                         LOGERR;                          LOGERR;

Removed from v.1.7  
changed lines
  Added in v.1.7.2.3


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