Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e37118

Browse files
committed
Loop calling CallNamedPipe() several times in case it fails,
since it can be transient failures, causing kill() to notproperly send signals.Original patch from Steve Marshall, modified by me.
1 parent3f7626e commit2e37118

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

‎src/port/kill.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*signals that the backend can recognize.
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/port/kill.c,v 1.11 2009/01/01 17:24:04 momjian Exp $
12+
* $PostgreSQL: pgsql/src/port/kill.c,v 1.12 2009/02/15 13:58:18 mha Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -25,6 +25,7 @@ pgkill(int pid, int sig)
2525
BYTEsigData=sig;
2626
BYTEsigRet=0;
2727
DWORDbytes;
28+
intpipe_tries;
2829

2930
/* we allow signal 0 here, but it will be ignored in pg_queue_signal */
3031
if (sig >=PG_SIGNAL_COUNT||sig<0)
@@ -39,23 +40,33 @@ pgkill(int pid, int sig)
3940
return-1;
4041
}
4142
snprintf(pipename,sizeof(pipename),"\\\\.\\pipe\\pgsignal_%u",pid);
42-
if (!CallNamedPipe(pipename,&sigData,1,&sigRet,1,&bytes,1000))
43-
{
44-
if (GetLastError()==ERROR_FILE_NOT_FOUND)
45-
errno=ESRCH;
46-
elseif (GetLastError()==ERROR_ACCESS_DENIED)
47-
errno=EPERM;
48-
else
49-
errno=EINVAL;
50-
return-1;
51-
}
52-
if (bytes!=1||sigRet!=sig)
43+
44+
/*
45+
* Writing data to the named pipe can fail for transient reasons.
46+
* Therefore, it is useful to retry if it fails. The maximum number of
47+
* calls to make was empirically determined from a 90-hour notification
48+
* stress test.
49+
*/
50+
for (pipe_tries=0;pipe_tries<3;pipe_tries++)
5351
{
54-
errno=ESRCH;
55-
return-1;
52+
if (CallNamedPipe(pipename,&sigData,1,&sigRet,1,&bytes,1000))
53+
{
54+
if (bytes!=1||sigRet!=sig)
55+
{
56+
errno=ESRCH;
57+
return-1;
58+
}
59+
return0;
60+
}
5661
}
5762

58-
return0;
63+
if (GetLastError()==ERROR_FILE_NOT_FOUND)
64+
errno=ESRCH;
65+
elseif (GetLastError()==ERROR_ACCESS_DENIED)
66+
errno=EPERM;
67+
else
68+
errno=EINVAL;
69+
return-1;
5970
}
6071

6172
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp