Hello.

I created a simple examples which describe my problem.
It is some kind of server and client.
At first run a qserver and then qclient.
After that close the qserver and try to run it again.
It disallows (in my configuratio) to create the queue because it already exists 
and also the binding to it fails with error -EACCES.
This behavior continues till the qclient is closed. It's perhaps caused by the 
rt_queue_delete() at the end of qserver.

Also I have one question: How to break the rt_queue_bind call with TM_INFINITE 
parameter, because rt_task_unblock() doesn't work in this case?

______________________________________________________________
Od: "Philippe Gerum" <[email protected]>
Komu: Petr Cervenka <[email protected]>
Datum: 09.08.2011 18:04
Předmět: Re: [Xenomai-help] rt_queue_bind() returns -EACCES

CC: "xenomai-help" <[email protected]>
On Tue, 2011-08-09 at 17:40 +0200, Petr Cervenka wrote:
Hello everyone.

I'm trying linux kernel 2.6.38.8 together with xenomai 2.5.6.
My application tries to reuse already created rt_queue shared between couple of 
similiar applications.
When I try to recreate already existing rt_queue by rt_queue_create i get 
-EEXIST error (as I expected).
But if I try to bind it immediately with rt_queue_bind(&queue, QUEUE_NAME, 
TM_NONBLOCK) I get -EACCES error.
This error code is not in documentation and with the previously used version 
(kernel 2.6.32.6, xenomai 2.4.10) it was working fine.
Do you have any advice or suggestion?

-EACCESS is returned in case an attempt is made to use a binding service
which does not match the target object. E.g. using rt_queue_bind() for
binding an existing task.

Thanks in advance.

Petr Cervenka

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

--
Philippe.



#include <cstdlib>
#include <iostream>
#include <sys/mman.h>

#include <native/task.h>
#include <native/queue.h>
#include <native/timer.h>

using namespace std;

static RT_TASK task;
static RT_QUEUE queue;
static volatile bool end = false;

static void sigHandler(int sig __attribute__((unused))) {
    cout << "signal handler\n";
    end = true;
}

int main(int argc, char** argv) {
    int res;

    // lock memory
    mlockall(MCL_CURRENT | MCL_FUTURE);

    // setup signal handler
    signal(SIGINT, sigHandler);
    signal(SIGTERM, sigHandler);
    signal(SIGHUP, sigHandler);
    signal(SIGALRM, sigHandler);

    // shadow task
    cout << "rt_shadow_task\n";
    res = rt_task_shadow(
            &task,              // task
            "QSERVER",          // name
            10,                 // priority
            T_FPU               // mode T_FPU, T_CPU(i), T_SUSP, ...
            );
    if (res < 0) {
        cerr << "rt_task_shadow() failed: " << res << endl;
        goto cleanup_end;
    }

    // create queue
    cout << "rt_queue_create\n";
    res = rt_queue_create(
            &queue,             // queue
            "QQUEUE",           // name
            1000000,            // pool size
            Q_UNLIMITED,        // qlimit
            Q_FIFO | Q_SHARED   // mode
            );
    if (res == -EEXIST) {
        cout << "queue already exists, trying to bind it\n";
        cout << "rt_queue_bind\n";
        res = rt_queue_bind(&queue, "QQUEUE", TM_NONBLOCK);
    }
    if (res < 0) {
        cerr << "rt_queue_create() or rt_queue_bind() failed: " << res << endl;
        goto cleanup_task;
    }

    // endless loop
    while (!end && (res == 0 || res == -ETIMEDOUT)) {
        cout << ".";
        cout.flush();
        void *msg;
        res = rt_queue_receive(&queue, &msg, rt_timer_ns2ticks(1000000000ll));
        if (res >= 0) {
            cout << "rt_queue_free\n";
            rt_queue_free(&queue, msg);
        } else if (res != -ETIMEDOUT) {
            cerr << "rt_queue_receive() failed: " << res << endl;
        }
    }

cleanup_queue:
    cout << "rt_queue_delete\n";
    rt_queue_delete(&queue);
cleanup_task:
cleanup_end:
    cout << "application exit\n";
    return (EXIT_SUCCESS);
}
#include <cstdlib>
#include <iostream>
#include <sys/mman.h>

#include <native/task.h>
#include <native/queue.h>
#include <native/timer.h>

using namespace std;

static RT_TASK task;
static RT_QUEUE queue;
static volatile bool end = false;

static void sigHandler(int sig __attribute__((unused))) {
    cout << "signal handler\n";
    end = true;
    rt_task_unblock(&task);
}

int main(int argc, char** argv) {
    int res;

    // lock memory
    mlockall(MCL_CURRENT | MCL_FUTURE);

    // setup signal handler
    signal(SIGINT, sigHandler);
    signal(SIGTERM, sigHandler);
    signal(SIGHUP, sigHandler);
    signal(SIGALRM, sigHandler);

    // shadow task
    cout << "rt_shadow_task\n";
    res = rt_task_shadow(
            &task,          // task
            "QCLIENT",      // name
            10,             // priority
            T_FPU           // mode T_FPU, T_CPU(i), T_SUSP, ...
            );
    if (res < 0) {
        cerr << "rt_task_shadow() failed: " << res << endl;
        goto cleanup_end;
    }

    // bind queue
    cout << "rt_queue_bind\n";
    res = rt_queue_bind(&queue, "QQUEUE", TM_INFINITE);
    if (res < 0) {
        cerr << "rt_queue_bind() failed: " << res << endl;
        goto cleanup_task;
    }

    // endless loop
    while (!end) {
        cout << ".";
        cout.flush();
        rt_task_sleep(rt_timer_ns2ticks(1000000000ll));
    }

cleanup_queue:
    cout << "rt_queue_unbind\n";
    rt_queue_unbind(&queue);
cleanup_task:
cleanup_end:
    cout << "application exit\n";
    return (EXIT_SUCCESS);
}
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to