예제 #1
0
파일: stepd_api.c 프로젝트: IFCA/slurm
/*
 *
 * Returns jobacctinfo_t struct on success, NULL on error.
 * jobacctinfo_t must be freed after calling this function.
 */
int
stepd_stat_jobacct(int fd, job_step_id_msg_t *sent, job_step_stat_t *resp)
{
	int req = REQUEST_STEP_STAT;
	int rc = SLURM_SUCCESS;
	int tasks = 0;

	debug("Entering stepd_stat_jobacct for job %u.%u",
	      sent->job_id, sent->step_id);
	safe_write(fd, &req, sizeof(int));

	/* Receive the jobacct struct and return */
	resp->jobacct = jobacctinfo_create(NULL);

	/* Do not attempt reading data until there is something to read.
	 * Avoid locking the jobacct_gather plugin early and creating
	 * possible deadlock. */
	if (wait_fd_readable(fd, 300))
		goto rwfail;
	rc = jobacctinfo_getinfo(resp->jobacct, JOBACCT_DATA_PIPE, &fd);

	safe_read(fd, &tasks, sizeof(int));
	resp->num_tasks = tasks;

	return rc;
rwfail:
	error("gathering job accounting: %d", rc);
	jobacctinfo_destroy(resp->jobacct);
	resp->jobacct = NULL;
	return rc;
}
예제 #2
0
파일: io_hdr.c 프로젝트: A1ve5/slurm
int
io_init_msg_read_from_fd(int fd, struct slurm_io_init_msg *msg)
{
	Buf buf;
	void *ptr;
	int n;

	xassert(msg);

	debug2("Entering io_init_msg_read_from_fd");
	if (wait_fd_readable(fd, 300)) {
		error("io_init_msg_read timed out");
		return SLURM_ERROR;
	}

	buf = init_buf(io_init_msg_packed_size());
	ptr = get_buf_data(buf);
again:
	if ((n = read(fd, ptr, io_init_msg_packed_size())) < 0) {
		if (errno == EINTR)
			goto again;
		free_buf(buf);
		return SLURM_ERROR;
	}
	if (n != io_init_msg_packed_size()) {
		error("io_init_msg_read too small");
		free_buf(buf);
		return SLURM_ERROR;
	}
	debug3("  read %d bytes", n);
	io_init_msg_unpack(msg, buf);

	free_buf(buf);

	debug2("Leaving  io_init_msg_read_from_fd");
	return SLURM_SUCCESS;
}