-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@startuml | ||
title Overflow scenario | ||
|
||
actor client as "Client" | ||
participant parser as "some : Parser" | ||
participant buffer1 as "buffer1 : Buffer" | ||
participant buffer2 as "buffer2 : Buffer" | ||
participant chunk1 as "chunk1 : Buffer" | ||
participant chunk2 as "chunk2 : Buffer" | ||
|
||
create buffer1 | ||
client -> buffer1: allocate | ||
client -> parser: initialize with buffer1 | ||
|
||
create chunk1 | ||
client -> chunk1: read | ||
client -> parser: feed chunk1 | ||
client -> parser: pull n tokens | ||
activate parser | ||
client <-- parser: some token | ||
client <-- parser: overflow | ||
note right: second token didn't fit into buffer1 | ||
deactivate parser | ||
|
||
create buffer2 | ||
client -> buffer2: allocate | ||
client -> parser: realloc with buffer2 | ||
activate parser | ||
note right of parser: some part of buffer1 may be copied to buffer2 | ||
client <-- parser | ||
deactivate parser | ||
client -> buffer1: free | ||
destroy buffer1 | ||
|
||
client -> parser: pull n tokens | ||
activate parser | ||
client <-- parser: starving | ||
deactivate parser | ||
|
||
create chunk2 | ||
client -> chunk2: read | ||
client -> parser: feed chunk2 | ||
client -> parser: pull n tokens | ||
activate parser | ||
client <-- parser: some token | ||
client <-- parser: starving | ||
deactivate parser | ||
@enduml |