# HG changeset patch # User Binki # Date 2009-12-12 17:03:42 # Node ID 5964e275c41079c1ee78ed0267861d855c5b6c2d # Parent 5523bae2123fb86d41ecfaafde0171d3d7eb1518 slave: reorganize vars, correct config gathering, error handling diff --git a/etc/distrenslave.conf.in b/etc/distrenslave.conf.in --- a/etc/distrenslave.conf.in +++ b/etc/distrenslave.conf.in @@ -2,6 +2,7 @@ slave { username = "!username" datadir = "@LOCALSTATEDIR@/@PACKAGE@" + hostname = "protofusion.org" } -include("distrencommon.conf") \ No newline at end of file +include("distrencommon.conf") diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -35,9 +35,51 @@ int main(int argc, char *argv[]) { char curopt; + + int tmp; + + char *datadir; + char *server; char *username; + cfg_opt_t myopts[] = { + CFG_SIMPLE_STR("username", &username), + CFG_SIMPLE_STR("datadir", &datadir), + CFG_SIMPLE_STR("server", &server), + CFG_END() + }; + cfg_t * my_cfg; + + struct options_common *commonopts; + + int jobnum = 0; + int framenum = 0; + + char *urltoTar; /* Full URL to the server-side location of job#.tgz */ + char *pathtoTar; /* Full path to the location of the job#.tgz */ - while(-1 != (curopt = getopt(argc, argv, "u:h"))) + char *urltoOutput; /* Full URL where output is posted */ + char *pathtoJobfile; /* Full path to the job's main file */ + char *pathtoXml; /* Full path to the job's xml file */ + char *pathtoOutput; /* Full path to the output (rendered) file */ + char *outputExt; /* Output Extension (e.g., JPG) */ + + char *tarcmd; /* Command to run for tar. Migrate to libtar sometime */ + char *outdir; /* Output Directory for tar */ + char *jobdatapath; /* Path to job data */ + + struct distrenjob *myjob; /* Structure to hold data gathered from the XML file */ + + struct remoteio *comm_slave; + + /** + initializations + */ + datadir = NULL; + server = NULL; + username = NULL; + + + while(((char)-1) != (curopt = getopt(argc, argv, "u:h"))) { if(curopt == ':') { @@ -63,15 +105,6 @@ int main(int argc, char *argv[]) } /* Get conf data */ - char *datadir; - cfg_t * my_cfg; - cfg_opt_t myopts[] = { - CFG_SIMPLE_STR("username", &username), - CFG_SIMPLE_STR("datadir", &datadir), - CFG_END() - }; - struct options_common *commonopts; - username = NULL; options_init(argc, argv, &my_cfg, myopts, "slave", &commonopts); @@ -97,31 +130,17 @@ int main(int argc, char *argv[]) } - int jobnum = 0; - int framenum = 0; - char *urltoTar; /* Full URL to the server-side location of job#.tgz */ - char *pathtoTar; /* Full path to the location of the job#.tgz */ - - char *urltoOutput; /* Full URL where output is posted */ - char *pathtoJobfile; /* Full path to the job's main file */ - char *pathtoXml; /* Full path to the job's xml file */ - char *pathtoOutput; /* Full path to the output (rendered) file */ - char *outputExt; /* Output Extension (e.g., JPG) */ + fprintf(stderr, "Loading config (fasten your seatbelts for a SEGFAULT :-D )...\n"); + - char *tarcmd; /* Command to run for tar. Migrate to libtar sometime */ - char *outdir; /* Output Directory for tar */ - char *jobdatapath; /* Path to job data */ - - struct distrenjob *myjob; /* Structure to hold data gathered from the XML file */ - - struct remoteio_opts *comm_slaveopts = {"ssh"}; - - struct execio *remoteExec; - struct remoteio *comm_slave = {0, comm_slaveopts, remoteExec}; /* Structures for remotio */ - - fprintf(stderr,"Connecting to server...\n"); - remoteio_open(&comm_slave, comm_slaveopts, "protofusion" ); + fprintf(stderr, "Connecting to server...\n"); + tmp = remoteio_open(&comm_slave, commonopts->remoteio, server); + if(tmp) + { + fprintf(stderr, "Error connecting to server; exitting\n"); + return 1; + } int haveWork = 0; diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -36,13 +36,16 @@ #include -// Sends the server a single request (see protocol.h) -int sendSignal(struct remoteio *rem, int signal){ +/** + Sends the server a single request (see protocol.h) +*/ +int sendSignal(struct remoteio *rem, int signal) +{ size_t written; char *ssignal; - _distren_asprintf(&ssignal,"%d",signal); + _distren_asprintf(&ssignal, "%d", signal); while( !remoteio_write(rem, ssignal, strlen(ssignal), &written) ) - fprintf(stderr,"Writing..."); + fprintf(stderr, "Writing..."); return 0; } /** diff --git a/src/server/slavefuncs.h b/src/server/slavefuncs.h --- a/src/server/slavefuncs.h +++ b/src/server/slavefuncs.h @@ -21,6 +21,7 @@ #define _DISTREN_SLAVEFUNCS_H #include "distrenjob.h" +#include "remoteio.h" #include #include