fix for weird obs bug with chunkstream ids on rapid i3 workspace switching (maybe also alt+tabs?)

This commit is contained in:
Muaz Ahmad 2023-08-22 14:59:17 +05:00
parent 7b5021f8d2
commit 355b1bfa77

View file

@ -4,6 +4,7 @@ import (
"net" "net"
"time" "time"
"encoding/binary" "encoding/binary"
"errors"
) )
// data intake object, only needed since most of the work is // data intake object, only needed since most of the work is
@ -189,7 +190,9 @@ func read_message_header_1(conn net.Conn, chnk_stream_ptr *ChunkStream, msg_ptr
func read_message_header_2(conn net.Conn, chnk_stream_ptr *ChunkStream, msg_ptr *Message, chunk_bufs_ptr *ChunkBuffers) (error) { func read_message_header_2(conn net.Conn, chnk_stream_ptr *ChunkStream, msg_ptr *Message, chunk_bufs_ptr *ChunkBuffers) (error) {
var extended_time bool var extended_time bool
var err error var err error
if chnk_stream_ptr == nil {
panic(err)
}
chnk_stream_ptr.timedelta, extended_time, err = read_time(conn, chunk_bufs_ptr) chnk_stream_ptr.timedelta, extended_time, err = read_time(conn, chunk_bufs_ptr)
if err != nil { if err != nil {
return err return err
@ -269,6 +272,9 @@ func ReadChunk(conn net.Conn, open_chnkstrms map[uint32]*ChunkStream, open_msgs
// format 1, chunkstream with this csid MUST have been opened before, but message is just starting since // format 1, chunkstream with this csid MUST have been opened before, but message is just starting since
// message metadata is being declared // message metadata is being declared
chnkstream_ptr = open_chnkstrms[csid] chnkstream_ptr = open_chnkstrms[csid]
if chnkstream_ptr == nil {
return nil, errors.New("Chunkstream was not opened, bad obs")
}
msg_ptr = new(Message) msg_ptr = new(Message)
if err := read_message_header_1(conn, chnkstream_ptr, msg_ptr, chunk_bufs_ptr); err != nil { if err := read_message_header_1(conn, chnkstream_ptr, msg_ptr, chunk_bufs_ptr); err != nil {
@ -281,6 +287,9 @@ func ReadChunk(conn net.Conn, open_chnkstrms map[uint32]*ChunkStream, open_msgs
case 2: case 2:
// format 2, same as 1 // format 2, same as 1
chnkstream_ptr = open_chnkstrms[csid] chnkstream_ptr = open_chnkstrms[csid]
if chnkstream_ptr == nil {
return nil, errors.New("Chunkstream was not opened, bad obs")
}
msg_ptr = new(Message) msg_ptr = new(Message)
if err := read_message_header_2(conn, chnkstream_ptr, msg_ptr, chunk_bufs_ptr); err != nil { if err := read_message_header_2(conn, chnkstream_ptr, msg_ptr, chunk_bufs_ptr); err != nil {
@ -294,6 +303,9 @@ func ReadChunk(conn net.Conn, open_chnkstrms map[uint32]*ChunkStream, open_msgs
// format 3 has no header, only happens when either a previous message over the csid was too large for the chunksize // format 3 has no header, only happens when either a previous message over the csid was too large for the chunksize
// or a new message with the same exact metadata including timedelta is being sent. // or a new message with the same exact metadata including timedelta is being sent.
chnkstream_ptr = open_chnkstrms[csid] chnkstream_ptr = open_chnkstrms[csid]
if chnkstream_ptr == nil {
return nil, errors.New("Chunkstream was not opened, bad obs")
}
msg_prev, ok := open_msgs[chnkstream_ptr.last_msg_strm_id] msg_prev, ok := open_msgs[chnkstream_ptr.last_msg_strm_id]
if !ok { if !ok {
msg_ptr = new(Message) msg_ptr = new(Message)