Esempio n. 1
0
int pbs_runjob_err(

  int   c,
  char *jobid,
  char *location,
  char *extend,
  int  *rc)

  {
  struct batch_reply   *reply;
  unsigned int          resch = 0;
  int                   sock;
  struct tcp_chan *chan = NULL;

  /* NOTE:  set_task sets WORK_Deferred_Child : request remains until child terminates */

  if ((jobid == NULL) ||
      (*jobid == '\0'))
    {
    *rc = PBSE_IVALREQ;
    return (*rc) * -1;
    }
  
  if ((c < 0) || 
      (c >= PBS_NET_MAX_CONNECTIONS))
    {
    return(PBSE_IVALREQ * -1);
    }

  if (location == NULL)
    {
    location = (char *)"";
    }

  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);
    }
  /* send run request */
  else if ((*rc = encode_DIS_ReqHdr(chan, PBS_BATCH_RunJob, pbs_current_user)) ||
           (*rc = encode_DIS_RunJob(chan, jobid, location, resch)) ||
           (*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 ((*rc = DIS_tcp_wflush(chan)) != PBSE_NONE)
    {
    pthread_mutex_unlock(connection[c].ch_mutex);
    
    DIS_tcp_cleanup(chan);

    return(PBSE_PROTOCOL);
    }

  /* get reply */

  reply = PBSD_rdrpy(rc, c);

/*  *rc = connection[c].ch_errno; */

  pthread_mutex_unlock(connection[c].ch_mutex);

  PBSD_FreeReply(reply);
    
  DIS_tcp_cleanup(chan);

  return(*rc);
  }  /* END pbs_runjob_err() */
Esempio n. 2
0
int pbs_asyrunjob_err(

  int   c,
  char *jobid,    /* I */
  char *location,
  char *extend,
  int  *local_errno)

  {
  int                 rc;

  struct batch_reply *reply;
  unsigned int        resch = 0;
  int                 sock;
  struct tcp_chan *chan = NULL;

  if ((c < 0) || (jobid == NULL) || (*jobid == '\0'))
    {
    return(PBSE_IVALREQ);
    }

  if (location == NULL)
    location = "";

  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)
    {
    rc = PBSE_PROTOCOL;
    return rc;
    }
  else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_AsyrunJob, pbs_current_user))
      || (rc = encode_DIS_RunJob(chan, jobid, location, resch))
      || (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);
    }

  /* get reply */

  reply = PBSD_rdrpy(local_errno, c);

  rc = connection[c].ch_errno;

  pthread_mutex_unlock(connection[c].ch_mutex);

  PBSD_FreeReply(reply);
  DIS_tcp_cleanup(chan);
  return(rc);
  }  /* END pbs_asyrunjob_err() */
Esempio n. 3
0
int pbs_stagein(
    
  int   c,
  char *jobid,
  char *location,
  char *extend)

  {
  int                   rc;
  int                   local_errno = 0;

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


  if ((jobid == (char *)0) || (*jobid == '\0'))
    return (PBSE_IVALREQ);

  if (location == (char *)0)
    location = (char *)"";

  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;
    }
    /* send stagein request, a run request with a different id */
  else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_StageIn, pbs_current_user)) ||
      (rc = encode_DIS_RunJob(chan, jobid, location, 0)) ||
      (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);
    }

  /* get reply */

  reply = PBSD_rdrpy(&local_errno, c);

  rc = connection[c].ch_errno;

  pthread_mutex_unlock(connection[c].ch_mutex);

  PBSD_FreeReply(reply);
  DIS_tcp_cleanup(chan);
  return(rc);
  }