5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #include <sys/types.h>
27 #include <sys/param.h>
28 #include <sys/signal.h>
29 #include <sys/cmn_err.h>
30
31 #include <sys/stropts.h>
32 #include <sys/socket.h>
33 #include <sys/socketvar.h>
34 #include <sys/sockio.h>
35 #include <sys/strsubr.h>
36 #include <sys/strsun.h>
37 #include <sys/atomic.h>
38 #include <sys/tihdr.h>
39
40 #include <fs/sockfs/sockcommon.h>
41 #include <fs/sockfs/sockfilter_impl.h>
42 #include <fs/sockfs/socktpi.h>
43 #include <fs/sockfs/sodirect.h>
44 #include <sys/ddi.h>
379 socket_sendsig(struct sonode *so, int event)
380 {
381 proc_t *proc;
382
383 ASSERT(MUTEX_HELD(&so->so_lock));
384
385 if (so->so_pgrp == 0 || (!(so->so_state & SS_ASYNC) &&
386 event != SOCKETSIG_URG)) {
387 return;
388 }
389
390 dprint(3, ("sending sig %d to %d\n", event, so->so_pgrp));
391
392 if (so->so_pgrp > 0) {
393 /*
394 * XXX This unfortunately still generates
395 * a signal when a fd is closed but
396 * the proc is active.
397 */
398 mutex_enter(&pidlock);
399 proc = prfind(so->so_pgrp);
400 if (proc == NULL) {
401 mutex_exit(&pidlock);
402 return;
403 }
404 mutex_enter(&proc->p_lock);
405 mutex_exit(&pidlock);
406 socket_sigproc(proc, event);
407 mutex_exit(&proc->p_lock);
408 } else {
409 /*
410 * Send to process group. Hold pidlock across
411 * calls to socket_sigproc().
412 */
413 pid_t pgrp = -so->so_pgrp;
414
415 mutex_enter(&pidlock);
416 proc = pgfind(pgrp);
417 while (proc != NULL) {
418 mutex_enter(&proc->p_lock);
419 socket_sigproc(proc, event);
420 mutex_exit(&proc->p_lock);
421 proc = proc->p_pglink;
422 }
423 mutex_exit(&pidlock);
424 }
425 }
426
427 #define MIN(a, b) ((a) < (b) ? (a) : (b))
428 /* Copy userdata into a new mblk_t */
429 mblk_t *
430 socopyinuio(uio_t *uiop, ssize_t iosize, size_t wroff, ssize_t maxblk,
431 size_t tail_len, int *errorp)
432 {
433 mblk_t *head = NULL, **tail = &head;
434
435 ASSERT(iosize == INFPSZ || iosize > 0);
436
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25 /*
26 * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
27 */
28
29 #include <sys/types.h>
30 #include <sys/param.h>
31 #include <sys/signal.h>
32 #include <sys/cmn_err.h>
33
34 #include <sys/stropts.h>
35 #include <sys/socket.h>
36 #include <sys/socketvar.h>
37 #include <sys/sockio.h>
38 #include <sys/strsubr.h>
39 #include <sys/strsun.h>
40 #include <sys/atomic.h>
41 #include <sys/tihdr.h>
42
43 #include <fs/sockfs/sockcommon.h>
44 #include <fs/sockfs/sockfilter_impl.h>
45 #include <fs/sockfs/socktpi.h>
46 #include <fs/sockfs/sodirect.h>
47 #include <sys/ddi.h>
382 socket_sendsig(struct sonode *so, int event)
383 {
384 proc_t *proc;
385
386 ASSERT(MUTEX_HELD(&so->so_lock));
387
388 if (so->so_pgrp == 0 || (!(so->so_state & SS_ASYNC) &&
389 event != SOCKETSIG_URG)) {
390 return;
391 }
392
393 dprint(3, ("sending sig %d to %d\n", event, so->so_pgrp));
394
395 if (so->so_pgrp > 0) {
396 /*
397 * XXX This unfortunately still generates
398 * a signal when a fd is closed but
399 * the proc is active.
400 */
401 mutex_enter(&pidlock);
402 /*
403 * Even if the thread started in another zone, we're receiving
404 * on behalf of this socket's zone, so find the proc using the
405 * socket's zone ID.
406 */
407 proc = prfind_zone(so->so_pgrp, so->so_zoneid);
408 if (proc == NULL) {
409 mutex_exit(&pidlock);
410 return;
411 }
412 mutex_enter(&proc->p_lock);
413 mutex_exit(&pidlock);
414 socket_sigproc(proc, event);
415 mutex_exit(&proc->p_lock);
416 } else {
417 /*
418 * Send to process group. Hold pidlock across
419 * calls to socket_sigproc().
420 */
421 pid_t pgrp = -so->so_pgrp;
422
423 mutex_enter(&pidlock);
424 /*
425 * Even if the thread started in another zone, we're receiving
426 * on behalf of this socket's zone, so find the pgrp using the
427 * socket's zone ID.
428 */
429 proc = pgfind_zone(pgrp, so->so_zoneid);
430 while (proc != NULL) {
431 mutex_enter(&proc->p_lock);
432 socket_sigproc(proc, event);
433 mutex_exit(&proc->p_lock);
434 proc = proc->p_pglink;
435 }
436 mutex_exit(&pidlock);
437 }
438 }
439
440 #define MIN(a, b) ((a) < (b) ? (a) : (b))
441 /* Copy userdata into a new mblk_t */
442 mblk_t *
443 socopyinuio(uio_t *uiop, ssize_t iosize, size_t wroff, ssize_t maxblk,
444 size_t tail_len, int *errorp)
445 {
446 mblk_t *head = NULL, **tail = &head;
447
448 ASSERT(iosize == INFPSZ || iosize > 0);
449
|