Date: Sun, 19 May 2019 09:23:20 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347969 - head/sys/compat/linux Message-ID: <201905190923.x4J9NKOT041625@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Sun May 19 09:23:20 2019 New Revision: 347969 URL: https://svnweb.freebsd.org/changeset/base/347969 Log: Linux send() call returns EAGAIN instead of ENOTCONN in case when the socket is non-blocking and connect() is not finished yet. Initial patch developed by Steven Hartland in 2008 and adopted by me. PR: 129169 Reported by: smh@ MFC after: 2 weeks Modified: head/sys/compat/linux/linux_socket.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Sun May 19 09:18:09 2019 (r347968) +++ head/sys/compat/linux/linux_socket.c Sun May 19 09:23:20 2019 (r347969) @@ -798,6 +798,8 @@ linux_send(struct thread *td, struct linux_send_args * caddr_t to; int tolen; } */ bsd_args; + struct file *fp; + int error, fflag; bsd_args.s = args->s; bsd_args.buf = (caddr_t)PTRIN(args->msg); @@ -805,7 +807,21 @@ linux_send(struct thread *td, struct linux_send_args * bsd_args.flags = args->flags; bsd_args.to = NULL; bsd_args.tolen = 0; - return (sys_sendto(td, &bsd_args)); + error = sys_sendto(td, &bsd_args); + if (error == ENOTCONN) { + /* + * Linux doesn't return ENOTCONN for non-blocking sockets. + * Instead it returns the EAGAIN. + */ + error = getsock_cap(td, args->s, &cap_send_rights, &fp, + &fflag, NULL); + if (error == 0) { + if (fflag & FNONBLOCK) + error = EAGAIN; + fdrop(fp, td); + } + } + return (error); } struct linux_recv_args {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905190923.x4J9NKOT041625>