~ubuntu-branches/ubuntu/hardy/exim4/hardy-proposed

« back to all changes in this revision

Viewing changes to src/ip.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Haber
  • Date: 2005-07-02 06:08:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050702060834-qk17pd52kb9nt3bj
Tags: 4.52-1
* new upstream version 4.51. (mh)
  * adapt 70_remove_exim-users_references
  * remove 37_gnutlsparams
  * adapt 36_pcre
  * adapt 31_eximmanpage
* fix package priorities to have them in sync with override again. (mh)
* Fix error in nb (Norwegian) translation.
  Thanks to Helge Hafting. (mh). Closes: #315775
* Standards-Version: 3.6.2, no changes needed. (mh)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Cambridge: exim/exim-src/src/ip.c,v 1.3 2005/06/27 14:29:43 ph10 Exp $ */
 
2
 
1
3
/*************************************************
2
4
*     Exim - an Internet mail transport agent    *
3
5
*************************************************/
4
6
 
5
 
/* Copyright (c) University of Cambridge 1995 - 2004 */
 
7
/* Copyright (c) University of Cambridge 1995 - 2005 */
6
8
/* See the file NOTICE for conditions of use and distribution. */
7
9
 
8
10
/* Functions for doing things with sockets. With the advent of IPv6 this has
247
249
/* A failure whose error code is "Interrupted system call" is in fact
248
250
an externally applied timeout if the signal handler has been run. */
249
251
 
250
 
close(sock);
 
252
(void)close(sock);
251
253
errno = (save_errno == EINTR && sigalrm_seen)? ETIMEDOUT : save_errno;
252
254
return -1;
253
255
}
303
305
{
304
306
fd_set select_inset;
305
307
struct timeval tv;
 
308
int start_recv = time(NULL);
306
309
int rc;
307
310
 
308
311
/* Wait until the socket is ready */
313
316
  FD_SET (sock, &select_inset);
314
317
  tv.tv_sec = timeout;
315
318
  tv.tv_usec = 0;
 
319
 
 
320
  DEBUG(D_transport) debug_printf("waiting for data on socket\n");
316
321
  rc = select(sock + 1, (SELECT_ARG2_TYPE *)&select_inset, NULL, NULL, &tv);
317
322
 
318
323
  /* If some interrupt arrived, just retry. We presume this to be rare,
319
324
  but it can happen (e.g. the SIGUSR1 signal sent by exiwhat causes
320
 
  select() to exit). */
 
325
  select() to exit).
 
326
 
 
327
  Aug 2004: Somebody set up a cron job that ran exiwhat every 2 minutes, making
 
328
  the interrupt not at all rare. Since the timeout is typically more than 2
 
329
  minutes, the effect was to block the timeout completely. To prevent this
 
330
  happening again, we do an explicit time test. */
321
331
 
322
332
  if (rc < 0 && errno == EINTR)
323
333
    {
324
 
    HDEBUG(D_any) debug_printf("EINTR while selecting for socket read\n");
325
 
    continue;
 
334
    DEBUG(D_transport) debug_printf("EINTR while waiting for socket data\n");
 
335
    if (time(NULL) - start_recv < timeout) continue;
 
336
    DEBUG(D_transport) debug_printf("total wait time exceeds timeout\n");
326
337
    }
327
338
 
328
 
  /* Handle a timeout, and treat any other select error as a timeout. */
 
339
  /* Handle a timeout, and treat any other select error as a timeout, including
 
340
  an EINTR when we have been in this loop for longer than timeout. */
329
341
 
330
342
  if (rc <= 0)
331
343
    {