On Sun, 8 Sep 2013, Phil Dibowitz wrote:

>> +    /*
>> +     * Second parameter in the read file "ack" message is the data length.  
>> Use
>> +     * this to determine the number of packets we should expect.
>> +     */
>> +    uint32_t data_len = (rsp[7] << 24) + (rsp[8] << 16) + (rsp[9] << 8) +
>> +        rsp[10];
>> +    int pkts_to_read = data_len / MH_MAX_DATA_SIZE;
>> +    if ((data_len % MH_MAX_DATA_SIZE) != 0)
>> +        pkts_to_read++;
>> +    pkts_to_read++; // count is always one more than the actual count
>
> I was willing to buy that until I saw:
>
>> +        pkts_to_read--;
>> +        if (pkts_to_read == 1) {
>> +            break;
>> +        }
>
> This. If you stop when you have one more to read, then really the original
> number was correct, no?

Yes, but the problem is, the 'ack' message to the remote has a field that 
is the number of packets to read, plus one (don't ask me why, I didn't 
design the protocol).  We use this 'pkts_to_read' variable to populate 
that 'ack' message, so pkts_to_read always is one more than the number of 
packets we're actually planning to read.  For example, if we need to read 
43 packets, we start with pkts_to_read = 44 and go until pkts_to_read = 1.

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to