Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
msgq: dont clean up uninitialized sockerts
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm committed Nov 15, 2019
1 parent c008b63 commit 4e513a8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
12 changes: 8 additions & 4 deletions messaging/impl_msgq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ void MSGQSubSocket::setTimeout(int t){
}

MSGQSubSocket::~MSGQSubSocket(){
msgq_close_queue(q);
delete q;
if (q != NULL){
msgq_close_queue(q);
delete q;
}
}

void MSGQPubSocket::connect(Context *context, std::string endpoint){
Expand Down Expand Up @@ -150,8 +152,10 @@ int MSGQPubSocket::send(char *data, size_t size){
}

MSGQPubSocket::~MSGQPubSocket(){
msgq_close_queue(q);
delete q;
if (q != NULL){
msgq_close_queue(q);
delete q;
}
}


Expand Down
4 changes: 2 additions & 2 deletions messaging/impl_msgq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MSGQMessage : public Message {

class MSGQSubSocket : public SubSocket {
private:
msgq_queue_t * q;
msgq_queue_t * q = NULL;
int timeout;
public:
void connect(Context *context, std::string endpoint, std::string address, bool conflate=false);
Expand All @@ -43,7 +43,7 @@ class MSGQSubSocket : public SubSocket {

class MSGQPubSocket : public PubSocket {
private:
msgq_queue_t * q;
msgq_queue_t * q = NULL;
public:
void connect(Context *context, std::string endpoint);
int sendMessage(Message *message);
Expand Down
19 changes: 19 additions & 0 deletions messaging/stress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import time
from messaging_pyx import Context, Poller, SubSocket, PubSocket # pylint: disable=no-name-in-module, import-error

#21845
#32767 after closing mmap fd

if __name__ == "__main__":
c = Context()
pub_sock = PubSocket()
pub_sock.connect(c, "controlsState")

for i in range(int(1e10)):
print(i)
sub_sock = SubSocket()
sub_sock.connect(c, "controlsState")


pub_sock.send(b'a')
print(sub_sock.receive())

0 comments on commit 4e513a8

Please sign in to comment.