You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/03/19 03:40:32 UTC
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 edited a comment on pull request #619: dhcpd/telnet: don't need to dupcalite listen socket when task_create
xiaoxiang781216 edited a comment on pull request #619:
URL: https://github.com/apache/incubator-nuttx-apps/pull/619#issuecomment-802524079
> > @Donny9
> > Thanks, telnetd works now.
> > By the way, I noticed that webserver and ftpd work without modification.
> > Could you tell me why only telnetd and dhcpd need to be modified?
>
> @masayuki2009 I just checked ftpd daemon, it doesn't need to modify because ftpd_startworker will create a work thread for new connection by pthread_create API, the filelist duplicate don't occur when pthread_create. And the thttpd webserver used poll(fdwatch) to monitor the fd when a new connections occurs, the new thread or task doesn't be created, so it doesn't need to modify.
> The root cause is if parent task has socket(listened,not connect), child task will fail when it is created because the dup operate(psock_dup2) will fail.
@masayuki2009, here is more detail analysis:
https://github.com/apache/incubator-nuttx/pull/3045 check the file duplication result(ignore before this PR):
https://github.com/apache/incubator-nuttx/commit/e96c8b9283ddbdc329e96d262aefc9bb199d5578#diff-3e4edca12a292d53823387fc8d11439c7f1efe7702f80962193bdff8f3c27045L154-R83
and expose an old bug happen in tcp socket dup here:
https://github.com/apache/incubator-nuttx/blob/master/net/socket/net_dup2.c#L102
https://github.com/apache/incubator-nuttx/blob/37d5c1b0d93290212b7a7a246bd5845f8f0dd3cd/net/tcp/tcp_monitor.c#L257-L270
Since the listen socket isn't in TCP_ESTABLISHED or TCP_SYN_RCVD state, tcp_start_monitor return fail and then fail to create the new task.
So the fix has two part:
1. Add SOCK_CLOEXEC to server who spawn the child task, but the sock don't child inherited from
2. Fix the error in psock_dup2 which will provide by @anchao soon.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org