Changeset 687f7d
- Timestamp:
- 04/24/10 14:12:00 (22 months ago)
- 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)
- Files:
-
- 2 edited
-
TODO (modified) (1 diff)
-
src/client.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
TODO
r957de1 r687f7d 32 32 (SOL_SOCKET option). 33 33 34 - use sigpending() for SIGPIPE. 35 34 36 - set close-on-exec (SO_CLOEXEC). 35 37 -
src/client.c
r957de1 r687f7d 283 283 size_t prefix_len; 284 284 285 sigset_t sigpipe_mask;286 287 285 int connect_timeout; /* 1/1000 sec. */ 288 286 int io_timeout; /* 1/1000 sec. */ … … 388 386 389 387 dispatch_init(&c->dispatch); 390 391 sigemptyset(&c->sigpipe_mask);392 sigaddset(&c->sigpipe_mask, SIGPIPE);393 388 394 389 c->connect_timeout = 250; … … 1442 1437 1443 1438 #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; 1456 1448 #endif /* ! defined(MSG_NOSIGNAL) && ! defined(WIN32) */ 1457 1449 … … 1559 1551 1560 1552 #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); 1577 1558 #endif /* ! defined(MSG_NOSIGNAL) && ! defined(WIN32) */ 1578 1559
Note: See TracChangeset
for help on using the changeset viewer.
