You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The dependency tree grows unless pruned. We prune the dependency
information when the stream is closed, and in addition, fix the tree
manipulations to be robust in the face of missing stream dependencies.
Copy file name to clipboardExpand all lines: lib/protocol/http2/connection.rb
+36-26Lines changed: 36 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -63,14 +63,6 @@ def id
63
63
0
64
64
end
65
65
66
-
defparent
67
-
nil
68
-
end
69
-
70
-
defchildren
71
-
@dependency.streams
72
-
end
73
-
74
66
def [] id
75
67
ifid.zero?
76
68
self
@@ -113,10 +105,7 @@ def closed?
113
105
114
106
defdelete(id)
115
107
@streams.delete(id)
116
-
117
-
ifdependency=@dependencies[id]
118
-
dependency.delete!ifdependency.irrelevant?
119
-
end
108
+
@dependencies[id]&.delete!
120
109
end
121
110
122
111
# Close the underlying framer and all streams.
@@ -145,20 +134,10 @@ def next_stream_id
145
134
end
146
135
147
136
attr:streams
137
+
148
138
attr:dependencies
149
139
150
-
# Fetch (or create) the flow control windows for the specified stream id.
151
-
# @param id [Integer] the stream id.
152
-
defdependency_for(id)
153
-
@dependencies.fetch(id)do
154
-
dependency=Dependency.new(self,id)
155
-
156
-
# TODO this might be irrelevant, if initially processing priority frame.
157
-
@dependency.add_child(dependency)
158
-
159
-
@dependencies[id]=dependency
160
-
end
161
-
end
140
+
attr:dependency
162
141
163
142
# 6.8. GOAWAY
164
143
# There is an inherent race condition between an endpoint starting new streams and the remote sending a GOAWAY frame. To deal with this case, the GOAWAY contains the stream identifier of the last peer-initiated stream that was or might be processed on the sending endpoint in this connection. For instance, if the server sends a GOAWAY frame, the identified stream is the highest-numbered stream initiated by the client.
# Stream ID (odd for client initiated streams, even otherwise).
64
80
attr:id
65
81
66
-
# The stream id that this stream depends on, according to the priority.
67
-
attr_accessor:dependent_id
82
+
# The parent dependency.
83
+
attr_accessor:parent
84
+
85
+
# The dependent children.
86
+
attr_accessor:children
68
87
69
88
# The weight of the stream relative to other siblings.
70
89
attr_accessor:weight
@@ -77,10 +96,26 @@ def clear_cache!
77
96
@ordered_children=nil
78
97
end
79
98
99
+
defdelete!
100
+
@connection.dependencies.delete(@id)
101
+
102
+
@parent.remove_child(self)
103
+
104
+
@children&.eachdo |id,child|
105
+
parent.add_child(child)
106
+
end
107
+
108
+
@connection=nil
109
+
@parent=nil
110
+
@children=nil
111
+
end
112
+
80
113
defadd_child(dependency)
81
114
@children ||= {}
82
115
@children[dependency.id]=dependency
83
116
117
+
dependency.parent=self
118
+
84
119
self.clear_cache!
85
120
end
86
121
@@ -90,33 +125,24 @@ def remove_child(dependency)
90
125
self.clear_cache!
91
126
end
92
127
128
+
# An exclusive flag allows for the insertion of a new level of dependencies. The exclusive flag causes the stream to become the sole dependency of its parent stream, causing other dependencies to become dependent on the exclusive stream.
129
+
# @param parent [Dependency] the dependency which will be inserted, taking control of all current children.
0 commit comments