Module: xenomai-3
Branch: wip/dovetail
Commit: c854d7b39976884f2d44367b19020a11f2c7ffd0
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c854d7b39976884f2d44367b19020a11f2c7ffd0

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Feb 12 17:00:54 2016 +0100

cobalt/registry: return -EAGAIN upon lack of registry slot

-ENOMEM is confusing in this case, does not actually reflect the error
condition, and does not match the error code commonly returned by
POSIX services for denoting a (temporary) lack of resources.
Besides, this source of error was not even mentioned in the
documentation of the affected services.

All error codes must be detected, and any program that might have
specifically checked for -ENOMEM during error recovery in the affected
services was potentially confused, so this change does not introduce a
significant ABI variation.

---

 include/rtdm/uapi/ipc.h     |    3 ++-
 kernel/cobalt/registry.c    |    2 +-
 kernel/cobalt/rtdm/device.c |    3 +++
 lib/cobalt/cond.c           |    1 +
 lib/cobalt/mq.c             |    1 +
 lib/cobalt/mutex.c          |    1 +
 lib/cobalt/semaphore.c      |    1 +
 7 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/rtdm/uapi/ipc.h b/include/rtdm/uapi/ipc.h
index a558150..432cd9b 100644
--- a/include/rtdm/uapi/ipc.h
+++ b/include/rtdm/uapi/ipc.h
@@ -174,7 +174,8 @@ int close__AF_RTIPC(int sockfd);
  *   - -ENOMEM (Not enough memory)
  *   - -EINVAL (Invalid parameter)
  *   - -EADDRINUSE (Socket already bound to a port, or no port available)
- *   .
+ *   - -EAGAIN (no registry slot available, check/raise
+ *     CONFIG_XENO_OPT_REGISTRY_NRSLOTS) .
  *
  * @par Calling context:
  * non-RT
diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index ba46bd0..9d14863 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -637,7 +637,7 @@ int xnregistry_enter(const char *key, void *objaddr,
        xnlock_get_irqsave(&nklock, s);
 
        if (list_empty(&free_object_list)) {
-               ret = -ENOMEM;
+               ret = -EAGAIN;
                goto unlock_and_exit;
        }
 
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 9c5aeb1..660f61c 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -352,6 +352,9 @@ static void unregister_driver(struct rtdm_driver *drv)
  * - -ENOMEM is returned if a memory allocation failed in the process
  * of registering the device.
  *
+ * - -EAGAIN is returned if no registry slot is available (check/raise
+ * CONFIG_XENO_OPT_REGISTRY_NRSLOTS).
+ *
  * @coretags{secondary-only}
  */
 int rtdm_dev_register(struct rtdm_device *dev)
diff --git a/lib/cobalt/cond.c b/lib/cobalt/cond.c
index 7eeb9e6..00a2018 100644
--- a/lib/cobalt/cond.c
+++ b/lib/cobalt/cond.c
@@ -103,6 +103,7 @@ void cobalt_default_condattr_init(void)
  * - EBUSY, the condition variable @a cond was already initialized;
  * - ENOMEM, insufficient memory available from the system heap to initialize 
the
  *   condition variable, increase CONFIG_XENO_OPT_SYS_HEAPSZ.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  *
  * @see
  * <a 
href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_cond_init.html";>
diff --git a/lib/cobalt/mq.c b/lib/cobalt/mq.c
index a361688..471d9b3 100644
--- a/lib/cobalt/mq.c
+++ b/lib/cobalt/mq.c
@@ -93,6 +93,7 @@
  * - EPERM, attempting to create a message queue from an invalid context;
  * - EINVAL, the @a attr argument is invalid;
  * - EMFILE, too many descriptors are currently open.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  *
  * @see
  * <a 
href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_open.html";>
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 979c91b..9d8a914 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -98,6 +98,7 @@ void cobalt_mutex_init(void)
  * - EAGAIN, insufficient memory available to initialize the
  *   mutex, increase CONFIG_XENO_OPT_SHARED_HEAPSZ for a process-shared
  *   mutex, or CONFIG_XENO_OPT_PRIVATE_HEAPSZ for a process-private mutex.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  *
  * @see
  * <a 
href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_mutex_init.html";>
diff --git a/lib/cobalt/semaphore.c b/lib/cobalt/semaphore.c
index 5a69968..45705d4 100644
--- a/lib/cobalt/semaphore.c
+++ b/lib/cobalt/semaphore.c
@@ -75,6 +75,7 @@ struct cobalt_sem_state *sem_get_state(struct 
cobalt_sem_shadow *shadow)
  * - EAGAIN, insufficient memory available to initialize the
  *   semaphore, increase CONFIG_XENO_OPT_SHARED_HEAPSZ for a process-shared
  *   semaphore, or CONFIG_XENO_OPT_PRIVATE_HEAPSZ for a process-private 
semaphore.
+ * - EAGAIN, no registry slot available, check/raise 
CONFIG_XENO_OPT_REGISTRY_NRSLOTS.
  * - EINVAL, the @a value argument exceeds @a SEM_VALUE_MAX.
  *
  * @see


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to