Skip to content
Snippets Groups Projects
slurm_protocol_pack.c 65.3 KiB
Newer Older
	pack32_array(msg->global_task_ids,
		     msg->tasks_to_launch, buffer);
tewk's avatar
tewk committed
#ifdef HAVE_LIBELAN3
	qsw_pack_jobinfo(msg->qsw_job, buffer);
tewk's avatar
tewk committed
#endif
static int
_unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **
				 msg_ptr, Buf buffer)
{
	uint16_t uint16_tmp;
	launch_tasks_request_msg_t *msg;

	msg = xmalloc(sizeof(launch_tasks_request_msg_t));
	*msg_ptr = msg;

	safe_unpack32(&msg->job_id, buffer);
	safe_unpack32(&msg->job_step_id, buffer);
	safe_unpack32(&msg->nnodes, buffer);
	safe_unpack32(&msg->nprocs, buffer);
	safe_unpack32(&msg->uid, buffer);
	safe_unpack32(&msg->srun_node_id, buffer);
	if (unpack_job_credential(&msg->credential, buffer))
	safe_unpack32(&msg->tasks_to_launch, buffer);
	safe_unpackstr_array(&msg->env, &msg->envc, buffer);
	safe_unpackstr_xmalloc(&msg->cwd, &uint16_tmp, buffer);
	safe_unpackstr_array(&msg->argv, &msg->argc, buffer);
	safe_unpack16(&msg->resp_port, buffer);
	safe_unpack16(&msg->io_port, buffer);
	safe_unpack16(&msg->task_flags, buffer);
	safe_unpackstr_xmalloc(&msg->ofname, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&msg->efname, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&msg->ifname, &uint16_tmp, buffer);
	safe_unpack32_array(&msg->global_task_ids, &uint32_tmp, buffer);
tewk's avatar
tewk committed
#ifdef HAVE_LIBELAN3
	qsw_alloc_jobinfo(&msg->qsw_job);
	if (qsw_unpack_jobinfo(msg->qsw_job, buffer) < 0) {
		error("qsw_unpack_jobinfo: %m");
tewk's avatar
tewk committed
#endif
	return SLURM_SUCCESS;
	slurm_free_launch_tasks_request_msg(msg);
	*msg_ptr = NULL;
	return SLURM_ERROR;
static void
_pack_cancel_tasks_msg(kill_tasks_msg_t * msg, Buf buffer)
	pack32(msg->job_id, buffer);
	pack32(msg->job_step_id, buffer);
	pack32(msg->signal, buffer);
static int
_unpack_cancel_tasks_msg(kill_tasks_msg_t ** msg_ptr, Buf buffer)
	kill_tasks_msg_t *msg;
	msg = xmalloc(sizeof(kill_tasks_msg_t));
	*msg_ptr = msg;
	safe_unpack32(&msg->job_id, buffer);
	safe_unpack32(&msg->job_step_id, buffer);
	safe_unpack32(&msg->signal, buffer);
	return SLURM_SUCCESS;
      unpack_error:
	xfree(msg);
	*msg_ptr = NULL;
	return SLURM_ERROR;
static void
_pack_shutdown_msg(shutdown_msg_t * msg, Buf buffer)
	pack16(msg->core, buffer);
static int
_unpack_shutdown_msg(shutdown_msg_t ** msg_ptr, Buf buffer)
	shutdown_msg_t *msg;
	msg = xmalloc(sizeof(shutdown_msg_t));
	*msg_ptr = msg;
	safe_unpack16(&msg->core, buffer);
	return SLURM_SUCCESS;
      unpack_error:
	xfree(msg);
	*msg_ptr = NULL;
	return SLURM_ERROR;

/* _pack_job_step_id_msg
 * packs a slurm job step id
 * IN msg - pointer to the job step id (contains job_id and job_step_id)
 * IN/OUT buffer - destination of the pack, contains pointers that are 
 *			automatically updated
 */
static void
_pack_job_step_id_msg(job_step_id_t * msg, Buf buffer)
	pack_time(msg->last_update, buffer);
	pack32(msg->job_id, buffer);
	pack32(msg->job_step_id, buffer);
/* _unpack_job_step_id_msg
 * unpacks a slurm job step id
 * OUT msg_ptr - pointer to the job step id buffer (contains job_id and   
 *			job_step_id)
 * IN/OUT buffer - source of the unpack, contains pointers that are 
 *			automatically updated
 */
static int
_unpack_job_step_id_msg(job_step_id_t ** msg_ptr, Buf buffer)
	job_step_id_msg_t *msg;
	msg = xmalloc(sizeof(job_step_id_msg_t));
	*msg_ptr = msg;
	safe_unpack_time(&msg->last_update, buffer);
	safe_unpack32(&msg->job_id, buffer);
	safe_unpack32(&msg->job_step_id, buffer);
	return SLURM_SUCCESS;
      unpack_error:
	xfree(msg);
	*msg_ptr = NULL;
	return SLURM_ERROR;
static void
_pack_complete_job_step_msg(complete_job_step_msg_t * msg, Buf buffer)
	pack32(msg->job_id, buffer);
	pack32(msg->job_step_id, buffer);
	pack32(msg->job_rc, buffer);
	pack32(msg->slurm_rc, buffer);
	packstr(msg->node_name, buffer);
static int
_unpack_complete_job_step_msg(complete_job_step_msg_t ** msg_ptr, Buf buffer)
	complete_job_step_msg_t *msg;
	msg = xmalloc(sizeof(complete_job_step_msg_t));
	*msg_ptr = msg;
	safe_unpack32(&msg->job_id, buffer);
	safe_unpack32(&msg->job_step_id, buffer);
	safe_unpack32(&msg->job_rc, buffer);
	safe_unpack32(&msg->slurm_rc, buffer);
	safe_unpackstr_xmalloc(&msg->node_name, &uint16_tmp, buffer);
	return SLURM_SUCCESS;
      unpack_error:
	xfree(msg);
static void
_pack_get_job_step_info_msg(job_step_info_request_msg_t * msg, Buf buffer)
	pack_time(msg->last_update, buffer);
	pack32(msg->job_id, buffer);
	pack32(msg->step_id, buffer);
static int
_unpack_get_job_step_info_msg(job_step_info_request_msg_t ** msg, Buf buffer)
	job_step_info_request_msg_t *job_step_info;
	job_step_info = xmalloc(sizeof(job_step_info_request_msg_t));
	safe_unpack_time(&job_step_info->last_update, buffer);
	safe_unpack32(&job_step_info->job_id, buffer);
	safe_unpack32(&job_step_info->step_id, buffer);
	return SLURM_SUCCESS;

      unpack_error:
	xfree(job_step_info);
static void
_pack_slurm_addr_array(slurm_addr * slurm_address,
		       uint16_t size_val, Buf buffer)
	uint16_t nl = htons(size_val);
	pack16(nl, buffer);
	for (i = 0; i < size_val; i++) {
		slurm_pack_slurm_addr(slurm_address + i, buffer);
static int
_unpack_slurm_addr_array(slurm_addr ** slurm_address,
			 uint16_t * size_val, Buf buffer)
	int i = 0;
	uint16_t nl;
	safe_unpack16(&nl, buffer);
	*size_val = ntohs(nl);
	*slurm_address = xmalloc((*size_val) * sizeof(slurm_addr));

	for (i = 0; i < *size_val; i++) {
		if (slurm_unpack_slurm_addr_no_alloc((*slurm_address) + i,
						     buffer))
		xfree(*slurm_address);
	*slurm_address = NULL;
	return SLURM_ERROR;
static void
_pack_batch_job_launch_msg(batch_job_launch_msg_t * msg, Buf buffer)
	assert(msg != NULL);
	pack32(msg->job_id, buffer);
	pack32(msg->uid, buffer);
	packstr(msg->nodes, buffer);
	packstr(msg->script, buffer);
	packstr(msg->work_dir, buffer);
	packstr(msg->err, buffer);
	packstr(msg->in, buffer);
	packstr(msg->out, buffer);
	pack16(msg->argc, buffer);
	packstr_array(msg->argv, msg->argc, buffer);
	pack16(msg->envc, buffer);
	packstr_array(msg->environment, msg->envc, buffer);
static int
_unpack_batch_job_launch_msg(batch_job_launch_msg_t ** msg, Buf buffer)
	batch_job_launch_msg_t *launch_msg_ptr;
	assert(msg != NULL);
	launch_msg_ptr = xmalloc(sizeof(batch_job_launch_msg_t));
	*msg = launch_msg_ptr;

	safe_unpack32(&launch_msg_ptr->job_id, buffer);
	safe_unpack32(&launch_msg_ptr->uid, buffer);

	safe_unpackstr_xmalloc(&launch_msg_ptr->nodes, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&launch_msg_ptr->script, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&launch_msg_ptr->work_dir, &uint16_tmp,
			       buffer);

	safe_unpackstr_xmalloc(&launch_msg_ptr->err, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&launch_msg_ptr->in, &uint16_tmp, buffer);
	safe_unpackstr_xmalloc(&launch_msg_ptr->out, &uint16_tmp, buffer);

	safe_unpack16(&launch_msg_ptr->argc, buffer);
	safe_unpackstr_array(&launch_msg_ptr->argv,
			     &launch_msg_ptr->argc, buffer);

	safe_unpack16(&launch_msg_ptr->envc, buffer);
	safe_unpackstr_array(&launch_msg_ptr->environment,
			     &launch_msg_ptr->envc, buffer);
      unpack_error:
	if (launch_msg_ptr->nodes)
		xfree(launch_msg_ptr->nodes);
	if (launch_msg_ptr->script)
		xfree(launch_msg_ptr->script);
	if (launch_msg_ptr->work_dir)
		xfree(launch_msg_ptr->work_dir);
	if (launch_msg_ptr->err)
		xfree(launch_msg_ptr->err);
	if (launch_msg_ptr->in)
		xfree(launch_msg_ptr->in);
	if (launch_msg_ptr->out)
		xfree(launch_msg_ptr->out);
	if (launch_msg_ptr->argv)
		xfree(launch_msg_ptr->argv);
	if (launch_msg_ptr->environment)
		xfree(launch_msg_ptr->environment);
	xfree(launch_msg_ptr);
void pack_ ( * msg , Buf buffer )
	pack16 ( msg -> , buffer ) ;
	pack32 ( msg -> , buffer ) ;
	packstr ( msg -> , buffer ) ;
int unpack_ ( ** msg_ptr , Buf buffer )
	assert ( msg_ptr != NULL );

	msg = xmalloc ( sizeof ( ) ) ;
	safe_unpack16 ( & msg -> , buffer ) ;
	safe_unpack32 ( & msg -> , buffer ) ;
	safe_unpackstr_xmalloc ( & msg -> x, & uint16_tmp , buffer ) ;
	return SLURM_SUCCESS;

    unpack_error:
	if (msg -> x)
		xfree (msg -> x);
	xfree (msg);
	*msg_ptr = NULL;
	return SLURM_ERROR;