# HG changeset patch # User Nathan Phillip Brink # Date 2010-10-09 11:29:35 # Node ID 71f0379b39de1103a71ba464f4091b3408361c63 # Parent ec90f545efc5ff0eca829696b22d4761beb435d5 Renice execio's newly spawned processes. Fixes bug 8. diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -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. diff --git a/src/common/execio.c b/src/common/execio.c --- a/src/common/execio.c +++ b/src/common/execio.c @@ -32,7 +32,7 @@ #include #include -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; /* diff --git a/src/common/execio.h b/src/common/execio.h --- a/src/common/execio.h +++ b/src/common/execio.h @@ -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); /** diff --git a/src/common/remoteio.c b/src/common/remoteio.c --- a/src/common/remoteio.c +++ b/src/common/remoteio.c @@ -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); diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -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"); diff --git a/test/check_execio.c b/test/check_execio.c --- a/test/check_execio.c +++ b/test/check_execio.c @@ -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,