equal
deleted
inserted
replaced
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package jdk.internal.net.http; |
26 package jdk.internal.net.http; |
27 |
27 |
|
28 import jdk.internal.net.http.common.FlowTube; |
28 import jdk.internal.net.http.common.Logger; |
29 import jdk.internal.net.http.common.Logger; |
29 import jdk.internal.net.http.frame.SettingsFrame; |
30 import jdk.internal.net.http.frame.SettingsFrame; |
30 import jdk.internal.net.http.frame.WindowUpdateFrame; |
31 import jdk.internal.net.http.frame.WindowUpdateFrame; |
31 import jdk.internal.net.http.common.Utils; |
32 import jdk.internal.net.http.common.Utils; |
32 import java.util.concurrent.atomic.AtomicInteger; |
33 import java.util.concurrent.atomic.AtomicInteger; |
64 } |
65 } |
65 |
66 |
66 abstract int getStreamId(); |
67 abstract int getStreamId(); |
67 |
68 |
68 void update(int delta) { |
69 void update(int delta) { |
69 if (debug.on()) debug.log("update: %d", delta); |
70 int rcv = received.addAndGet(delta); |
70 if (received.addAndGet(delta) > limit) { |
71 if (debug.on()) debug.log("update: %d, received: %d, limit: %d", delta, rcv, limit); |
|
72 if (rcv > limit) { |
71 synchronized (this) { |
73 synchronized (this) { |
72 int tosend = received.get(); |
74 int tosend = received.get(); |
73 if( tosend > limit) { |
75 if( tosend > limit) { |
74 received.getAndAdd(-tosend); |
76 received.getAndAdd(-tosend); |
75 sendWindowUpdate(tosend); |
77 sendWindowUpdate(tosend); |
81 void sendWindowUpdate(int delta) { |
83 void sendWindowUpdate(int delta) { |
82 if (debug.on()) debug.log("sending window update: %d", delta); |
84 if (debug.on()) debug.log("sending window update: %d", delta); |
83 connection.sendUnorderedFrame(new WindowUpdateFrame(getStreamId(), delta)); |
85 connection.sendUnorderedFrame(new WindowUpdateFrame(getStreamId(), delta)); |
84 } |
86 } |
85 |
87 |
|
88 volatile String dbgString; |
86 String dbgString() { |
89 String dbgString() { |
87 return "WindowUpdateSender(stream: " + getStreamId() + ")"; |
90 String dbg = dbgString; |
|
91 if (dbg != null) return dbg; |
|
92 FlowTube tube = connection.connection.getConnectionFlow(); |
|
93 if (tube == null) { |
|
94 return "WindowUpdateSender(stream: " + getStreamId() + ")"; |
|
95 } else { |
|
96 int streamId = getStreamId(); |
|
97 dbg = connection.dbgString() + ":WindowUpdateSender(stream: " + streamId + ")"; |
|
98 return streamId == 0 ? dbg : (dbgString = dbg); |
|
99 } |
88 } |
100 } |
89 |
101 |
90 } |
102 } |