Changeset - 86c54813cdc2
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2010-01-23 16:20:33
ohnobinki@ohnopublishing.net
fix distrenjob_serialize()
1 file changed with 13 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/server/distrenjob.c
Show inline comments
 
@@ -50,25 +50,25 @@ int distrenjob_new(struct distrenjob **d
 
       faster: */
 
      *distrenjob = NULL;
 
      return 1;
 
    }
 
  *distrenjob = dj;
 

	
 
  dj->next = NULL;
 
  dj->jobnum = 0; /*< @todo there should be a central jobnum allocator and a way to save the maximum jobnumber allocated */
 
  dj->type = 1;
 
  dj->name = (char *)NULL;
 
  dj->submitter = (char *)NULL;
 

	
 
  df->output_format = (char *)NULL;
 
  dj->output_format = (char *)NULL;
 
  dj->width = 0;
 
  dj->height = 0;
 

	
 
  dj->priority = 0;
 
  dj->completed_frames = 0;
 
  dj->assigned_frames = 0;
 
  dj->total_frames = 0;
 
  dj->prev_frame_index = -1;
 

	
 
  dj->total_render_time = 0;
 
  dj->assigned_render_power = 0;
 
  dj->watchdog_forgiveness = 3600; // initialize watchdog forgiveness at 1 hour
 
@@ -222,31 +222,31 @@ int distrenjob_unserialize(struct distre
 
      xmlFree(xmlchar);
 
    }
 

	
 
  xmlnode = xml_quickxpath(xmlxpathcontext, (xmlChar *)"/job/watchdog");
 
  dj->watchdog_forgiveness = 3600;
 
  tmp =_distrenjob_xml_readuint(xmlnode, (xmlChar *)"forgiveness", &dj->watchdog_forgiveness);
 
  if(tmp)
 
    fprintf(stderr, "distrenjob_unserialize(): warning: watchdog forgiveness is unspecified in ``%s'', defaulting to 3600\n", pathtoxml);
 

	
 
  xmlXPathFreeContext(xmlxpathcontext);
 
  xmlFreeDoc(xmldoc);
 

	
 
#ifndef NDEBUG
 
  fprintf(stderr, "distrenjob_unserialize(): restoring %d frames\n", dj->total_frames);
 
#endif
 
  /**
 
     reconstruct the frameset
 
  */
 
  dj->total_frames = end_frame - start_frame + 1;
 
#ifndef NDEBUG
 
  fprintf(stderr, "distrenjob_unserialize(): restoring %d frames\n", dj->total_frames);
 
#endif
 
  dj->frameset = malloc(sizeof(struct frameset) * dj->total_frames);
 
  if(!dj->frameset)
 
    {
 
      fprintf(stderr, "OOM!\n");
 
      distrenjob_free(distrenjob);
 
      return 8;
 
    }
 
  fs = dj->frameset;
 
  for(counter = start_frame; counter <= end_frame; counter ++)
 
    {
 
      fs->num = counter;
 
      fs->status = FRAMESETSTATUS_UNASSIGNED; /*< @todo job partial completion and resumption support */
 
@@ -300,37 +300,43 @@ int distrenjob_serialize(struct distrenj
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"height", (xmlChar*)tmp);
 
  free(tmp);
 

	
 
  xmlTextWriterEndElement(writer);
 

	
 
  /**
 
     write video element and its attributes */
 
  xmlTextWriterStartElement(writer, (xmlChar*)"video");
 
  _distren_asprintf(&tmp, "%d", job->frameset[0].num);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"start_frame", (xmlChar*)tmp);
 
  free(tmp);
 

	
 
  _distren_asprintf(&tmp, "%d", job->frameset[(job->total_frames - 1)].num);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"end_fame", (xmlChar*)tmp);
 
  _distren_asprintf(&tmp, "%d", job->frameset[ job->total_frames - 1 ].num);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"end_frame", (xmlChar*)tmp);
 
  free(tmp);
 

	
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"output_format", (xmlChar*)job->output_format);
 
  xmlTextWriterEndElement(writer);
 

	
 
  /**
 
     write watchdog forgiveness element */
 
  xmlTextWriterStartElement(writer, (xmlChar*)"watchdog");
 

	
 
  _distren_asprintf(&tmp, "%d", job->watchdog_forgiveness);
 
  xmlTextWriterWriteElement(writer, (xmlChar*)"wd_forgiveness", (xmlChar*)tmp);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar *)"forgiveness", (xmlChar *)tmp);
 
  free(tmp);
 

	
 
  xmlTextWriterEndElement(writer); /* </watchdog> */
 

	
 
  xmlTextWriterEndElement(writer); /* </job> */
 

	
 
  /**
 
     end document */
 
  xmlTextWriterEndDocument(writer);
 

	
 
  /**
 
     free writer and save xml file to disk */
 
  xmlFreeTextWriter(writer);
 

	
 
  /**
 
     This is the key to transactioanl POSIX
 
     FS programming.
 
   */
0 comments (0 inline, 0 general)