refill.c (132943) | refill.c (157001) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. | 2 * Copyright (c) 2000-2001, 2005-2006 Sendmail, Inc. and its suppliers. |
3 * All rights reserved. 4 * Copyright (c) 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Chris Torek. 9 * 10 * By using this file, you agree to the terms and conditions set 11 * forth in the LICENSE file which can be found at the top level of 12 * the sendmail distribution. 13 */ 14 15#include <sm/gen.h> | 3 * All rights reserved. 4 * Copyright (c) 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Chris Torek. 9 * 10 * By using this file, you agree to the terms and conditions set 11 * forth in the LICENSE file which can be found at the top level of 12 * the sendmail distribution. 13 */ 14 15#include <sm/gen.h> |
16SM_RCSID("@(#)$Id: refill.c,v 1.50 2002/09/09 21:50:10 gshapiro Exp $") | 16SM_RCSID("@(#)$Id: refill.c,v 1.53 2006/02/28 18:48:25 ca Exp $") |
17#include <stdlib.h> 18#include <unistd.h> 19#include <errno.h> 20#include <setjmp.h> 21#include <signal.h> | 17#include <stdlib.h> 18#include <unistd.h> 19#include <errno.h> 20#include <setjmp.h> 21#include <signal.h> |
22#include <sys/time.h> | 22#include <sm/time.h> |
23#include <fcntl.h> 24#include <string.h> 25#include <sm/io.h> 26#include <sm/conf.h> 27#include <sm/assert.h> 28#include "local.h" 29 30static int sm_lflush __P((SM_FILE_T *, int *)); --- 40 unchanged lines hidden (view full) --- 71 return SM_IO_EOF; \ 72 } \ 73 FD_ZERO(&sm_io_to_mask); \ 74 FD_SET((fd), &sm_io_to_mask); \ 75 FD_ZERO(&sm_io_x_mask); \ 76 FD_SET((fd), &sm_io_x_mask); \ 77 if (gettimeofday(&sm_io_to_before, NULL) < 0) \ 78 return SM_IO_EOF; \ | 23#include <fcntl.h> 24#include <string.h> 25#include <sm/io.h> 26#include <sm/conf.h> 27#include <sm/assert.h> 28#include "local.h" 29 30static int sm_lflush __P((SM_FILE_T *, int *)); --- 40 unchanged lines hidden (view full) --- 71 return SM_IO_EOF; \ 72 } \ 73 FD_ZERO(&sm_io_to_mask); \ 74 FD_SET((fd), &sm_io_to_mask); \ 75 FD_ZERO(&sm_io_x_mask); \ 76 FD_SET((fd), &sm_io_x_mask); \ 77 if (gettimeofday(&sm_io_to_before, NULL) < 0) \ 78 return SM_IO_EOF; \ |
79 (sel_ret) = select((fd) + 1, &sm_io_to_mask, NULL, \ 80 &sm_io_x_mask, (to)); \ | 79 do \ 80 { \ 81 (sel_ret) = select((fd) + 1, &sm_io_to_mask, NULL, \ 82 &sm_io_x_mask, (to)); \ 83 } while ((sel_ret) < 0 && errno == EINTR); \ |
81 if ((sel_ret) < 0) \ 82 { \ 83 /* something went wrong, errno set */ \ 84 fp->f_r = 0; \ 85 fp->f_flags |= SMERR; \ 86 return SM_IO_EOF; \ 87 } \ 88 else if ((sel_ret) == 0) \ 89 { \ 90 /* timeout */ \ 91 errno = EAGAIN; \ 92 return SM_IO_EOF; \ 93 } \ 94 /* calulate wall-clock time used */ \ 95 if (gettimeofday(&sm_io_to_after, NULL) < 0) \ 96 return SM_IO_EOF; \ | 84 if ((sel_ret) < 0) \ 85 { \ 86 /* something went wrong, errno set */ \ 87 fp->f_r = 0; \ 88 fp->f_flags |= SMERR; \ 89 return SM_IO_EOF; \ 90 } \ 91 else if ((sel_ret) == 0) \ 92 { \ 93 /* timeout */ \ 94 errno = EAGAIN; \ 95 return SM_IO_EOF; \ 96 } \ 97 /* calulate wall-clock time used */ \ 98 if (gettimeofday(&sm_io_to_after, NULL) < 0) \ 99 return SM_IO_EOF; \ |
97 timersub(&sm_io_to_before, &sm_io_to_after, &sm_io_to_diff); \ | 100 timersub(&sm_io_to_after, &sm_io_to_before, &sm_io_to_diff); \ |
98 timersub((to), &sm_io_to_diff, (to)); \ 99} 100 101/* 102** SM_LFLUSH -- flush a file if it is line buffered and writable 103** 104** Parameters: 105** fp -- file pointer to flush --- 194 unchanged lines hidden --- | 101 timersub((to), &sm_io_to_diff, (to)); \ 102} 103 104/* 105** SM_LFLUSH -- flush a file if it is line buffered and writable 106** 107** Parameters: 108** fp -- file pointer to flush --- 194 unchanged lines hidden --- |