Module: xenomai-head
Branch: master
Commit: 927283852001f368b649aa97814472f544f4e254
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=927283852001f368b649aa97814472f544f4e254

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Sep  8 15:48:06 2009 +0200

rtipc: fix iddp/xddp context for _RTIOC_BIND

---

 ksrc/drivers/ipc/iddp.c |   23 ++++++++++-------------
 ksrc/drivers/ipc/xddp.c |   35 +++++++++++++++--------------------
 2 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/ksrc/drivers/ipc/iddp.c b/ksrc/drivers/ipc/iddp.c
index 273f428..174c1f0 100644
--- a/ksrc/drivers/ipc/iddp.c
+++ b/ksrc/drivers/ipc/iddp.c
@@ -854,7 +854,13 @@ static int __iddp_ioctl(struct iddp_socket *sk,
                break;
 
        case _RTIOC_BIND:
-               return -ENOSYS; /* Downgrade to NRT */
+               ret = rtipc_get_sockaddr(user_info, arg, &saddrp);
+               if (ret)
+                       return ret;
+               if (saddrp == NULL)
+                       return -EFAULT;
+               ret = __iddp_bind_socket(sk, saddrp);
+               break;
 
        case _RTIOC_GETSOCKNAME:
                ret = rtipc_put_sockaddr(user_info, arg, &sk->name);
@@ -893,20 +899,11 @@ static int iddp_ioctl(struct rtipc_private *priv,
                      unsigned int request, void *arg)
 {
        struct iddp_socket *sk = priv->state;
-       struct sockaddr_ipc saddr, *saddrp;
-       int ret;
-
-       if (rtdm_in_rt_context() || request != _RTIOC_BIND)
-               return __iddp_ioctl(sk, user_info, request, arg);
 
-       saddrp = &saddr;
-       ret = rtipc_get_sockaddr(user_info, arg, &saddrp);
-       if (ret)
-               return ret;
-       if (saddrp == NULL)
-               return -EFAULT;
+       if (rtdm_in_rt_context() && request == _RTIOC_BIND)
+               return -ENOSYS; /* Try downgrading to NRT */
 
-       return __iddp_bind_socket(sk, saddrp);
+       return __iddp_ioctl(sk, user_info, request, arg);
 }
 
 static int __init iddp_init(void)
diff --git a/ksrc/drivers/ipc/xddp.c b/ksrc/drivers/ipc/xddp.c
index b7d378f..39e1fa4 100644
--- a/ksrc/drivers/ipc/xddp.c
+++ b/ksrc/drivers/ipc/xddp.c
@@ -1010,22 +1010,31 @@ static int __xddp_getsockopt(struct xddp_socket *sk,
        return ret;
 }
 
-static int __xddp_ioctl(struct xddp_socket *sk,
+static int __xddp_ioctl(struct rtipc_private *priv,
                        rtdm_user_info_t *user_info,
                        unsigned int request, void *arg)
 {
-       struct sockaddr_ipc saddr, *saddrp;
+       struct sockaddr_ipc saddr, *saddrp = &saddr;
+       struct xddp_socket *sk = priv->state;
        int ret = 0;
 
        switch (request) {
        
        case _RTIOC_CONNECT:
-               saddrp = &saddr;
                ret = rtipc_get_sockaddr(user_info, arg, &saddrp);
                if (ret == 0)
                        ret = __xddp_connect_socket(sk, saddrp);
                break;
 
+       case _RTIOC_BIND:
+               ret = rtipc_get_sockaddr(user_info, arg, &saddrp);
+               if (ret)
+                       return ret;
+               if (saddrp == NULL)
+                       return -EFAULT;
+               ret = __xddp_bind_socket(priv, saddrp);
+               break;
+
        case _RTIOC_GETSOCKNAME:
                ret = rtipc_put_sockaddr(user_info, arg, &sk->name);
                break;
@@ -1042,9 +1051,6 @@ static int __xddp_ioctl(struct xddp_socket *sk,
                ret = __xddp_getsockopt(sk, user_info, arg);
                break;
 
-       case _RTIOC_BIND:
-               return -ENOSYS; /* Downgrade to NRT */
-
        case _RTIOC_LISTEN:
        case _RTIOC_ACCEPT:
                ret = -EOPNOTSUPP;
@@ -1065,21 +1071,10 @@ static int xddp_ioctl(struct rtipc_private *priv,
                      rtdm_user_info_t *user_info,
                      unsigned int request, void *arg)
 {
-       struct xddp_socket *sk = priv->state;
-       struct sockaddr_ipc saddr, *saddrp;
-       int ret;
-
-       if (rtdm_in_rt_context() || request != _RTIOC_BIND)
-               return __xddp_ioctl(sk, user_info, request, arg);
-
-       saddrp = &saddr;
-       ret = rtipc_get_sockaddr(user_info, arg, &saddrp);
-       if (ret)
-               return ret;
-       if (saddrp == NULL)
-               return -EFAULT;
+       if (rtdm_in_rt_context() && request == _RTIOC_BIND)
+               return -ENOSYS; /* Try downgrading to NRT */
 
-       return __xddp_bind_socket(priv, saddrp);
+       return __xddp_ioctl(priv, user_info, request, arg);
 }
 
 struct rtipc_protocol xddp_proto_driver = {


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

Reply via email to