コード例 #1
0
int aio_suspend(client_ctx_ptr ctx, giocb *giocbp, const timespec *timeout) {
  XXEnter();
  int r = 0;
  if (ctx == nullptr || giocbp == nullptr) {
    errno = EINVAL;
    XXExit();
    return (r = -1);
  }
  {
    if (timeout) {
      auto func = [&]() { return giocbp->request_->_signaled; };
      // TODO add func
      if (giocbp->request_->_cvp->wait_for(timeout) == std::cv_status::timeout) {
        r = ETIMEDOUT;
      }
    } else {
      giocbp->request_->_cvp->wait();
    }
  }
  if (r == ETIMEDOUT) {
    r = -1;
    errno = EAGAIN;
    GLOG_DEBUG("TimeOut");
  } else if (giocbp->request_->_failed) {
    errno = giocbp->request_->_errno;
    r = -1;
  }
  XXExit();
  return r;
}
コード例 #2
0
ファイル: scalix-utils.c プロジェクト: GNOME/evolution-scalix
/* This function is stolen from E-D-S */
char *
path_from_uri (const char *uri)
{
    char *mangled_uri, *path;
    int i;

    /* mangle the URI to not contain invalid characters */
    mangled_uri = g_strdup (uri);

    for (i = 0; i < strlen (mangled_uri); i++) {
        switch (mangled_uri[i]) {
        case ':':
        case '/':
            mangled_uri[i] = '_';
        }
    }

    /* generate the file name */
    path = g_build_path (G_DIR_SEPARATOR_S,
                         g_get_home_dir (),
                         ".evolution", "cache", "scalix", mangled_uri, NULL);

    GLOG_DEBUG ("path [from uri: %s] = %s", uri, path);
    /* free memory */
    g_free (mangled_uri);

    return path;
}
コード例 #3
0
int aio_suspendv(client_ctx_ptr ctx, const std::vector<giocb *> &giocbp_vec,
                 const timespec *timeout) {
  XXEnter();
  int r = 0;
  if (ctx == nullptr || giocbp_vec.size() == 0) {
    errno = EINVAL;
    XXExit();
    return (r = -1);
  }

  auto cvp = giocbp_vec[0]->request_->_cvp;

  {
    if (timeout) {
      // TODO add func
      if (cvp->wait_for(timeout) == std::cv_status::timeout) {
        r = ETIMEDOUT;
      }
    } else {
      cvp->wait();
    }
  }

  if (r == ETIMEDOUT) {
    r = -1;
    errno = EAGAIN;
    GLOG_DEBUG("TimeOut");
  }

  for (auto& elem : giocbp_vec) {
    if (elem->request_->_failed) {
      // break out on first error
      // let caller check individual error codes using aio_return
      errno = elem->request_->_errno;
      r = -1;
      break;
    }
  }
  XXExit();
  return r;
}