Skip to content

Commit

Permalink
Add buffers to stream channel. Check data packet type in iterator (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpunish3r authored Sep 21, 2023
1 parent 480fd21 commit f4fbdc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions datastreamer/streamfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,12 @@ func (f *StreamFile) iteratorNext(iterator *iteratorFile) (bool, error) {
log.Errorf("Error reading new packet type for iterator: %v", err)
return true, err
}
}

// Should be of type data
if packet[0] != PtData {
log.Errorf("Error data page not starting with packet of type data. Type: %d", packet[0])
return true, errors.New("page not starting with entry data")
}
// Should be of type data
if packet[0] != PtData {
log.Errorf("Error expecting packet of type data(%d). Read: %d", PtData, packet[0])
return true, errors.New("error expecting packet type data")
}

// Read the rest of fixed data entry bytes
Expand Down
4 changes: 3 additions & 1 deletion datastreamer/streamserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type StreamType uint64
type CommandError uint32

const (
streamBuffer = 128 // Buffers for the stream channel

// Commands
CmdUnknown Command = 0
CmdStart Command = 1
Expand Down Expand Up @@ -121,7 +123,7 @@ func New(port uint16, streamType StreamType, fileName string) (StreamServer, err
startEntry: 0,
entries: []FileEntry{},
},
stream: make(chan streamAO),
stream: make(chan streamAO, streamBuffer),
}

// Open (or create) the data stream file
Expand Down

0 comments on commit f4fbdc9

Please sign in to comment.