|
13 | 13 | *
|
14 | 14 | * Copyright (c) 2001-2006, PostgreSQL Global Development Group
|
15 | 15 | *
|
16 |
| - * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.135 2006/07/14 14:52:22 momjian Exp $ |
| 16 | + * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.136 2006/07/16 18:17:14 tgl Exp $ |
17 | 17 | * ----------
|
18 | 18 | */
|
19 | 19 | #include "postgres.h"
|
@@ -323,8 +323,12 @@ pgstat_init(void)
|
323 | 323 | * rules prevent it).
|
324 | 324 | */
|
325 | 325 | test_byte = TESTBYTEVAL;
|
| 326 | + |
| 327 | +retry1: |
326 | 328 | if (send(pgStatSock, &test_byte, 1, 0) != 1)
|
327 | 329 | {
|
| 330 | + if (errno == EINTR) |
| 331 | + goto retry1; /* if interrupted, just retry */ |
328 | 332 | ereport(LOG,
|
329 | 333 | (errcode_for_socket_access(),
|
330 | 334 | errmsg("could not send test message on socket for statistics collector: %m")));
|
@@ -375,8 +379,11 @@ pgstat_init(void)
|
375 | 379 |
|
376 | 380 | test_byte++; /* just make sure variable is changed */
|
377 | 381 |
|
| 382 | +retry2: |
378 | 383 | if (recv(pgStatSock, &test_byte, 1, 0) != 1)
|
379 | 384 | {
|
| 385 | + if (errno == EINTR) |
| 386 | + goto retry2; /* if interrupted, just retry */ |
380 | 387 | ereport(LOG,
|
381 | 388 | (errcode_for_socket_access(),
|
382 | 389 | errmsg("could not receive test message on socket for statistics collector: %m")));
|
@@ -1533,17 +1540,23 @@ pgstat_setheader(PgStat_MsgHdr *hdr, StatMsgType mtype)
|
1533 | 1540 | static void
|
1534 | 1541 | pgstat_send(void *msg, int len)
|
1535 | 1542 | {
|
| 1543 | + int rc; |
| 1544 | + |
1536 | 1545 | if (pgStatSock < 0)
|
1537 | 1546 | return;
|
1538 | 1547 |
|
1539 | 1548 | ((PgStat_MsgHdr *) msg)->m_size = len;
|
1540 | 1549 |
|
| 1550 | + /* We'll retry after EINTR, but ignore all other failures */ |
| 1551 | + do |
| 1552 | + { |
| 1553 | + rc = send(pgStatSock, msg, len, 0); |
| 1554 | + } while (rc < 0 && errno == EINTR); |
| 1555 | + |
1541 | 1556 | #ifdef USE_ASSERT_CHECKING
|
1542 |
| - if (send(pgStatSock, msg, len, 0) < 0) |
| 1557 | + /* In debug builds, log send failures ... */ |
| 1558 | + if (rc < 0) |
1543 | 1559 | elog(LOG, "could not send to statistics collector: %m");
|
1544 |
| -#else |
1545 |
| - send(pgStatSock, msg, len, 0); |
1546 |
| - /* We deliberately ignore any error from send() */ |
1547 | 1560 | #endif
|
1548 | 1561 | }
|
1549 | 1562 |
|
@@ -1718,9 +1731,13 @@ PgstatCollectorMain(int argc, char *argv[])
|
1718 | 1731 | len = recv(pgStatSock, (char *) &msg,
|
1719 | 1732 | sizeof(PgStat_Msg), 0);
|
1720 | 1733 | if (len < 0)
|
| 1734 | + { |
| 1735 | + if (errno == EINTR) |
| 1736 | + continue; |
1721 | 1737 | ereport(ERROR,
|
1722 | 1738 | (errcode_for_socket_access(),
|
1723 | 1739 | errmsg("could not read statistics message: %m")));
|
| 1740 | + } |
1724 | 1741 |
|
1725 | 1742 | /*
|
1726 | 1743 | * We ignore messages that are smaller than our common header
|
|
0 commit comments