diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -30,9 +30,10 @@ #include #include + + int main(int argc, char *argv[]) { - char curopt; char *username; @@ -114,16 +115,26 @@ int main(int argc, char *argv[]) struct distrenjob *myjob; /* Structure to hold data gathered from the XML file */ + struct remoteio *comm_slave; /* Structures for remotio */ + struct remoteio_opts *comm_slaveoptions; + + fprintf(stderr,"Connecting to server...\n"); + remoteio_open(&comm_slave, comm_slaveoptions, "protofusion" ); + int haveWork = 0; while(1) { - tell_the_server(0); // Give me some work! + // request work + fprintf(stderr,"Requesting work...\n"); + sendSignal(comm_slave, DISTREN_REQUEST_GETWORK); /* If we got a frame */ if(haveWork) { + + fprintf(stderr,"Got work from server...\n"); /* @TODO: Add remotio hooks */ // jobnum = remoteio_read(jobnum); /* Set jobnum from remoteio (we could use info from struct, but we need this info to download the xmlfile */ //framenum = remoteio_read(jobnum); /* Set framenum from remoteio */ @@ -150,7 +161,7 @@ int main(int argc, char *argv[]) free(urltoTar); } else { - fprintf(stderr, "Downloading job data from server failed. Check your network connection.\n"); + fprintf(stderr, "Downloading job data from %s failed. Check your network connection.\n",urltoTar); return 1; // Eventually make a retry loop } } @@ -158,7 +169,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Using cached job file...\n"); _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); - mkdir("/tmp/distren", 0750); /* @TODO: Change to tmpdir once it exists */ + mkdir("/tmp/distren", 0750); /* @FIXME: Change to tmpdir once it exists */ mkdir(outdir, 0750); _distren_asprintf(&tarcmd, "tar -xvf \"%s\" -C \"%s\"", pathtoTar, outdir); /* @TODO:Use a lib here! */ @@ -178,7 +189,7 @@ int main(int argc, char *argv[]) } else { - fprintf(stderr, "I think the XML craziness may have failed, so I'll terminate just for fun.\n"); + fprintf(stderr, "XML job data parsing has failed. Please contact a developer, or try again.\n"); return 1; } @@ -191,13 +202,13 @@ int main(int argc, char *argv[]) /* Execute blender */ if(exec_blender(pathtoJobfile, pathtoOutput, framenum)) { - fprintf(stderr,"Error running Blender. Check your installation and/or your PATH."); + fprintf(stderr,"Error running Blender. Check your installation and/or your PATH.\n"); return 1; } free(pathtoJobfile); /* Post-execution */ - fprintf(stderr, "Finished frame %d in job %d, uploading...", framenum, jobnum); + fprintf(stderr, "Finished frame %d in job %d, uploading...\n", framenum, jobnum); if( !curlpost(pathtoOutput, urltoOutput)) // Uploads output { fprintf(stderr,"Upload successful, removing old output...\n"); @@ -205,11 +216,11 @@ int main(int argc, char *argv[]) } else { - fprintf(stderr,"Upload failed. Check your network connection. Trying again..."); - int tries=0; - while(tries<10 && curlpost(pathtoOutput, urltoOutput)) + fprintf(stderr,"Upload failed. Check your network connection. Retrying upload...\n"); + int tries=1; + while(tries<=10 && curlpost(pathtoOutput, urltoOutput)) { - fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)", tries); + fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)\n", tries); tries++; sleep(10); } @@ -218,7 +229,10 @@ int main(int argc, char *argv[]) free(urltoOutput); free(pathtoOutput); - tell_the_server(DISTREN_REQUEST_DONEFRAME); /* Tells the server that it's done rendering, and upload is done */ + // Tell the server that rendering and upload are complete + // sendServer(DISTREN_REQUEST_DONEFRAME); + sendSignal(comm_slave, DISTREN_REQUEST_DONEFRAME); + } else fprintf(stderr,"Nothing to do. Idling...\n"); @@ -233,5 +247,9 @@ int main(int argc, char *argv[]) sleep(5); // Poll 5 seconds. @TODO: Remove all polling } + + fprintf(stderr,"Closing connection to server...\n"); + remoteio_close(comm_slave); + return 0; }