* When incoming data is appended to the socket, we get notified here. * This is also called whenever a significant event occurs for the socket. * Our original caller may have queued this even some time ago and * we cannot trust that he even still exists. The node however is being * held with a reference by the queueing code and guarantied to be valid. */
| 1023 | * held with a reference by the queueing code and guarantied to be valid. |
| 1024 | */ |
| 1025 | static void |
| 1026 | ng_ksocket_incoming2(node_p node, hook_p hook, void *arg1, int arg2) |
| 1027 | { |
| 1028 | struct socket *so = arg1; |
| 1029 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 1030 | struct ng_mesg *response; |
| 1031 | int error; |
| 1032 | |
| 1033 | KASSERT(so == priv->so, ("%s: wrong socket", __func__)); |
| 1034 | |
| 1035 | /* Allow next incoming event to be queued. */ |
| 1036 | atomic_store_rel_int(&priv->fn_sent, 0); |
| 1037 | |
| 1038 | /* Check whether a pending connect operation has completed */ |
| 1039 | if (priv->flags & KSF_CONNECTING) { |
| 1040 | if ((error = so->so_error) != 0) { |
| 1041 | so->so_error = 0; |
| 1042 | so->so_state &= ~SS_ISCONNECTING; |
| 1043 | } |
| 1044 | if (!(so->so_state & SS_ISCONNECTING)) { |
| 1045 | NG_MKMESSAGE(response, NGM_KSOCKET_COOKIE, |
| 1046 | NGM_KSOCKET_CONNECT, sizeof(int32_t), M_NOWAIT); |
| 1047 | if (response != NULL) { |
| 1048 | response->header.flags |= NGF_RESP; |
| 1049 | response->header.token = priv->response_token; |
| 1050 | *(int32_t *)response->data = error; |
| 1051 | /* |
| 1052 | * send an async "response" message |
| 1053 | * to the node that set us up |
| 1054 | * (if it still exists) |
| 1055 | */ |
| 1056 | NG_SEND_MSG_ID(error, node, |
| 1057 | response, priv->response_addr, 0); |
| 1058 | } |
| 1059 | priv->flags &= ~KSF_CONNECTING; |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | /* Check whether a pending accept operation has completed */ |
| 1064 | if (priv->flags & KSF_ACCEPTING) |
| 1065 | (void )ng_ksocket_accept(priv); |
| 1066 | |
| 1067 | /* |
| 1068 | * If we don't have a hook, we must handle data events later. When |
| 1069 | * the hook gets created and is connected, this upcall function |
| 1070 | * will be called again. |
| 1071 | */ |
| 1072 | if (priv->hook == NULL) |
| 1073 | return; |
| 1074 | |
| 1075 | /* Read and forward available mbufs. */ |
| 1076 | while (1) { |
| 1077 | struct uio uio; |
| 1078 | struct sockaddr *sa; |
| 1079 | struct mbuf *m; |
| 1080 | int flags; |
| 1081 | |
| 1082 | /* Try to get next packet from socket. */ |
nothing calls this directly
no test coverage detected