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
 
@@ -36,6 +36,9 @@ 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.
src/common/execio.c
Show inline comments
 
@@ -32,7 +32,7 @@
 
#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];
 
@@ -99,6 +99,11 @@ int execio_open(struct execio **rem, con
 
  /* child */
 
  else
 
    {
 
#ifdef HAVE_NICE
 
      /* lower the nice value */
 
      nice(nice_incr);
 
#endif
 

	
 
      /* close unused pipes */
 
      close(pipe_write[1]);
 
      close(pipe_read[0]);
 
@@ -162,7 +167,7 @@ int _execio_checkpid(struct execio *eio)
 
}
 

	
 

	
 
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;
 
  /*
src/common/execio.h
Show inline comments
 
@@ -44,17 +44,27 @@ struct execio
 
};
 

	
 
/**
 
  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);
 

	
 
/**
src/common/remoteio.c
Show inline comments
 
@@ -595,7 +595,7 @@ int _remoteio_ssh_open(struct remoteio *
 
    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);
src/server/slavefuncs.c
Show inline comments
 
@@ -299,7 +299,7 @@ int exec_blender(char *input, char *outp
 
  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");
 
@@ -727,7 +727,7 @@ int _web_getwork(int slavekey, char *sla
 
        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?
 

	
 
@@ -795,7 +795,7 @@ int slaveBenchmark(char *datadir, int *b
 
  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");
test/check_execio.c
Show inline comments
 
@@ -39,7 +39,7 @@ START_TEST (check_execio)
 

	
 
  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,
0 comments (0 inline, 0 general)