Hello,

I am new to Genode and currently writing a program in which two components communicate with each other over virtual ethernet. The communication using a NIC router works completely fine if started from the main component, but fails whenever initiated from a thread. Hereby

Error: pthread_self() called from alien thread named 'Broker Thread'
no RM attachment (READ pf_addr=0x4b8 pf_ip=0x10f62dfc from pager_object: pd='init -> manager' thread='Broker Thread')

is thrown when the 'connect' function is called. I have tried resolving this by simply allocating some RAM and also by initializing a sliced heap, both to no avail. Unfortunately it is imperative for the component to initialize a connection from within a thread. Therefore I would be very grateful for any help regarding this issue. I have attached the thread's code to this mail.

Kind regards,

Kevin Burton

struct Broker_thread : public Genode::Thread {
private:

    Libc::Env &_env;
    Genode::Ram_dataspace_capability &_capability;

    Genode::uint8_t _ipv4[4];
    Genode::uint16_t _port;

    void entry() override {
        Libc::with_libc([&] () {
            struct sockaddr_in sockaddr = { };
            int fd;
            if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
                Genode::log("Socket initialization failed");
                return;
            }
            sockaddr.sin_family = AF_INET;
            sockaddr.sin_port = htons(_port);
            std::string ip = std::to_string(_ipv4[0]) + "." + std::to_string(_ipv4[1]) + "." + std::to_string(_ipv4[2]) + "." + std::to_string(_ipv4[3]);
            sockaddr.sin_addr.s_addr = inet_addr(ip.c_str());

            Genode::log("Connecting to ", ip.c_str(), ":", _port);
            if (connect(fd, (struct sockaddr *) &sockaddr, sizeof sockaddr) < 0) {
                Genode::log("Socket connection failed");
                return;
            }
        });
    }

public:
    Broker_thread(Libc::Env &env, const Genode::uint8_t ipv4[4], Genode::uint16_t port, Genode::Ram_dataspace_capability &capability)
    : Thread(env, "Broker Thread", 1024 * 16), _env(env), _capability(capability), _port(port) {
        for (int i = 0; i < 4; i++) _ipv4[i] = ipv4[i];
    }

    ~Broker_thread() { };
};
_______________________________________________
Genode users mailing list
[email protected]
https://lists.genode.org/listinfo/users

Reply via email to