The reason for so many checks is to make sure the status of the variables
had not changed in the time that the variable condition was validated to
the time when the line would execute.
as for:
 fprintf(stdout, " ")
My guess is that the while loop keeps on doing the print until appropriate
conditions are resolved for the worker threads in order to terminate or
proceed with other conditions. the print out is used so that the compiler
thinks that progress is being made while the worker threads resolve
(reads_finished becomes true instead of false when it is finished). I'm not
really sure though, just a guess.



On Thu, Feb 6, 2014 at 12:46 PM, esaunders <notifications@github.com> wrote:

> In src/dig.cpp:
>
> > -    if((status =
> > -	digBuffer(state, rinfo->bytesread, rinfo->beginreadpos
> > -		  )) != SCALPEL_OK) {
> > -      return status;
> > -    }
> > -    put(empty_readbuf, (void *)rinfo);
> > + while (true)
> > +  {
> > +	fprintf(stdout, " "); //needed for while loop to continue while some functions resolve
> > +	if (reads_finished && full_readbuf->empty) break;
> > +	if (!full_readbuf->empty)
> > +	{
> > +	    readbuf_info *rinfo = (readbuf_info *)get(full_readbuf);
> > +        if (!full_readbuf->empty)  readbuffer = rinfo->readbuf; //TODO @@@ check for race cond. on this global var.
> > +		if((status =digBuffer(state, rinfo->bytesread, rinfo->beginreadpos)) != SCALPEL_OK) return status;
> > +		if (!full_readbuf->empty) put(empty_readbuf, (void *)rinfo);
>
> Again, why the extra check for !full_readbuf->empty?
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/sleuthkit/scalpel/pull/1/files#r9510033>
> .
>