Lines Matching defs:so
175 static void unp_get_locks_in_order(struct socket *so, struct socket *conn_so);
178 unp_get_locks_in_order(struct socket *so, struct socket *conn_so)
180 if (so < conn_so) {
183 struct unpcb *unp = sotounpcb(so);
186 socket_unlock(so, 0);
190 socket_lock(so, 0);
200 uipc_abort(struct socket *so)
202 struct unpcb *unp = sotounpcb(so);
208 sofree(so);
213 uipc_accept(struct socket *so, struct sockaddr **nam)
215 struct unpcb *unp = sotounpcb(so);
240 uipc_attach(struct socket *so, __unused int proto, __unused proc_t p)
242 struct unpcb *unp = sotounpcb(so);
246 return (unp_attach(so));
250 uipc_bind(struct socket *so, struct sockaddr *nam, proc_t p)
252 struct unpcb *unp = sotounpcb(so);
266 uipc_connect(struct socket *so, struct sockaddr *nam, proc_t p)
268 struct unpcb *unp = sotounpcb(so);
272 return (unp_connect(so, nam, p));
295 uipc_detach(struct socket *so)
297 struct unpcb *unp = sotounpcb(so);
308 uipc_disconnect(struct socket *so)
310 struct unpcb *unp = sotounpcb(so);
323 uipc_listen(struct socket *so, __unused proc_t p)
325 struct unpcb *unp = sotounpcb(so);
333 uipc_peeraddr(struct socket *so, struct sockaddr **nam)
335 struct unpcb *unp = sotounpcb(so);
349 uipc_rcvd(struct socket *so, __unused int flags)
351 struct unpcb *unp = sotounpcb(so);
356 switch (so->so_type) {
362 #define rcv (&so->so_rcv)
368 unp_get_locks_in_order(so, so2);
413 uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
417 struct unpcb *unp = sotounpcb(so);
431 socket_unlock(so, 0);
433 socket_lock(so, 0);
438 switch (so->so_type) {
448 error = unp_connect(so, nam, p);
459 if (so != so2)
460 unp_get_locks_in_order(so, so2);
482 if (so != so2)
494 #define snd (&so->so_snd)
500 if ((so->so_state & SS_ISCONNECTED) == 0) {
502 error = unp_connect(so, nam, p);
511 if (so->so_state & SS_CANTSENDMORE) {
519 unp_get_locks_in_order(so, so2);
525 if ((so->so_state & SS_CANTSENDMORE)) {
581 socantsendmore(so);
586 socket_unlock(so, 0);
588 socket_lock(so, 0);
600 uipc_sense(struct socket *so, void *ub, int isstat64)
602 struct unpcb *unp = sotounpcb(so);
609 blksize = so->so_snd.sb_hiwat;
610 if (so->so_type == SOCK_STREAM && unp->unp_conn != 0) {
646 uipc_shutdown(struct socket *so)
648 struct unpcb *unp = sotounpcb(so);
652 socantsendmore(so);
662 uipc_sockaddr(struct socket *so, struct sockaddr **nam)
664 struct unpcb *unp = sotounpcb(so);
685 uipc_ctloutput(struct socket *so, struct sockopt *sopt)
687 struct unpcb *unp = sotounpcb(so);
698 if (so->so_type == SOCK_STREAM)
769 unp_attach(struct socket *so)
774 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
775 switch (so->so_type) {
778 error = soreserve(so, unpst_sendspace, unpst_recvspace);
782 error = soreserve(so, unpdg_sendspace, unpdg_recvspace);
801 unp->unp_socket = so;
804 LIST_INSERT_HEAD(so->so_type == SOCK_DGRAM ?
807 so->so_pcb = (caddr_t)unp;
809 * Mark AF_UNIX socket buffers accordingly so that:
826 so->so_rcv.sb_flags |= SB_UNIX;
827 so->so_snd.sb_flags |= SB_UNIX;
932 struct socket *so = unp->unp_socket;
945 socket_unlock(so, 0);
953 socket_lock(so, 0);
969 socket_lock(so, 0);
1001 socket_lock(so, 0);
1005 socket_lock(so, 0);
1032 unp_connect(struct socket *so, struct sockaddr *nam, __unused proc_t p)
1047 unp = sotounpcb(so);
1055 socket_unlock(so, 0);
1061 socket_lock(so, 0);
1068 socket_lock(so, 0);
1075 socket_lock(so, 0);
1082 socket_lock(so, 0);
1091 socket_lock(so, 0);
1102 if (so != so2) {
1104 socket_lock(so, 0);
1112 if (so < so2) {
1114 socket_lock(so, 0);
1116 } else if (so > so2) {
1117 socket_lock(so, 0);
1124 if ((so->so_state & SS_ISCONNECTED) != 0) {
1129 if (so->so_type != so2->so_type) {
1134 if (so->so_proto->pr_flags & PR_CONNREQUIRED) {
1136 socket_unlock(so, 0);
1141 if (so != so2) {
1143 socket_lock(so, 0);
1145 socket_lock(so, 0);
1172 * process's credentials at that time so we can use
1178 /* Here we need to have both so and so2 locks and so2
1181 if (so < so2) {
1183 socket_lock(so, 0);
1186 socket_lock(so, 0);
1190 if ((so->so_state & SS_ISCONNECTED) != 0) {
1202 /* XXXMAC: recursive lock: SOCK_LOCK(so); */
1203 mac_socketpeer_label_associate_socket(so, so3);
1204 mac_socketpeer_label_associate_socket(so3, so);
1205 /* XXXMAC: SOCK_UNLOCK(so); */
1229 error = unp_connect2(so, so2);
1233 if (so != so2) {
1261 unp_connect2(struct socket *so, struct socket *so2)
1263 struct unpcb *unp = sotounpcb(so);
1266 if (so2->so_type != so->so_type)
1281 switch (so->so_type) {
1286 if (so != so2) {
1292 soisconnected(so);
1293 unp_get_locks_in_order(so, so2);
1296 soisconnected(so);
1312 so->so_usecount++;
1315 socket_unlock(so, 0);
1323 socket_lock(so, 0);
1324 soisconnected(so);
1326 unp_get_locks_in_order(so, so2);
1332 panic("unknown socket type %d in unp_connect2", so->so_type);
1343 struct socket *so2 = NULL, *so;
1347 so = unp->unp_socket;
1354 socket_unlock(so, 0);
1364 socket_lock(so, 0);
1376 if (so == so2) {
1378 socket_lock(so, 0);
1380 waitso = so;
1381 } else if (so < so2) {
1383 socket_lock(so, 0);
1389 socket_unlock(so, 0);
1392 socket_lock(so, 0);
1393 waitso = so;
1405 if (so != so2) {
1430 if (so != so2)
1436 so->so_usecount--;
1454 panic("unknown socket type %d", so->so_type);
1463 socket_unlock(so, 0);
1467 socket_lock(so,0);
1468 soisdisconnected(so);
1792 struct socket *so = unp->unp_socket;
1796 unp_get_locks_in_order(so, so2);
1805 struct socket *so = unp->unp_socket;
1807 so->so_error = errno;
1994 struct socket *so;
2040 * already marked.. if so skip it
2063 * accessible and not already marked so.
2067 (so = (struct socket *)fg->fg_data) == 0) {
2071 if (so->so_proto->pr_domain != &localdomain ||
2072 (so->so_proto->pr_flags&PR_RIGHTS) == 0) {
2081 if (so->so_rcv.sb_flags & SB_LOCK) {
2092 (void) sbwait(&so->so_rcv);
2108 unp_scan(so->so_rcv.sb_mb, unp_mark);
2116 * The bug in the orginal code is a little tricky, so I'll describe
2169 * of (shut-down) FDs, so include it in our
2188 so = (struct socket *)(tfg->fg_data);
2190 socket_lock(so, 0);
2192 sorflush(so);
2194 socket_unlock(so, 0);
2305 unp_lock(struct socket *so, int refcount, void * lr)
2312 if (so->so_pcb) {
2313 lck_mtx_lock(&((struct unpcb *)so->so_pcb)->unp_mtx);
2315 panic("unp_lock: so=%p NO PCB! lr=%p ref=0x%x\n",
2316 so, lr_saved, so->so_usecount);
2319 if (so->so_usecount < 0)
2320 panic("unp_lock: so=%p so_pcb=%p lr=%p ref=0x%x\n",
2321 so, so->so_pcb, lr_saved, so->so_usecount);
2324 so->so_usecount++;
2326 so->lock_lr[so->next_lock_lr] = lr_saved;
2327 so->next_lock_lr = (so->next_lock_lr+1) % SO_LCKDBG_MAX;
2332 unp_unlock(struct socket *so, int refcount, void * lr)
2336 struct unpcb *unp = sotounpcb(so);
2343 so->so_usecount--;
2345 if (so->so_usecount < 0)
2346 panic("unp_unlock: so=%p usecount=%x\n", so, so->so_usecount);
2347 if (so->so_pcb == NULL) {
2348 panic("unp_unlock: so=%p NO PCB usecount=%x\n", so, so->so_usecount);
2350 mutex_held = &((struct unpcb *)so->so_pcb)->unp_mtx;
2353 so->unlock_lr[so->next_unlock_lr] = lr_saved;
2354 so->next_unlock_lr = (so->next_unlock_lr+1) % SO_LCKDBG_MAX;
2356 if (so->so_usecount == 0 && (so->so_flags & SOF_PCBCLEARING)) {
2357 sofreelastref(so, 1);
2376 unp_getlock(struct socket *so, __unused int locktype)
2378 struct unpcb *unp = (struct unpcb *)so->so_pcb;
2381 if (so->so_pcb) {
2382 if (so->so_usecount < 0)
2383 panic("unp_getlock: so=%p usecount=%x\n", so, so->so_usecount);
2386 panic("unp_getlock: so=%p NULL so_pcb\n", so);
2387 return (so->so_proto->pr_domain->dom_mtx);