svn commit: r364695 - stable/12/sys/compat/linux
Edward Tomasz Napierala
trasz at FreeBSD.org
Mon Aug 24 15:50:58 UTC 2020
Author: trasz
Date: Mon Aug 24 15:50:57 2020
New Revision: 364695
URL: https://svnweb.freebsd.org/changeset/base/364695
Log:
MFC r347969 by dchagin:
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
Modified:
stable/12/sys/compat/linux/linux_socket.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/compat/linux/linux_socket.c
==============================================================================
--- stable/12/sys/compat/linux/linux_socket.c Mon Aug 24 15:49:37 2020 (r364694)
+++ stable/12/sys/compat/linux/linux_socket.c Mon Aug 24 15:50:57 2020 (r364695)
@@ -805,6 +805,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);
@@ -812,7 +814,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 {
More information about the svn-src-all
mailing list