@@ -355,7 +355,8 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
355
355
fn recv_task (rt : * Runtime , result : RecvResult , provision : * Provision ) ! void {
356
356
assert (provision .job == .recv );
357
357
358
- const length = result .unwrap () catch | e | {
358
+ // recv_count is how many bytes we have read off the socket
359
+ const recv_count = result .unwrap () catch | e | {
359
360
if (e != error .Closed ) {
360
361
log .warn ("socket recv failed | {}" , .{e });
361
362
}
@@ -369,18 +370,8 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
369
370
370
371
const recv_job = & provision .job .recv ;
371
372
372
- // If the socket is closed.
373
- if (length <= 0 ) {
374
- provision .job = .close ;
375
- try rt .net .close (provision , close_task , provision .socket );
376
- return ;
377
- }
378
-
379
373
log .debug ("{d} - recv triggered" , .{provision .index });
380
374
381
- // recv_count is how many bytes we have read off the socket
382
- const recv_count : usize = @intCast (length );
383
-
384
375
// this is how many http bytes we have received
385
376
const http_bytes_count : usize = blk : {
386
377
if (comptime security == .tls ) {
@@ -468,7 +459,7 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
468
459
try handshake_inner_task (rt , length , provision );
469
460
}
470
461
471
- fn handshake_inner_task (rt : * Runtime , length : i32 , provision : * Provision ) ! void {
462
+ fn handshake_inner_task (rt : * Runtime , length : usize , provision : * Provision ) ! void {
472
463
assert (security == .tls );
473
464
if (comptime security == .tls ) {
474
465
const tls_slice = rt .storage .get ("__zzz_tls_slice" , []TLSType );
@@ -488,11 +479,9 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
488
479
return error .TLSHandshakeTooManyCycles ;
489
480
}
490
481
491
- const hs_length : usize = @intCast (length );
492
-
493
482
const hstate = switch (handshake_job .state ) {
494
- .recv = > tls_ptr .*.? .continue_handshake (.{ .recv = @intCast ( hs_length ) }),
495
- .send = > tls_ptr .*.? .continue_handshake (.{ .send = @intCast ( hs_length ) }),
483
+ .recv = > tls_ptr .*.? .continue_handshake (.{ .recv = length }),
484
+ .send = > tls_ptr .*.? .continue_handshake (.{ .send = length }),
496
485
} catch | e | {
497
486
log .err ("{d} - tls handshake failed={any}" , .{ provision .index , e });
498
487
provision .job = .close ;
@@ -618,7 +607,7 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
618
607
assert (provision .job == .send );
619
608
const config = rt .storage .get_const_ptr ("__zzz_config" , ServerConfig );
620
609
621
- const length = result .unwrap () catch | e | {
610
+ const send_count = result .unwrap () catch | e | {
622
611
// If the socket is closed.
623
612
if (e != error .ConnectionReset ) {
624
613
log .warn ("socket send failed: {}" , .{e });
@@ -631,7 +620,6 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
631
620
const send_job = & provision .job .send ;
632
621
633
622
log .debug ("{d} - send triggered" , .{provision .index });
634
- const send_count : usize = @intCast (length );
635
623
log .debug ("{d} - sent length: {d}" , .{ provision .index , send_count });
636
624
637
625
switch (comptime security ) {
0 commit comments