Deleted Added
full compact
sys_pipe.c (43278) sys_pipe.c (43301)
1/*
2 * Copyright (c) 1996 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. Modifications may be freely made to this file if the above conditions
17 * are met.
18 *
1/*
2 * Copyright (c) 1996 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. Modifications may be freely made to this file if the above conditions
17 * are met.
18 *
19 * $Id: sys_pipe.c,v 1.46 1998/12/07 21:58:29 archie Exp $
19 * $Id: sys_pipe.c,v 1.47 1999/01/27 10:10:02 bde Exp $
20 */
21
22/*
23 * This file contains a high-performance replacement for the socket-based
24 * pipes scheme originally used in FreeBSD/4.4Lite. It does not support
25 * all features of sockets, but does do everything that pipes normally
26 * do.
27 */

--- 249 unchanged lines hidden (view full) ---

277static __inline int
278pipelock(cpipe, catch)
279 struct pipe *cpipe;
280 int catch;
281{
282 int error;
283 while (cpipe->pipe_state & PIPE_LOCK) {
284 cpipe->pipe_state |= PIPE_LWANT;
20 */
21
22/*
23 * This file contains a high-performance replacement for the socket-based
24 * pipes scheme originally used in FreeBSD/4.4Lite. It does not support
25 * all features of sockets, but does do everything that pipes normally
26 * do.
27 */

--- 249 unchanged lines hidden (view full) ---

277static __inline int
278pipelock(cpipe, catch)
279 struct pipe *cpipe;
280 int catch;
281{
282 int error;
283 while (cpipe->pipe_state & PIPE_LOCK) {
284 cpipe->pipe_state |= PIPE_LWANT;
285 if (error = tsleep( cpipe,
286 catch?(PRIBIO|PCATCH):PRIBIO, "pipelk", 0)) {
285 if ((error = tsleep( cpipe,
286 catch?(PRIBIO|PCATCH):PRIBIO, "pipelk", 0)) != 0) {
287 return error;
288 }
289 }
290 cpipe->pipe_state |= PIPE_LOCK;
291 return 0;
292}
293
294/*

--- 124 unchanged lines hidden (view full) ---

419 }
420
421 if (rpipe->pipe_state & PIPE_WANTW) {
422 rpipe->pipe_state &= ~PIPE_WANTW;
423 wakeup(rpipe);
424 }
425
426 rpipe->pipe_state |= PIPE_WANTR;
287 return error;
288 }
289 }
290 cpipe->pipe_state |= PIPE_LOCK;
291 return 0;
292}
293
294/*

--- 124 unchanged lines hidden (view full) ---

419 }
420
421 if (rpipe->pipe_state & PIPE_WANTW) {
422 rpipe->pipe_state &= ~PIPE_WANTW;
423 wakeup(rpipe);
424 }
425
426 rpipe->pipe_state |= PIPE_WANTR;
427 if (error = tsleep(rpipe, PRIBIO|PCATCH, "piperd", 0)) {
427 if ((error = tsleep(rpipe, PRIBIO|PCATCH, "piperd", 0)) != 0) {
428 break;
429 }
430 }
431 }
432
433 if (error == 0)
434 getnanotime(&rpipe->pipe_atime);
435

--- 423 unchanged lines hidden (view full) ---

859
860 /*
861 * We have no more space and have something to offer,
862 * wake up select/poll.
863 */
864 pipeselwakeup(wpipe);
865
866 wpipe->pipe_state |= PIPE_WANTW;
428 break;
429 }
430 }
431 }
432
433 if (error == 0)
434 getnanotime(&rpipe->pipe_atime);
435

--- 423 unchanged lines hidden (view full) ---

859
860 /*
861 * We have no more space and have something to offer,
862 * wake up select/poll.
863 */
864 pipeselwakeup(wpipe);
865
866 wpipe->pipe_state |= PIPE_WANTW;
867 if (error = tsleep(wpipe, (PRIBIO+1)|PCATCH, "pipewr", 0)) {
867 if ((error = tsleep(wpipe, (PRIBIO+1)|PCATCH, "pipewr", 0)) != 0) {
868 break;
869 }
870 /*
871 * If read side wants to go away, we just issue a signal
872 * to ourselves.
873 */
874 if (wpipe->pipe_state & PIPE_EOF) {
875 error = EPIPE;

--- 190 unchanged lines hidden (view full) ---

1066 wakeup(cpipe);
1067 cpipe->pipe_state |= PIPE_WANT|PIPE_EOF;
1068 tsleep(cpipe, PRIBIO, "pipecl", 0);
1069 }
1070
1071 /*
1072 * Disconnect from peer
1073 */
868 break;
869 }
870 /*
871 * If read side wants to go away, we just issue a signal
872 * to ourselves.
873 */
874 if (wpipe->pipe_state & PIPE_EOF) {
875 error = EPIPE;

--- 190 unchanged lines hidden (view full) ---

1066 wakeup(cpipe);
1067 cpipe->pipe_state |= PIPE_WANT|PIPE_EOF;
1068 tsleep(cpipe, PRIBIO, "pipecl", 0);
1069 }
1070
1071 /*
1072 * Disconnect from peer
1073 */
1074 if (ppipe = cpipe->pipe_peer) {
1074 if ((ppipe = cpipe->pipe_peer) != NULL) {
1075 pipeselwakeup(ppipe);
1076
1077 ppipe->pipe_state |= PIPE_EOF;
1078 wakeup(ppipe);
1079 ppipe->pipe_peer = NULL;
1080 }
1081
1082 /*

--- 21 unchanged lines hidden ---
1075 pipeselwakeup(ppipe);
1076
1077 ppipe->pipe_state |= PIPE_EOF;
1078 wakeup(ppipe);
1079 ppipe->pipe_peer = NULL;
1080 }
1081
1082 /*

--- 21 unchanged lines hidden ---