Jan Kiszka : RTDM+POSIX: Avoid leaking binding objects on errors
A message that is not in the archive (sent off-list or not yet received): [email protected]
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 12 lines · GIT version control
ksrc/skins/posix/mq.c +1
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ; unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }
Ok. Will pull. But I really need to fix that.
Signature · 1 line
Gilles.
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;
Quoted 8 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Jan
Quoted 17 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Quoted 2 lines
Ack - now that I see it myself.
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Thanks,
Jan
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Gilles Chanteperdrix
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 12 lines · GIT version control
ksrc/skins/posix/mq.c +1
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ; unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Quoted 6 lines
Quoted 2 lines
Ack - now that I see it myself.
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from select() instead of letting the call fail. I beed to look into this again.
Jan
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 8 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.
It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 3 lines
Jan
Signature · 1 line
Gilles.
Quoted 24 lines · Gilles Chanteperdrix
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Jan Kiszka
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 9 lines
Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Quoted 7 lines
Quoted 4 lines
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 27 lines · Jan Kiszka
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Gilles Chanteperdrix
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 12 lines · GIT version control
ksrc/skins/posix/mq.c +1
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ; unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Quoted 5 lines
Quoted 2 lines
Ack - now that I see it myself.
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.
Quoted 7 lines
Quoted 2 lines
It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 3 lines
Jan
Signature · 1 line
Gilles.
Quoted 37 lines · Gilles Chanteperdrix
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 27 lines · Jan Kiszka
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Gilles Chanteperdrix
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 12 lines · GIT version control
ksrc/skins/posix/mq.c +1
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ; unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Quoted 5 lines
Quoted 2 lines
Ack - now that I see it myself.
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.Quoted 6 lines
Quoted 2 lines
It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
Quoted 4 lines
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 19 lines · Jan Kiszka
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 6 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
First draft of a fix that so far does what it is supposed to do, comments welcome:
ksrc/skins/posix/syscall.c +14 -7
@@ -2298,24 +2298,30 @@ static int select_bind_one(struct xnselector *selector, unsigned type, int fd) }static int select_bind_all (struct xnselector *selector, -fd_set *fds[XNSELECT_MAX_TYPES ],int nfds) +fd_set *in_fds[XNSELECT_MAX_TYPES ], +fd_set *out_fds[XNSELECT_MAX_TYPES ],int nfds) {unsigned fd, type; +int pending =0 ;int err;for (type =0 ; type <XNSELECT_MAX_TYPES ; type++) { -fd_set *set = fds[type]; +fd_set *set = in_fds[type];if (set)for (fd =find_first_bit (set->fds_bits, nfds); fd < nfds; fd =find_next_bit (set->fds_bits, nfds, fd +1 )) { err =select_bind_one (selector, type, fd); -if (err) -return err; +if (err) { +if (err != -EIDRM ) +return err; +__FD_SET (fd, out_fds[type]); + pending++; + } } } -return 0 ; +return pending; }/* int select(int, fd_set *, fd_set *, fd_set *, struct timeval *) */
@@ -2387,7 +2393,7 @@ static int __select(struct pt_regs *regs)/* Bind directly the file descriptors, we do not need to go through xnselect returning -ECHRNG */ -if ((err =select_bind_all (selector, in_fds, nfds))) +if ((err =select_bind_all (selector, in_fds, out_fds, nfds)))return err; }
@@ -2395,7 +2401,8 @@ static int __select(struct pt_regs *regs) err =xnselect (selector, out_fds, in_fds, nfds, timeout, mode);if (err == -ECHRNG ) { -int err =select_bind_all (selector, out_fds, nfds); +int err =select_bind_all (selector, out_fds, out_fds, + nfds);if (err)return err; }
Quoted 79 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 6 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
First draft of a fix that so far does what it is supposed to do, comments welcome:
ksrc/skins/posix/syscall.c +12
-6@@ -2298,24 +2298,30 @@ static int select_bind_one(struct xnselector *selector, unsigned type, int fd) }static int select_bind_all (struct xnselector *selector, -fd_set *fds[XNSELECT_MAX_TYPES ],int nfds) +fd_set *in_fds[XNSELECT_MAX_TYPES ], +fd_set *out_fds[XNSELECT_MAX_TYPES ],int nfds) {unsigned fd, type; +int pending =0 ;int err;for (type =0 ; type <XNSELECT_MAX_TYPES ; type++) { -fd_set *set = fds[type]; +fd_set *set = in_fds[type];if (set)for (fd =find_first_bit (set->fds_bits, nfds); fd < nfds; fd =find_next_bit (set->fds_bits, nfds, fd +1 )) { err =select_bind_one (selector, type, fd); -if (err) -return err; +if (err) { +if (err != -EIDRM ) +return err; +__FD_SET (fd, out_fds[type]); + pending++; + } } } -return 0 ; +return pending; }/* int select(int, fd_set *, fd_set *, fd_set *, struct timeval *) */ @@ -2387,7 +2393,7 @@ static int __select(struct pt_regs *regs)/* Bind directly the file descriptors, we do not need to go through xnselect returning -ECHRNG */ -if ((err =select_bind_all (selector, in_fds, nfds))) +if ((err =select_bind_all (selector, in_fds, out_fds, nfds)))return err; }
ksrc/skins/posix/syscall.c static int __select(struct pt_regs *regs) · line 2405
Quoted 6 lines
ksrc/skins/posix/syscall.c +2
-1@@ -2395,7 +2401,8 @@ static int __select(struct pt_regs *regs) err =xnselect (selector, out_fds, in_fds, nfds, timeout, mode);if (err == -ECHRNG ) { -int err =select_bind_all (selector, out_fds, nfds); +int err =select_bind_all (selector, out_fds, out_fds, + nfds);
Mmh, this is probably no good idea, need to truly split in (aka "no yet bound") and out (aka "pending") sets here as well.
ksrc/skins/posix/syscall.c static int __select(struct pt_regs *regs) · line 2408
Quoted 3 lines
ksrc/skins/posix/syscall.c +0
-0if (err)return err; }
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 42 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
Signature · 1 line
Gilles.
Quoted 48 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).
Just pushed the corresponding fix.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 53 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
Quoted 7 lines
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).Just pushed the corresponding fix.
I really do not understand what you are trying to do. What is the problem exactly, and how do you fix it? You are reserving 384 more bytes on the stack. What for?
Signature · 1 line
Gilles.
Quoted 59 lines · Gilles Chanteperdrix
Quoted 58 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).
Quoted 6 lines
Quoted 1 line
Just pushed the corresponding fix.
I really do not understand what you are trying to do. What is the problem exactly, and how do you fix it? You are reserving 384 more bytes on the stack. What for?
"We already return an fd as pending if the corresponding xnsynch object is delete while waiting on it. Extend select to do the same if the object is already marked deleted on binding.
This fixes the return code select on half-closed RTnet TCP sockets from -EIDRM to > 0 (for pending fds)."
HTH.
Regarding the additional stack requirements - yes, not nice. Maybe we can avoid this by clearing the in_fds in select_bind_all while processing it unless an fd is marked deleted. Would also avoid passing a separate fds to it.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 73 lines · Jan Kiszka
Quoted 59 lines · Gilles Chanteperdrix
Quoted 58 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
diff --git a/ksrc/skins/posix/mq.c b/ksrc/skins/posix/mq.c
index 11f47c0..a896031 100644
--- a/ksrc/skins/posix/mq.c
+++ b/ksrc/skins/posix/mq.c
@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,
return 0;Quoted 7 lines
Quoted 5 lines
unlock_and_error:
+ xnfree(binding):
xnlock_put_irqrestore(&nklock, s);
return err;
}Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).Quoted 5 lines
Quoted 1 line
Just pushed the corresponding fix.
I really do not understand what you are trying to do. What is the problem exactly, and how do you fix it? You are reserving 384 more bytes on the stack. What for?
"We already return an fd as pending if the corresponding xnsynch object is delete while waiting on it. Extend select to do the same if the object is already marked deleted on binding.
This fixes the return code select on half-closed RTnet TCP sockets from
-EIDRMto > 0 (for pending fds)."
Quoted 6 lines
HTH.
Regarding the additional stack requirements - yes, not nice. Maybe we can avoid this by clearing the
in_fdsinselect_bind_allwhile processing it unless an fd is marked deleted. Would also avoid passing a separate fds to it.
I do not like calling FD_ZERO all the time either. Please take the time to explain me your implementation (I understood the reason, not the implementation itself), and to think calmly about the implementation. I am not going to merge anything before tonight anyway.
Signature · 1 line
Gilles.
Quoted 73 lines · Jan Kiszka
Quoted 59 lines · Gilles Chanteperdrix
Quoted 58 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
diff --git a/ksrc/skins/posix/mq.c b/ksrc/skins/posix/mq.c
index 11f47c0..a896031 100644
--- a/ksrc/skins/posix/mq.c
+++ b/ksrc/skins/posix/mq.c
@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,
return 0;Quoted 7 lines
Quoted 5 lines
unlock_and_error:
+ xnfree(binding):
xnlock_put_irqrestore(&nklock, s);
return err;
}Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).Quoted 5 lines
Quoted 1 line
Just pushed the corresponding fix.
I really do not understand what you are trying to do. What is the problem exactly, and how do you fix it? You are reserving 384 more bytes on the stack. What for?
"We already return an fd as pending if the corresponding xnsynch object is delete while waiting on it. Extend select to do the same if the object is already marked deleted on binding.
This fixes the return code select on half-closed RTnet TCP sockets from
-EIDRMto > 0 (for pending fds)."
Quoted 6 lines
HTH.
Regarding the additional stack requirements - yes, not nice. Maybe we can avoid this by clearing the
in_fdsinselect_bind_allwhile processing it unless an fd is marked deleted. Would also avoid passing a separate fds to it.
To be more precise, it looks to me like each call to bind_one is supposed to set the bit of the corresponding fd, so, if bind_one fails because the fd is in the transitory state (the one which I do not like), bind_all should simply set this bit to 1. And there does not seem to be any need for additional parameters, additional space on stack, or anything else.
Signature · 1 line
Gilles.
Quoted 80 lines · Gilles Chanteperdrix
Quoted 72 lines · Jan Kiszka
Quoted 59 lines · Gilles Chanteperdrix
Quoted 58 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 15 lines · Gilles Chanteperdrix
GIT version control wrote:
diff --git a/ksrc/skins/posix/mq.c b/ksrc/skins/posix/mq.c
index 11f47c0..a896031 100644
--- a/ksrc/skins/posix/mq.c
+++ b/ksrc/skins/posix/mq.c
@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,
return 0;unlock_and_error:
+ xnfree(binding):
xnlock_put_irqrestore(&nklock, s);
return err;
}
Ok. Will pull. But I really need to fix that.Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).Quoted 5 lines
Quoted 1 line
Just pushed the corresponding fix.
I really do not understand what you are trying to do. What is the problem exactly, and how do you fix it? You are reserving 384 more bytes on the stack. What for?
"We already return an fd as pending if the corresponding xnsynch object is delete while waiting on it. Extend select to do the same if the object is already marked deleted on binding.
This fixes the return code select on half-closed RTnet TCP sockets from
-EIDRMto > 0 (for pending fds)."Quoted 6 lines
HTH.
Regarding the additional stack requirements - yes, not nice. Maybe we can avoid this by clearing the
in_fdsinselect_bind_allwhile processing it unless an fd is marked deleted. Would also avoid passing a separate fds to it.
Quoted 6 lines
To be more precise, it looks to me like each call to
bind_oneis supposed to set the bit of the corresponding fd, so, ifbind_onefails because the fd is in the transitory state (the one which I do not like),bind_allshould simply set this bit to 1. And there does not seem to be any need for additional parameters, additional space on stack, or anything else.
Right, the trick is likely to properly maintain the output fds of bind_all in that not only pending fds are set, but others are cleared - avoids the third bitmap. Still playing with such an approach.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 87 lines · Jan Kiszka
Quoted 79 lines · Gilles Chanteperdrix
Quoted 72 lines · Jan Kiszka
Quoted 59 lines · Gilles Chanteperdrix
Quoted 58 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Gilles Chanteperdrix wrote:
GIT version control wrote:
diff --git a/ksrc/skins/posix/mq.c b/ksrc/skins/posix/mq.c
index 11f47c0..a896031 100644
--- a/ksrc/skins/posix/mq.c
+++ b/ksrc/skins/posix/mq.c
@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,
return 0;unlock_and_error:
+ xnfree(binding):
xnlock_put_irqrestore(&nklock, s);
return err;
}
Ok. Will pull. But I really need to fix that.Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).Quoted 5 lines
Quoted 1 line
Just pushed the corresponding fix.
I really do not understand what you are trying to do. What is the problem exactly, and how do you fix it? You are reserving 384 more bytes on the stack. What for?
"We already return an fd as pending if the corresponding xnsynch object is delete while waiting on it. Extend select to do the same if the object is already marked deleted on binding.
This fixes the return code select on half-closed RTnet TCP sockets from
-EIDRMto > 0 (for pending fds)."Quoted 6 lines
HTH.
Regarding the additional stack requirements - yes, not nice. Maybe we can avoid this by clearing the
in_fdsinselect_bind_allwhile processing it unless an fd is marked deleted. Would also avoid passing a separate fds to it.Quoted 6 lines
To be more precise, it looks to me like each call to
bind_oneis supposed to set the bit of the corresponding fd, so, ifbind_onefails because the fd is in the transitory state (the one which I do not like),bind_allshould simply set this bit to 1. And there does not seem to be any need for additional parameters, additional space on stack, or anything else.
Quoted 3 lines
Right, the trick is likely to properly maintain the output fds of
bind_allin that not only pending fds are set, but others are cleared - avoids the third bitmap. Still playing with such an approach.
xnselect_bind, called by bind_one should take care of setting/clearing individual bits, at least, it is the way it currently works.
Signature · 1 line
Gilles.
Quoted 87 lines · Jan Kiszka
Quoted 79 lines · Gilles Chanteperdrix
Quoted 72 lines · Jan Kiszka
Quoted 59 lines · Gilles Chanteperdrix
Quoted 58 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Gilles Chanteperdrix wrote:
GIT version control wrote:
diff --git a/ksrc/skins/posix/mq.c b/ksrc/skins/posix/mq.c
index 11f47c0..a896031 100644
--- a/ksrc/skins/posix/mq.c
+++ b/ksrc/skins/posix/mq.c
@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,
return 0;unlock_and_error:
+ xnfree(binding):
xnlock_put_irqrestore(&nklock, s);
return err;
}
Ok. Will pull. But I really need to fix that.Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that. Keep in mind that this pattern is in use even without select support. Diverging from it just to add select awareness to some driver would be a step back.
Quoted 4 lines
Ok. As you wish. But in that case, please provide a unit test case which we can run on all architectures to validate your modifications. We will not put this test case in xenomai repository but will create a repository for test cases later on.
As it requires quite some infrastructure to get there (or do I miss some preexisting select unit test?), I can just point to RTnet + TCP for now:
run rtnet/examples/xenomai/posix/rttcp-server + client over rtlo and terminate the client prematurely. This does not happen if you run the very same test without RTnet loaded (ie. against Linux' TCP).Quoted 5 lines
Quoted 1 line
Just pushed the corresponding fix.
I really do not understand what you are trying to do. What is the problem exactly, and how do you fix it? You are reserving 384 more bytes on the stack. What for?
"We already return an fd as pending if the corresponding xnsynch object is delete while waiting on it. Extend select to do the same if the object is already marked deleted on binding.
This fixes the return code select on half-closed RTnet TCP sockets from
-EIDRMto > 0 (for pending fds)."Quoted 6 lines
HTH.
Regarding the additional stack requirements - yes, not nice. Maybe we can avoid this by clearing the
in_fdsinselect_bind_allwhile processing it unless an fd is marked deleted. Would also avoid passing a separate fds to it.Quoted 6 lines
To be more precise, it looks to me like each call to
bind_oneis supposed to set the bit of the corresponding fd, so, ifbind_onefails because the fd is in the transitory state (the one which I do not like),bind_allshould simply set this bit to 1. And there does not seem to be any need for additional parameters, additional space on stack, or anything else.
Quoted 3 lines
Right, the trick is likely to properly maintain the output fds of
bind_allin that not only pending fds are set, but others are cleared - avoids the third bitmap. Still playing with such an approach.
Another precision, xnselect_bind accesses directly the "pending" set of the xnselector structure, so, you have the right to do that for the fds which failed binding but which you want to mark as pending.
Quoted 3 lines
Jan
Signature · 1 line
Gilles.
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Gilles Chanteperdrix
To be more precise, it looks to me like each call to
bind_oneis supposed to set the bit of the corresponding fd, so, ifbind_onefails because the fd is in the transitory state (the one which I do not like),bind_allshould simply set this bit to 1. And there does not seem to be any need for additional parameters, additional space on stack, or anything else.
Quoted 7 lines
Quoted 3 lines
Right, the trick is likely to properly maintain the output fds of
bind_allin that not only pending fds are set, but others are cleared - avoids the third bitmap. Still playing with such an approach.Another precision,
xnselect_bindaccesses directly the "pending" set of the xnselector structure, so, you have the right to do that for the fds which failed binding but which you want to mark as pending.
Right, /me was blind, the issue can trivially be fixed inside RTDM by binding as pending even if the object is marked deleted. I'm now just cleaning up some other RTDM bits at this chance, pull request will follow.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 3 lines · Jan Kiszka
Right, the trick is likely to properly maintain the output fds of
bind_allin that not only pending fds are set, but others are cleared - avoids the third bitmap. Still playing with such an approach.
What we are trying to do, in a nutshell, is to create a notion of stateless binding between a file descriptor and an xnselector. If we really want to do this, we will have to extend the xnselect interface. But this looks really wrong to me.
It seems possible to keep the bindings around as long as the file descriptor exists. The binding is here for this reason, to express the link between the file descriptor and the thread which runs select, and its lifecycle should be the same as the file descriptor. And if you want to signal that such a file descriptor is ready for reading/writing, even if it is closed, you should be using xnselect_signal. The interface is there, it is meant for that.
So, the more I think about it, the more I think that we are going in the wrong direction.
Signature · 1 line
Gilles.
Quoted 42 lines · Jan Kiszka
Quoted 32 lines · Gilles Chanteperdrix
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 20 lines · Jan Kiszka
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Jan Kiszka
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · GIT version control
ksrc/skins/posix/mq.c +0
-0@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector,return 0 ;Quoted 7 lines
ksrc/skins/posix/mq.c int pse51_mq_select_bind(mqd_t fd, struct xnselector *selector, · line 1289
Quoted 5 lines
ksrc/skins/posix/mq.c +1
-0unlock_and_error: + xnfree(binding):xnlock_put_irqrestore (&nklock, s);return err; }Ok. Will pull. But I really need to fix that.
Ack - now that I see it myself.
Quoted 7 lines
Quoted 3 lines
I fixed this in my branch and added another patch to transform EIDRM into EBADF when selecting a (half-)deleted RTDM device. Please merge.
Wait! When the sync object behind some file descriptor is deleted but the descriptor itself is still existing, we rather have to return that fd signaled from
select()instead of letting the call fail. I beed to look into this again.It looks to me like a transitory state, we can wait for the sync object to be deleted to have the fd destructor signaled. It should not be long.
Quoted 8 lines
Quoted 4 lines
That's not an issue of waiting for this. See e.g. TCP: peer closes connection -> internal sync objects will be destroyed (to make read/write fail). But the fd will remain valid until the local side closes it as well.
It looks to me like this is going to complicate things a lot, and will be a source of regressions. Why can we not have sync objects be destroyed when the fd is really destroyed and use a status bit of some kind to signal read/write that the fd was closed by peer?
Quoted 5 lines
It is way easier and more consistent to unblock reader and writers via destroying the sync object than to signal it and add tests for specific states to detect that.
From my point of view, having an object with partially destroyed parts
is asking for trouble.
Signature · 1 line
Gilles.