Skip to content

Instantly share code, notes, and snippets.

@MicBrain
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MicBrain/437606e97e24982a83ae to your computer and use it in GitHub Desktop.
Save MicBrain/437606e97e24982a83ae to your computer and use it in GitHub Desktop.
WaitForNext() Function
JobInfo* MultiFetcher::WaitForNext() {
int index;
int timeout = -1;
int length = getJobInfoList().size();
download_mgr->watch_fds_ =
static_cast<struct pollfd *>(smalloc(length * sizeof(struct pollfd)));
download_mgr->watch_fds_size_ = length;
for (index = 0; index < length; index++) {
download_mgr->watch_fd_[index].fd = JobInfo[idx].pipe_fd
download_mgr->watch_fd_[index].events = POLLIN | POLLPRI;
download_mgr->watch_fd_[index].revents = 0;
}
download_mgr->watch_fds_inuse_ = length;
DOING SOME OPERATIONS TO FIGURE OUT A RANDOM INDEX FOR OUR JOBINFO OBJECT
int retval = poll(download_mgr->watch_fds_, download_mgr->watch_fds_inuse_,
timeout);
Failures result;
result = info->error_code;
if (result != kFailOk) {
LogCvmfs(kLogDownload, kLogDebug, "download failed (error %d - %s)", result,
Code2Ascii(result));
if (info->destination == kDestinationPath)
unlink(info->destination_path->c_str());
if (info->destination_mem.data) {
free(info->destination_mem.data);
info->destination_mem.data = NULL;
info->destination_mem.size = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment