Example #1
0
int
__pbs_orderjob(int c, char *job1, char *job2, char *extend)
{
	struct batch_reply *reply;
	int rc;
	int sock;


	if ((job1 == NULL) || (*job1 == '\0') ||
		(job2 == NULL) || (*job2 == '\0'))
		return (pbs_errno = PBSE_IVALREQ);

	sock = connection[c].ch_socket;

	/* initialize the thread context data, if not already initialized */
	if (pbs_client_thread_init_thread_context() != 0)
		return pbs_errno;

	/* lock pthread mutex here for this connection */
	/* blocking call, waits for mutex release */
	if (pbs_client_thread_lock_connection(c) != 0)
		return pbs_errno;

	/* setup DIS support routines for following DIS calls */

	DIS_tcp_setup(sock);

	if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_OrderJob, pbs_current_user)) ||
		(rc = encode_DIS_MoveJob(sock, job1, job2)) ||
		(rc = encode_DIS_ReqExtend(sock, extend))) {
		connection[c].ch_errtxt = strdup(dis_emsg[rc]);
		if (connection[c].ch_errtxt == NULL) {
			pbs_errno = PBSE_SYSTEM;
		} else {
			pbs_errno = PBSE_PROTOCOL;
		}
		(void)pbs_client_thread_unlock_connection(c);
		return pbs_errno;
	}
	if (DIS_tcp_wflush(sock)) {
		pbs_errno = PBSE_PROTOCOL;
		(void)pbs_client_thread_unlock_connection(c);
		return pbs_errno;
	}

	/* read reply */

	reply = PBSD_rdrpy(c);

	PBSD_FreeReply(reply);

	rc = connection[c].ch_errno;

	/* unlock the thread lock and update the thread context data */
	if (pbs_client_thread_unlock_connection(c) != 0)
		return pbs_errno;

	return rc;
}
Example #2
0
int pbs_orderjob_err(
    
  int   c,
  char *job1,
  char *job2,
  char *extend,
  int  *local_errno)

  {
  struct batch_reply *reply;
  int                 rc;
  int                 sock;
  struct tcp_chan *chan = NULL;


  if ((job1 == (char *)0) || (*job1 == '\0') ||
      (job2 == (char *)0) || (*job2 == '\0'))
    return (PBSE_IVALREQ);
  
  if ((c < 0) || 
      (c >= PBS_NET_MAX_CONNECTIONS))
    {
    return(PBSE_IVALREQ);
    }

  pthread_mutex_lock(connection[c].ch_mutex);

  sock = connection[c].ch_socket;

  /* setup DIS support routines for following DIS calls */

  if ((chan = DIS_tcp_setup(sock)) == NULL)
    {
    pthread_mutex_unlock(connection[c].ch_mutex);
    rc = PBSE_PROTOCOL;
    return rc;
    }
  else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_OrderJob, pbs_current_user))
      || (rc = encode_DIS_MoveJob(chan, job1, job2))
      || (rc = encode_DIS_ReqExtend(chan, extend)))
    {
    connection[c].ch_errtxt = strdup(dis_emsg[rc]);

    pthread_mutex_unlock(connection[c].ch_mutex);
    DIS_tcp_cleanup(chan);
    return (PBSE_PROTOCOL);
    }

  if (DIS_tcp_wflush(chan))
    {
    pthread_mutex_unlock(connection[c].ch_mutex);
    DIS_tcp_cleanup(chan);
    return (PBSE_PROTOCOL);
    }

  /* read reply */

  reply = PBSD_rdrpy(local_errno, c);

  PBSD_FreeReply(reply);

  rc = connection[c].ch_errno;

  pthread_mutex_unlock(connection[c].ch_mutex);
  DIS_tcp_cleanup(chan);

  return(rc);
  } /* END pbs_orderjob_err() */