Projects STRLCPY dnstt Commits 8526369e
🤬
  • Give next-response/timer-expired priority over packing downstream.

    I don't know what I was thinking in
    f1ee951fd67d43c3f642c1f319678da51dd05c9b. The way it was written, if
    there were not immediately additional packets to pack into the
    downstream, it would stop trying to pack and would instead wait until
    the maxResponseDelay or another response to send. What I meant is that
    the timer and the next-response channel should have priority, if either
    of those is true *and* there is additional downstream available to pack.
    Only when both of those are false should we try to pack downstream data.
  • Loading...
  • David Fifield committed 4 years ago
    8526369e
    1 parent 2371fb45
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    dnstt-server/main.go
    skipped 590 lines
    591 591   loop:
    592 592   for {
    593 593   select {
    594  - case p := <-ttConn.OutgoingQueue(rec.ClientID):
    595  - // We wait for the first packet in a
    596  - // bundle only. The second and later
    597  - // packets must be immediately available
    598  - // or they will be omitted from this
    599  - // send.
    600  - timer.Reset(0)
    601  - 
    602  - if int(uint16(len(p))) != len(p) {
    603  - panic(len(p))
    604  - }
    605  - if 2+len(p) > limit {
    606  - // Save this packet to send in
    607  - // the next response.
    608  - nextP = p
    609  - break loop
    610  - }
    611  - limit -= 2 + len(p)
    612  - binary.Write(&payload, binary.BigEndian, uint16(len(p)))
    613  - payload.Write(p)
     594 + // Prioritize the first two cases over the
     595 + // OutgoingQueue case. The first two cases are
     596 + // duplicated under the default case.
     597 + case nextRec = <-ch:
     598 + // If there's another response
     599 + // waiting to be sent, wait no
     600 + // longer for a payload for this
     601 + // one.
     602 + break loop
     603 + case <-timer.C:
     604 + break loop
    614 605   default:
    615 606   select {
    616 607   case nextRec = <-ch:
    617  - // If there's another response
    618  - // waiting to be sent, wait no
    619  - // longer for a payload for this
    620  - // one.
    621 608   break loop
    622 609   case <-timer.C:
    623 610   break loop
     611 + case p := <-ttConn.OutgoingQueue(rec.ClientID):
     612 + // We wait for the first packet
     613 + // in a bundle only. The second
     614 + // and later packets must be
     615 + // immediately available or they
     616 + // will be omitted from this
     617 + // send.
     618 + timer.Reset(0)
     619 + 
     620 + if int(uint16(len(p))) != len(p) {
     621 + panic(len(p))
     622 + }
     623 + if 2+len(p) > limit {
     624 + // Save this packet to
     625 + // send in the next
     626 + // response.
     627 + nextP = p
     628 + break loop
     629 + }
     630 + limit -= 2 + len(p)
     631 + binary.Write(&payload, binary.BigEndian, uint16(len(p)))
     632 + payload.Write(p)
    624 633   }
    625 634   }
    626 635   }
    skipped 270 lines
Please wait...
Page is in error, reload to recover