Changeset - 71f0379b39de
[Not reviewed]
tip default
0 6 0
Nathan Brink (binki) - 15 years ago 2010-10-09 11:29:35
ohnobinki@ohnopublishing.net
Renice execio's newly spawned processes. Fixes bug 8.
6 files changed with 30 insertions and 12 deletions:
0 comments (0 inline, 0 general)
configure.ac
Show inline comments
 
@@ -33,12 +33,15 @@ AC_TYPE_PID_T
 
AC_TYPE_SIZE_T
 

	
 
AC_TYPE_UINT8_T
 
AC_TYPE_UINT16_T
 
AC_TYPE_UINT32_T
 

	
 
dnl execio has a nice() call but it's not vital to our operation
 
AC_CHECK_FUNCS([nice])
 

	
 
dnl selective compilation
 
dnl For now, this is only left for when the C-based client is
 
dnl reintroducded.
 
AC_ARG_ENABLE([server],
 
	[AS_HELP_STRING([--disable-server],[Don't build the distren server])],
 
	[enable_server=$enableval],
src/common/execio.c
Show inline comments
 
@@ -29,13 +29,13 @@
 
#include <signal.h>
 
#include <fcntl.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <errno.h>
 

	
 
int execio_open(struct execio **rem, const char *progname, char *const argv[])
 
int execio_open(struct execio **rem, const char *progname, char *const argv[], int nice_incr)
 
{
 
  /* pipe used to write to child */
 
  int pipe_write[2];
 
  /* pipe used to read from child */
 
  int pipe_read[2];
 

	
 
@@ -96,12 +96,17 @@ int execio_open(struct execio **rem, con
 
      return 0;
 
    }
 
  
 
  /* child */
 
  else
 
    {
 
#ifdef HAVE_NICE
 
      /* lower the nice value */
 
      nice(nice_incr);
 
#endif
 

	
 
      /* close unused pipes */
 
      close(pipe_write[1]);
 
      close(pipe_read[0]);
 

	
 
      /*
 
	reset stdin, stdout, and stderr to the appropriate files. OK, not stderr :-) 
 
@@ -159,13 +164,13 @@ int _execio_checkpid(struct execio *eio)
 
  /* perror()? */
 

	
 
  return WIFEXITED(childstatus);
 
}
 

	
 

	
 
int execio_read(struct execio *eio, const void *buf, size_t len, size_t *bytesread)
 
int execio_read(struct execio *eio, void *buf, size_t len, size_t *bytesread)
 
{
 
  ssize_t ret;
 
  /*
 
    TODO: detect NULL eio? 
 
    TODO: errno?
 
    update status of eio for execio_status/to be able to cleanup subproc??
src/common/execio.h
Show inline comments
 
@@ -41,23 +41,33 @@ struct execio
 
  enum execio_state state;
 

	
 
  pid_t child;
 
};
 

	
 
/**
 
  runs progname with the arguments in argv. argv must be null terminated!!!!!!!!!
 

	
 
  returns nonzero return on error
 
 * \brief
 
 *   runs progname with the arguments in argv. argv must be null terminated!!!!!!!!!
 
 *
 
 * \param eio
 
 *   Where to store the pointer to the execio handle.
 
 * \param progname
 
 *   The name of the program to execute at the system's shell.
 
 * \param argv
 
 *   The NULL-terminated list of arguments to send to the subcommand.
 
 * \param nice_incr
 
 *   The amount to increase the subprogram's nice value by. See nice(3p).
 
 * \return
 
 *   nonzero return on error
 
*/
 
int execio_open(struct execio **eio, const char *progname, char *const argv[]);
 
int execio_open(struct execio **eio, const char *progname, char *const argv[], int nice_incr);
 

	
 
/**
 
   doesn't block,
 
   returns 0 on success, 1 on failure
 
*/
 
int execio_read(struct execio *eio, const void *buf, size_t len, size_t *bytesread);
 
int execio_read(struct execio *eio, void *buf, size_t len, size_t *bytesread);
 
int execio_write(struct execio *eio, const void *buf, size_t len, size_t *byteswritten);
 

	
 
/**
 
  use this function to determine if the using program should keep trying to read/write
 

	
 
  @todo is this function good enough/necessary?
src/common/remoteio.c
Show inline comments
 
@@ -592,13 +592,13 @@ int _remoteio_ssh_open(struct remoteio *
 
  if(server->username)
 
    _distren_asprintf(&userhost, "%s@%s", server->username, server->hostname);
 
  else
 
    userhost = strdup(server->hostname);
 
  sshargs[1] = userhost;
 

	
 
  rtn = execio_open( &rem->execio, "ssh", sshargs);
 
  rtn = execio_open( &rem->execio, "ssh", sshargs, 0);
 
  if(rtn)
 
    {
 
      fprintf(stderr, "error opening remoteio channel to ssh userhost ``%s''\n" , userhost);
 
      free(userhost);
 
      return 1;
 
    }
src/server/slavefuncs.c
Show inline comments
 
@@ -296,13 +296,13 @@ int exec_blender(char *input, char *outp
 
  struct execio *testrem;
 
  size_t readlen;
 

	
 
  if(DEBUG)
 
    fprintf(stderr,"Executing: %s\n", frame_str);
 

	
 
  ret = execio_open(&testrem, command, cmd);
 
  ret = execio_open(&testrem, command, cmd, 10);
 
  if(ret)
 
    {
 
      fprintf(stderr, "Error running blender\n");
 
      return 1;
 
    }
 
  buf[19] = '\0';
 
@@ -724,13 +724,13 @@ int _web_getwork(int slavekey, char *sla
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      *outputext = strdup(tmp);
 
      if(DEBUG)
 
        fprintf(stderr,"GETWORK Debug output - Job: %d | Frame: %d | Xres: %d | Yres: %d | Outformat: %s\n", *jobnum, *framenum, *xres, *yres, outputext);
 
        fprintf(stderr,"GETWORK Debug output - Job: %d | Frame: %d | Xres: %d | Yres: %d | Outformat: %s\n", *jobnum, *framenum, *xres, *yres, *outputext);
 

	
 
      // @FIXME: Setting outputext and serverversion = temp; will this cause issues as these are pointers to parts of the original temp var?
 

	
 
      // @TODO: This should be called every time, not just on fail.
 
      if(strcmp(PACKAGE_VERSION,serverversion)){
 
        fprintf(stderr,"Your distren package is out of date! Please acquire a newer version. (%s local vs %s remote)\n", PACKAGE_VERSION, serverversion);
 
@@ -792,13 +792,13 @@ int slaveBenchmark(char *datadir, int *b
 
  time(&startTime);
 

	
 
  char buf[20];
 
  struct execio *testrem;
 
  size_t readlen;
 

	
 
  ret = execio_open(&testrem, command, cmd);
 
  ret = execio_open(&testrem, command, cmd, 10);
 
  if(ret)
 
    {
 
      fprintf(stderr, "Error executing blender\n");
 
      return 1;
 
    }
 

	
test/check_execio.c
Show inline comments
 
@@ -36,13 +36,13 @@ START_TEST (check_execio)
 
  char inbuf[20];
 
  size_t bytesread;
 
  size_t pos;
 

	
 
  pos = 1;
 

	
 
  fail_unless(execio_open(&eio, echoargv[0], echoargv) == 0,
 
  fail_unless(execio_open(&eio, echoargv[0], echoargv, 0) == 0,
 
	      "execio_open failed");
 
  
 
  fail_unless(execio_read(eio, inbuf, sizeof(inbuf) - 1, &bytesread) == 0,
 
	      "error using execio_read\n");
 
  pos += bytesread;
 

	
0 comments (0 inline, 0 general)