sys_pipe.c (193951) | sys_pipe.c (195423) |
---|---|
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 --- 75 unchanged lines hidden (view full) --- 84 * both directions of a pipe. 85 * 86 * As pipelock() may have to sleep before it can acquire the flag, it 87 * is important to reread all data after a call to pipelock(); everything 88 * in the structure may have changed. 89 */ 90 91#include <sys/cdefs.h> | 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 --- 75 unchanged lines hidden (view full) --- 84 * both directions of a pipe. 85 * 86 * As pipelock() may have to sleep before it can acquire the flag, it 87 * is important to reread all data after a call to pipelock(); everything 88 * in the structure may have changed. 89 */ 90 91#include <sys/cdefs.h> |
92__FBSDID("$FreeBSD: head/sys/kern/sys_pipe.c 193951 2009-06-10 20:59:32Z kib $"); | 92__FBSDID("$FreeBSD: head/sys/kern/sys_pipe.c 195423 2009-07-07 09:43:44Z kib $"); |
93 94#include <sys/param.h> 95#include <sys/systm.h> 96#include <sys/fcntl.h> 97#include <sys/file.h> 98#include <sys/filedesc.h> 99#include <sys/filio.h> 100#include <sys/kernel.h> --- 1247 unchanged lines hidden (view full) --- 1348 PIPE_LOCK(rpipe); 1349#ifdef MAC 1350 error = mac_pipe_check_poll(active_cred, rpipe->pipe_pair); 1351 if (error) 1352 goto locked_error; 1353#endif 1354 if (events & (POLLIN | POLLRDNORM)) 1355 if ((rpipe->pipe_state & PIPE_DIRECTW) || | 93 94#include <sys/param.h> 95#include <sys/systm.h> 96#include <sys/fcntl.h> 97#include <sys/file.h> 98#include <sys/filedesc.h> 99#include <sys/filio.h> 100#include <sys/kernel.h> --- 1247 unchanged lines hidden (view full) --- 1348 PIPE_LOCK(rpipe); 1349#ifdef MAC 1350 error = mac_pipe_check_poll(active_cred, rpipe->pipe_pair); 1351 if (error) 1352 goto locked_error; 1353#endif 1354 if (events & (POLLIN | POLLRDNORM)) 1355 if ((rpipe->pipe_state & PIPE_DIRECTW) || |
1356 (rpipe->pipe_buffer.cnt > 0) || 1357 (rpipe->pipe_state & PIPE_EOF)) | 1356 (rpipe->pipe_buffer.cnt > 0)) |
1358 revents |= events & (POLLIN | POLLRDNORM); 1359 1360 if (events & (POLLOUT | POLLWRNORM)) 1361 if (wpipe->pipe_present != PIPE_ACTIVE || 1362 (wpipe->pipe_state & PIPE_EOF) || 1363 (((wpipe->pipe_state & PIPE_DIRECTW) == 0) && 1364 (wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) >= PIPE_BUF)) 1365 revents |= events & (POLLOUT | POLLWRNORM); 1366 | 1357 revents |= events & (POLLIN | POLLRDNORM); 1358 1359 if (events & (POLLOUT | POLLWRNORM)) 1360 if (wpipe->pipe_present != PIPE_ACTIVE || 1361 (wpipe->pipe_state & PIPE_EOF) || 1362 (((wpipe->pipe_state & PIPE_DIRECTW) == 0) && 1363 (wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) >= PIPE_BUF)) 1364 revents |= events & (POLLOUT | POLLWRNORM); 1365 |
1367 if ((rpipe->pipe_state & PIPE_EOF) || 1368 wpipe->pipe_present != PIPE_ACTIVE || 1369 (wpipe->pipe_state & PIPE_EOF)) 1370 revents |= POLLHUP; | 1366 if ((events & POLLINIGNEOF) == 0) { 1367 if (rpipe->pipe_state & PIPE_EOF) { 1368 revents |= (events & (POLLIN | POLLRDNORM)); 1369 if (wpipe->pipe_present != PIPE_ACTIVE || 1370 (wpipe->pipe_state & PIPE_EOF)) 1371 revents |= POLLHUP; 1372 } 1373 } |
1371 1372 if (revents == 0) { 1373 if (events & (POLLIN | POLLRDNORM)) { 1374 selrecord(td, &rpipe->pipe_sel); 1375 if (SEL_WAITING(&rpipe->pipe_sel)) 1376 rpipe->pipe_state |= PIPE_SEL; 1377 } 1378 --- 263 unchanged lines hidden --- | 1374 1375 if (revents == 0) { 1376 if (events & (POLLIN | POLLRDNORM)) { 1377 selrecord(td, &rpipe->pipe_sel); 1378 if (SEL_WAITING(&rpipe->pipe_sel)) 1379 rpipe->pipe_state |= PIPE_SEL; 1380 } 1381 --- 263 unchanged lines hidden --- |