yangsong8-a1 opened a new pull request, #21802:
URL: https://github.com/apache/nuttx/pull/21802
## Summary
Two pty fixes found with a Bluetooth SPP to pty bridge carrying adbd on the
slave side:
- Forward PIPEIOC_SETSIZE and PIPEIOC_GETSIZE to the sink pipe, so one
program can enlarge the pipe it writes into without raising
CONFIG_PSEUDOTERM_RXBUFSIZE/TXBUFSIZE for every pty in the system.
- pty_close(): a master created with pty_register() never closed its pipes,
because its node stays registered and the reference count check only
matched the SUSv1 case. The slave never saw EOF or POLLHUP after the master
went away. Pick the expected count from the pair type.
## Impact
pty only. PIPEIOC_SETSIZE/GETSIZE on a pty now work instead of returning
ENOTTY. After the last close of a pty_register() master, the slave gets
POLLHUP and read() returns 0. Like the slave side today, a master reopened
while the slave is still open has no pipes until both sides have closed.
## Testing
Ubuntu 22.04, gcc 13.1. sim:nsh with CONFIG_PSEUDOTERM (SUSv1) plus two
pty_register() pairs (/dev/pty5, /dev/pty6) from a test app (not part of
this PR), no new warnings.
| Test | apache/master | This PR |
|---|---|---|
| /dev/ptmx open/close with data, 20 times | fails=0 | fails=0 |
| PIPEIOC_GETSIZE on master | -1, ENOTTY | 256 |
| PIPEIOC_SETSIZE 1024 on master, then GETSIZE on master / slave | -1 ENOTTY
| 0, then 1024 / 256 |
| FIONSPACE on master after SETSIZE, write 1000 bytes, read on slave | 256,
write not tried | 1024, 1000 written, 1000 read |
| BSD pair: close master, poll slave POLLIN (1 s) | 0 (timeout), read -1
EAGAIN | 1, revents POLLHUP, read 0 |
| BSD pair: close both, reopen both, write/read | 3 / 3 | 3 / 3 |
| BSD pair: reopen master while slave stays open, write | 1 | -1 EBADF |
| BSD pair: reopen slave while master stays open, write | -1 EBADF | -1
EBADF |
```
bsd: after master close, poll -> 1 revents=0x10 (POLLHUP)
bsd: slave read after hangup -> 0 errno=0
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]