# HG changeset patch # User ethanzonca@localhost.localdomain # Date 2009-11-24 00:07:50 # Node ID d1b199f51bbd8712d60de7d21e3f14b8ac31cee8 # Parent daac9f402eabc79a925feec6c7a709575da4a604 Upload failure management diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -176,7 +176,20 @@ int main(int argc, char *argv[]) /* When blender is finished, run this... */ fprintf(stderr, "Finished frame %d in job %d, uploading...", framenum, jobnum); - curlpost(pathtoOutput, urltoOutput); /* uploads (HTML POST) the output at outputpath to the server at outputurl */ + if( !curlpost(pathtoOutput, urltoOutput)){ // Uploads output + fprintf(stderr,"Upload successful, removing old output...\n"); + remove(pathtoOutput); // Delete the file after its uploaded + } + else{ + fprintf(stderr,"Upload failed. Check your network connection. Trying again..."); + int tries=0; + while(tries<10 && curlpost(pathtoOutput, urltoOutput)){ + fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)", tries); + tries++; + sleep(10); + } + // @TODO: Keep track of files that we were unable to upload, and upload them later + } free(urltoOutput); free(pathtoOutput); @@ -185,13 +198,14 @@ int main(int argc, char *argv[]) } else fprintf(stderr,"Nothing to do. Idling...\n"); + // If the server says that every frame for the last jobnum is finished, OR if the data is getting old if(1 == 0){ + // Note: individual frames are already deleted after uploading, + // except for ones that couldn't be uploaded delete_jobdata(jobnum, datadir); } - - sleep(5); // Poll 5 seconds. @TODO: Remove all polling } return 0; diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -156,7 +156,7 @@ int curlpost(char *filename, char *url){ curl_formfree(formpost); curl_slist_free_all (headerlist); } - return 0; + return res; }