Changeset 687f7d


Ignore:
Timestamp:
04/24/10 14:12:00 (22 months ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master
Children:
335378
Parents:
ed2993
git-author:
Tomash Brechko <tomash.brechko@…> (04/24/10 14:12:00)
git-committer:
Tomash Brechko <tomash.brechko@…> (04/24/10 14:12:00)
Message:

Revert "Fix SIGPIPE ignoring."

Turned out some orthodox systems do not have sigtimedwait(). Since
advanced systems that have sigtimedwait() also have MSG_NOSIGNAL and
thus do not use SIGPIPE suppression code in question, and other
systems have neither MSG_NOSIGNAL nor sigtimedwait(), the only option
is to revert to the previous suppression code. It works correctly
unless your program is multi-threaded.

This reverts commit 957de1c85a26ef090d3ac1dfa0d244fd1032556d.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TODO

    r957de1 r687f7d  
    3232  (SOL_SOCKET option). 
    3333 
     34- use sigpending() for SIGPIPE. 
     35 
    3436- set close-on-exec (SO_CLOEXEC). 
    3537 
  • src/client.c

    r957de1 r687f7d  
    283283  size_t prefix_len; 
    284284 
    285   sigset_t sigpipe_mask; 
    286  
    287285  int connect_timeout;          /* 1/1000 sec.  */ 
    288286  int io_timeout;               /* 1/1000 sec.  */ 
     
    388386 
    389387  dispatch_init(&c->dispatch); 
    390  
    391   sigemptyset(&c->sigpipe_mask); 
    392   sigaddset(&c->sigpipe_mask, SIGPIPE); 
    393388 
    394389  c->connect_timeout = 250; 
     
    14421437 
    14431438#if ! defined(MSG_NOSIGNAL) && ! defined(WIN32) 
    1444   int sigpipe_pending, sigpipe_unblock = 0; 
    1445   sigset_t pending; 
    1446  
    1447   sigpending(&pending); 
    1448   sigpipe_pending = sigismember(&pending, SIGPIPE); 
    1449   if (! sigpipe_pending) 
    1450     { 
    1451       sigset_t blocked; 
    1452  
    1453       pthread_sigmask(SIG_BLOCK, &c->sigpipe_mask, &blocked); 
    1454       sigpipe_unblock = ! sigismember(&blocked, SIGPIPE); 
    1455     } 
     1439  struct sigaction orig, ignore; 
     1440  int res; 
     1441 
     1442  ignore.sa_handler = SIG_IGN; 
     1443  sigemptyset(&ignore.sa_mask); 
     1444  ignore.sa_flags = 0; 
     1445  res = sigaction(SIGPIPE, &ignore, &orig); 
     1446  if (res == -1) 
     1447    return MEMCACHED_FAILURE; 
    14561448#endif /* ! defined(MSG_NOSIGNAL) && ! defined(WIN32) */ 
    14571449 
     
    15591551 
    15601552#if ! defined(MSG_NOSIGNAL) && ! defined(WIN32) 
    1561   if (! sigpipe_pending) 
    1562     { 
    1563       sigpending(&pending); 
    1564       if (sigismember(&pending, SIGPIPE)) 
    1565         { 
    1566           static const struct timespec nowait = { 0, 0 }; 
    1567           int res; 
    1568  
    1569           do 
    1570             res = sigtimedwait(&c->sigpipe_mask, NULL, &nowait); 
    1571           while (res == -1 && errno == EINTR); 
    1572         } 
    1573  
    1574       if (sigpipe_unblock) 
    1575         pthread_sigmask(SIG_UNBLOCK, &c->sigpipe_mask, NULL); 
    1576     } 
     1553  /* 
     1554    Ignore return value of sigaction(), there's nothing we can do in 
     1555    the case of error. 
     1556  */ 
     1557  sigaction(SIGPIPE, &orig, NULL); 
    15771558#endif /* ! defined(MSG_NOSIGNAL) && ! defined(WIN32) */ 
    15781559 
Note: See TracChangeset for help on using the changeset viewer.