Page MenuHomeFreeBSD

D42637.id.diff
No OneTemporary

D42637.id.diff

diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c
--- a/sys/netgraph/ng_ksocket.c
+++ b/sys/netgraph/ng_ksocket.c
@@ -152,6 +152,10 @@
/* Helper functions */
static int ng_ksocket_accept(priv_p);
+static int ng_ksocket_listen_upcall(struct socket *so, void *arg,
+ int waitflag);
+static void ng_ksocket_listen_upcall2(node_p node, hook_p hook,
+ void *arg1, int arg2);
static int ng_ksocket_incoming(struct socket *so, void *arg, int waitflag);
static int ng_ksocket_parse(const struct ng_ksocket_alias *aliases,
const char *s, int family);
@@ -695,6 +699,12 @@
/* Listen */
so->so_state |= SS_NBIO;
error = solisten(so, *((int32_t *)msg->data), td);
+ if (error == 0) {
+ SOLISTEN_LOCK(so);
+ solisten_upcall_set(so,
+ ng_ksocket_listen_upcall, priv);
+ SOLISTEN_UNLOCK(so);
+ }
break;
}
@@ -715,11 +725,15 @@
/*
* If a connection is already complete, take it.
* Otherwise let the upcall function deal with
- * the connection when it comes in.
+ * the connection when it comes in. Don't return
+ * EWOULDBLOCK, per ng_ksocket(4) documentation.
*/
error = ng_ksocket_accept(priv);
- if (error != 0 && error != EWOULDBLOCK)
+ if (error == EWOULDBLOCK)
+ error = 0;
+ if (error != 0)
ERROUT(error);
+
priv->response_token = msg->header.token;
priv->response_addr = NGI_RETADDR(item);
break;
@@ -1064,10 +1078,6 @@
}
}
- /* Check whether a pending accept operation has completed */
- if (priv->flags & KSF_ACCEPTING)
- (void )ng_ksocket_accept(priv);
-
/*
* If we don't have a hook, we must handle data events later. When
* the hook gets created and is connected, this upcall function
@@ -1250,6 +1260,25 @@
return (0);
}
+static int
+ng_ksocket_listen_upcall(struct socket *so, void *arg, int waitflag)
+{
+ priv_p priv = arg;
+ int wait = ((waitflag & M_WAITOK) ? NG_WAITOK : 0) | NG_QUEUE;
+
+ ng_send_fn1(priv->node, NULL, &ng_ksocket_listen_upcall2, priv, 0,
+ wait);
+ return (SU_OK);
+}
+
+static void
+ng_ksocket_listen_upcall2(node_p node, hook_p hook, void *arg1, int arg2)
+{
+ const priv_p priv = NG_NODE_PRIVATE(node);
+
+ (void )ng_ksocket_accept(priv);
+}
+
/*
* Parse out either an integer value or an alias.
*/

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 1:06 AM (4 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14524458
Default Alt Text
D42637.id.diff (2 KB)

Event Timeline