Skip to content

Commit

Permalink
added overflow scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
ony committed Feb 28, 2014
1 parent 956047e commit e50841e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Binary file added doc/json-loop-overflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions doc/json-loop-overflow.txt
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

0 comments on commit e50841e

Please sign in to comment.