Skip to content

Commit

Permalink
not used
Browse files Browse the repository at this point in the history
  • Loading branch information
cirospaciari committed Oct 18, 2024
1 parent 5e3276c commit 1e127cf
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/bun.js/api/bun/h2_frame_parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ pub const H2FrameParser = struct {
client.outboundQueueSize += 1;
client.queuedDataSize += frame.len;
client.calculateEstimatedByteSize();

}

pub fn init(streamIdentifier: u32, initialWindowSize: u32) Stream {
Expand Down Expand Up @@ -1137,6 +1138,7 @@ pub const H2FrameParser = struct {
client.outboundQueueSize -= 1;
}
client.calculateEstimatedByteSize();

}
/// this can be called multiple times
pub fn freeResources(this: *Stream, client: *H2FrameParser, comptime finalizing: bool) void {
Expand Down Expand Up @@ -1489,7 +1491,8 @@ pub const H2FrameParser = struct {

pub fn _genericWrite(this: *H2FrameParser, comptime T: type, socket: T, bytes: []const u8) bool {
log("_genericWrite {}", .{bytes.len});
defer this.calculateEstimatedByteSize();
defer this.calculateEstimatedByteSize();


const buffer = this.writeBuffer.slice()[this.writeBufferOffset..];
if (buffer.len > 0) {
Expand Down Expand Up @@ -1728,6 +1731,7 @@ pub const H2FrameParser = struct {
_ = this.readBuffer.appendSlice(payload) catch bun.outOfMemory();
this.calculateEstimatedByteSize();


return .{
.data = this.readBuffer.list.items,
.end = end,
Expand Down Expand Up @@ -2268,6 +2272,7 @@ pub const H2FrameParser = struct {
_ = this.readBuffer.appendSlice(bytes) catch bun.outOfMemory();
this.calculateEstimatedByteSize();


return bytes.len;
}
FrameHeader.from(&header, this.readBuffer.list.items[0..buffered_data], 0, false);
Expand Down Expand Up @@ -3141,7 +3146,7 @@ pub const H2FrameParser = struct {
}
return stream_id;
}

pub fn writeStream(this: *H2FrameParser, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSValue {
JSC.markBinding(@src());
const args = callframe.argumentsUndef(5);
Expand Down Expand Up @@ -3906,15 +3911,15 @@ pub const H2FrameParser = struct {
}
return this;
}
pub fn detachFromJS(this: *H2FrameParser, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, this_value: JSC.JSValue) JSValue {
pub fn detachFromJS(this: *H2FrameParser, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, _: JSC.JSValue) JSValue {
JSC.markBinding(@src());
this.detach(false);
return .undefined;
}
/// be careful when calling detach be sure that the socket is closed and the parser not accesible anymore
/// this function can be called multiple times, it will erase stream info
pub fn detach(this: *H2FrameParser, comptime finalizing: bool) void {
log("detach {s}", .{if (this.isServer) "server" else "client"});
log("detach {s}", .{ if(this.isServer) "server" else "client" });
this.flushCorked();
this.detachNativeSocket();
this.strong_ctx.deinit();
Expand All @@ -3937,9 +3942,10 @@ pub const H2FrameParser = struct {
var streams = this.streams;
this.streams = bun.U32HashMap(Stream).init(bun.default_allocator);
streams.deinit();

this.has_pending_activity.store(false, .release);
this.calculateEstimatedByteSize();

}

pub fn deinit(this: *H2FrameParser) void {
Expand All @@ -3956,18 +3962,18 @@ pub const H2FrameParser = struct {
}

pub fn estimatedSize(this: ?*H2FrameParser) callconv(.C) usize {
if (this == null) {
if(this == null) {
return 0;
}
return this.?.reported_estimated_size;
}

pub fn calculateEstimatedByteSize(this: *H2FrameParser) void {
this.reported_estimated_size = @sizeOf(H2FrameParser) + this.writeBuffer.len + this.queuedDataSize + (this.streams.capacity() * @sizeOf(Stream));
}
}
pub fn hasPendingActivity(this: ?*H2FrameParser) callconv(.C) bool {
@fence(.acquire);
if (this == null) {
if(this == null) {
return false;
}
return this.?.has_pending_activity.load(.acquire);
Expand All @@ -3976,7 +3982,7 @@ pub const H2FrameParser = struct {
pub fn finalize(
this: *H2FrameParser,
) void {
log("finalize {s}", .{if (this.isServer) "server" else "client"});
log("finalize {s}", .{ if(this.isServer) "server" else "client" });
this.deref();
}
};
Expand Down

0 comments on commit 1e127cf

Please sign in to comment.