private void ParseRequests(DataStorage dts)
 {
     int dataLeft = 0, skip = 0;
     for (_parsePos = 0; true; dts.CommitSentBytes())
     {
         var ds = dts.GetSegmentToSend();
         if (ds == null) break;
         int cnt = ds.Count, offset = ds.Offset;
         // may need to skip some bytes if packet splits.
         if (skip != 0)
         {
             if (skip >= cnt) { skip -= cnt; continue; }
             cnt -= skip; offset += skip;
             skip = 0;
         }
         // process storage buffer/page.
         fixed (byte* bp = ds.Buffer)
         {
             byte* cp = bp + offset, ep = cp + cnt;
             if (dataLeft > 0)
             {
                 // append bytes to "open" value.
                 var sz = Math.Min(dataLeft, (int)(ep - cp));
                 _ce->AppendValue(cp, sz, _ce->ValSize - dataLeft);
                 if (sz == dataLeft)
                 {
                     cp += sz; dataLeft = 0;
                     _ce = null;
                 }
                 else { cp = ep; dataLeft -= sz; }
             }
             while ((cp = ParsePacket(cp, ep)) != null)
             {
                 // quick path, no page breaks.
                 var vsz = _ce->ValSize;
                 if (vsz > 0)
                 {
                     var left = vsz - (int)(ep - cp);
                     if (left > 0)
                     {
                         dataLeft = left;
                         _ce->AppendValue(cp, vsz - left, 0);
                         break;
                     }
                     _ce->AppendValue(cp, vsz, 0);
                     cp += vsz;
                 }
                 // indicates that request is fully built.
                 _ce = null;
             }
             if (cp == null && _parsePos > 0)
             {
                 // read "split" request into continuos area[].
                 int tsz = iDataKeyLimit - _parsePos, lsz = tsz, pos = ds.Count;
                 var bt = dts.Peek(ref tsz, ref pos);
                 if (lsz < tsz) tsz = lsz;
                 _memcopy(_split + _parsePos, bt, pos, tsz);
                 tsz += _parsePos;
                 var nx = ParsePacket(_split, _split + tsz);
                 if (nx == null)
                     throw new InvalidOperationException("eos");
                 skip = (int)(nx - _split) - _parsePos;
                 dataLeft = _ce->ValSize;
                 if (dataLeft == 0) _ce = null;
                 _parsePos = 0;
             }
         }
     }
 }