Disallow listen() on sockets which are in the SS_ISCONNECTED or

SS_ISCONNECTING state, returning EINVAL (which is what POSIX mandates
in this case).
listen() on connected or connecting sockets would cause them to enter
a bad state; in the TCP case, this could cause sockets to go
catatonic or panics, depending on how the socket was connected.

Reviewed by:	-net
MFC after:	2 weeks
This commit is contained in:
Thomas Moestl 2003-01-17 19:20:00 +00:00
parent 5269d202cc
commit 6f7cab9301
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109439

View file

@ -266,6 +266,10 @@ solisten(so, backlog, td)
int s, error;
s = splnet();
if (so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING)) {
splx(s);
return (EINVAL);
}
error = (*so->so_proto->pr_usrreqs->pru_listen)(so, td);
if (error) {
splx(s);