MCPcopy
hub / github.com/grpc/grpc-go / handleSettings

Method handleSettings

internal/transport/http2_client.go:1299–1346  ·  view source on GitHub ↗
(f *http2.SettingsFrame, isFirst bool)

Source from the content-addressed store, hash-verified

1297}
1298
1299func (t *http2Client) handleSettings(f *http2.SettingsFrame, isFirst bool) {
1300 if f.IsAck() {
1301 return
1302 }
1303 var maxStreams *uint32
1304 var ss []http2.Setting
1305 var updateFuncs []func()
1306 f.ForeachSetting(func(s http2.Setting) error {
1307 switch s.ID {
1308 case http2.SettingMaxConcurrentStreams:
1309 maxStreams = new(uint32)
1310 *maxStreams = s.Val
1311 case http2.SettingMaxHeaderListSize:
1312 updateFuncs = append(updateFuncs, func() {
1313 t.maxSendHeaderListSize = new(uint32)
1314 *t.maxSendHeaderListSize = s.Val
1315 })
1316 default:
1317 ss = append(ss, s)
1318 }
1319 return nil
1320 })
1321 if isFirst && maxStreams == nil {
1322 maxStreams = new(uint32)
1323 *maxStreams = math.MaxUint32
1324 }
1325 sf := &incomingSettings{
1326 ss: ss,
1327 }
1328 if maxStreams != nil {
1329 updateStreamQuota := func() {
1330 delta := int64(*maxStreams) - int64(t.maxConcurrentStreams)
1331 t.maxConcurrentStreams = *maxStreams
1332 t.streamQuota += delta
1333 if delta > 0 && t.waitingStreams > 0 {
1334 close(t.streamsQuotaAvailable) // wake all of them up.
1335 t.streamsQuotaAvailable = make(chan struct{}, 1)
1336 }
1337 }
1338 updateFuncs = append(updateFuncs, updateStreamQuota)
1339 }
1340 t.controlBuf.executeAndPut(func() bool {
1341 for _, f := range updateFuncs {
1342 f()
1343 }
1344 return true
1345 }, sf)
1346}
1347
1348func (t *http2Client) handlePing(f *http2.PingFrame) {
1349 if f.IsAck() {

Callers 2

readServerPrefaceMethod · 0.95
readerMethod · 0.95

Calls 1

executeAndPutMethod · 0.80

Tested by

no test coverage detected