Skip to content

Commit

Permalink
flush
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAlphaFox committed Oct 4, 2021
1 parent 73bedb4 commit ac97a92
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/aiutp_net.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ max_send(#aiutp_pcb{max_window = MaxWindow,
max_window_user = MaxWindowUser,
cur_window = CurWindow,
cur_window_packets = CurWindowPackets,
outbuf = OutBuf,
brust = Brust})->
if Brust == true ->
if CurWindowPackets > ?BRUST_OUTGOING_BUFFER_SIZE -> 0;
true -> ?PACKET_SIZE * (?BRUST_OUTGOING_BUFFER_SIZE - CurWindowPackets)
OSize = aiutp_buffer:used(OutBuf),
if OSize > ?BRUST_OUTGOING_BUFFER_SIZE -> 0;
true -> ?PACKET_SIZE * (?BRUST_OUTGOING_BUFFER_SIZE - OSize)
end;
true ->
MaxSend = erlang:min(MaxWindow, MaxWindowUser),
Expand All @@ -39,13 +41,15 @@ is_full(Bytes,#aiutp_pcb{time= Now,
max_window_user = MaxWindowUser,
cur_window = CurWindow,
cur_window_packets = CurWindowPackets,
outbuf = OutBuf,
brust = Brust} = PCB)->
Bytes0 = if Bytes > ?PACKET_SIZE -> ?PACKET_SIZE;
Bytes < 0 -> ?PACKET_SIZE;
true -> Bytes
end,
if Brust == true ->
if CurWindowPackets > ?BRUST_OUTGOING_BUFFER_SIZE ->
OSize = aiutp_buffer:used(OutBuf),
if OSize > ?BRUST_OUTGOING_BUFFER_SIZE ->
{true,PCB#aiutp_pcb{last_maxed_out_window = Now}};
true -> {false,PCB}
end;
Expand Down Expand Up @@ -315,7 +319,6 @@ send_data_in_queue(#aiutp_pcb{outque = OutQue} = PCB)->
{Type,Bin} = aiutp_queue:front(OutQue),
OutQue0 = aiutp_queue:pop_front(OutQue),
MaxSend = max_send(PCB),
io:format("max can send ~p~n",[MaxSend]),
send_data_in_queue(Type,Bin,MaxSend,PCB#aiutp_pcb{outque = OutQue0})
end.
flush_queue(#aiutp_pcb{time = Now,outque = OutQue,
Expand Down

0 comments on commit ac97a92

Please sign in to comment.