Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/octopos.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class octopOS {
/*! The ids of the used semaphores */
static std::vector<int> semids;
/*! The global list of tentacles used for communication with children */
static std::vector<std::shared_ptr<tentacle>> tentacles;
static std::vector<tentacle*> tentacles;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I like smart pointers. :(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget why we wanted to remove them. Probably had to do with shm

/*! Pointers to locations inside the shared memory segment. Used for
* allocation */
static intptr_t *shared_ptr, *shared_end_ptr;
Expand Down
9 changes: 4 additions & 5 deletions src/octopos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void octopOS::sig_handler(int sig) {
}
}
for (unsigned i = 0; i < NUMMODULES; ++i) {
tentacles.pop_back();
delete tentacles[i];
if (msgctl(tentacle_ids[i], IPC_RMID, NULL) < 0) {
if (sig < 0)
throw std::system_error(
Expand Down Expand Up @@ -87,8 +87,7 @@ octopOS::octopOS() {
std::generic_category(),
"Unable to create message queues");
} else {
tentacles.push_back(std::make_shared<tentacle>(
tentacle(MSGKEY + i)));
tentacles.push_back(new tentacle(MSGKEY + i));
}
}

Expand Down Expand Up @@ -131,7 +130,7 @@ std::pair<unsigned, key_t> octopOS::create_new_topic
}

void* octopOS::listen_for_child(void* tentacle_id) {
std::shared_ptr<tentacle> t = tentacles[*(int*)tentacle_id]; // NOLINT
tentacle* t = tentacles[*(int*)tentacle_id]; // NOLINT

std::pair<long, std::string> data; // NOLINT
for (;;) {
Expand Down Expand Up @@ -299,7 +298,7 @@ octopOS::~octopOS() {

int octopOS::shmid = 0;
int octopOS::tentacle_ids[NUMMODULES];
std::vector<std::shared_ptr<tentacle>> octopOS::tentacles;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe :(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole branch is way behind master I think

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrite it in rust

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+2

std::vector<tentacle*> octopOS::tentacles;
std::vector<int> octopOS::semids;
intptr_t *octopOS::shared_ptr, *octopOS::shared_end_ptr;
std::unordered_map<std::string, std::tuple<unsigned, key_t,
Expand Down