mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-26 15:39:47 +00:00
Add quick logic for scheduler to send fake packet when no buffer is pending
This commit is contained in:
parent
71973da3f4
commit
c0619e390a
@ -57,9 +57,13 @@ func(s *Scheduler) mainLoop() {
|
|||||||
var sending = len(s.Buffer)
|
var sending = len(s.Buffer)
|
||||||
if sending > 0 {
|
if sending > 0 {
|
||||||
errors.LogDebug(s.ctx, "Scheduler Trigger for ", sending, " buffer(s) with ", d, " ", trigger)
|
errors.LogDebug(s.ctx, "Scheduler Trigger for ", sending, " buffer(s) with ", d, " ", trigger)
|
||||||
}
|
for i := 0; i<sending; i++ {
|
||||||
for i := 0; i<sending; i++ {
|
s.Error <- s.writer.WriteMultiBuffer(<-s.Buffer)
|
||||||
s.Error <- s.writer.WriteMultiBuffer(<-s.Buffer)
|
}
|
||||||
|
} else if trigger > 0 {
|
||||||
|
errors.LogDebug(s.ctx, "Scheduler Trigger for fake buffer with ", d, " ", trigger)
|
||||||
|
mb := make(buf.MultiBuffer, 1)
|
||||||
|
s.Error <- s.writer.WriteMultiBuffer(mb)
|
||||||
}
|
}
|
||||||
s.bufferReadLock.Unlock()
|
s.bufferReadLock.Unlock()
|
||||||
}()
|
}()
|
||||||
@ -69,6 +73,6 @@ func(s *Scheduler) mainLoop() {
|
|||||||
func(s *Scheduler) exampleIndependentScheduler() {
|
func(s *Scheduler) exampleIndependentScheduler() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
s.Trigger <- -1 // send all buffers
|
s.Trigger <- 1 // send fake buffer if no pending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user