Ejemplo n.º 1
0
func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
	if v, ok := f.Value(http2.SettingMaxConcurrentStreams); ok {
		t.mu.Lock()
		t.maxStreams = v
		t.mu.Unlock()
	}
}
Ejemplo n.º 2
0
func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
	if f.IsAck() {
		return
	}
	f.ForeachSetting(func(s http2.Setting) error {
		if v, ok := f.Value(http2.SettingInitialWindowSize); ok {
			t.mu.Lock()
			defer t.mu.Unlock()
			for _, s := range t.activeStreams {
				s.sendQuotaPool.reset(int(v - t.streamSendQuota))
			}
			t.streamSendQuota = v
		}
		return nil
	})
	t.controlBuf.put(&settings{ack: true})
}
Ejemplo n.º 3
0
func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
	if f.IsAck() {
		return
	}
	f.ForeachSetting(func(s http2.Setting) error {
		if v, ok := f.Value(s.ID); ok {
			switch s.ID {
			case http2.SettingMaxConcurrentStreams:
				// TODO(zhaoq): This is a hack to avoid significant refactoring of the
				// code to deal with the unrealistic int32 overflow. Probably will try
				// to find a better way to handle this later.
				if v > math.MaxInt32 {
					v = math.MaxInt32
				}
				t.mu.Lock()
				reset := t.streamsQuota != nil
				if !reset {
					t.streamsQuota = newQuotaPool(int(v))
				}
				ms := t.maxStreams
				t.maxStreams = int(v)
				t.mu.Unlock()
				if reset {
					t.streamsQuota.reset(int(v) - ms)
				}
			case http2.SettingInitialWindowSize:
				t.mu.Lock()
				for _, s := range t.activeStreams {
					// Adjust the sending quota for each s.
					s.sendQuotaPool.reset(int(v - t.streamSendQuota))
				}
				t.streamSendQuota = v
				t.mu.Unlock()
			}
		}
		return nil
	})
	t.controlBuf.put(&settings{ack: true})
}
Ejemplo n.º 4
0
func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
	if f.IsAck() {
		return
	}
	f.ForeachSetting(func(s http2.Setting) error {
		if v, ok := f.Value(s.ID); ok {
			t.mu.Lock()
			defer t.mu.Unlock()
			switch s.ID {
			case http2.SettingMaxConcurrentStreams:
				t.maxStreams = v
			case http2.SettingInitialWindowSize:
				for _, s := range t.activeStreams {
					// Adjust the sending quota for each s.
					s.sendQuotaPool.reset(int(v - t.streamSendQuota))
				}
				t.streamSendQuota = v
			}
		}
		return nil
	})
	t.controlBuf.put(&settings{ack: true})
}