Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 71d6d07

Browse files
committed
Allow copydir() to be interrupted.
This makes ALTER DATABASE .. SET TABLESPACE and CREATE DATABASE more sensitive to interrupts. Backpatch to 8.4, where ALTER DATABASE .. SET TABLESPACE was introduced. We could go back further, but in the absence of complaints about the CREATE DATABASE case it doesn't seem worth it. Guillaume Lelarge, with a small correction by me.
1 parent 600fc1d commit 71d6d07

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/port/copydir.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* as a service.
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.36 2010/03/01 14:54:00 tgl Exp $
14+
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.37 2010/07/01 20:12:40 rhaas Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -23,6 +23,7 @@
2323
#include <sys/stat.h>
2424

2525
#include "storage/fd.h"
26+
#include "miscadmin.h"
2627

2728
/*
2829
* On Windows, call non-macro versions of palloc; we can't reference
@@ -69,6 +70,9 @@ copydir(char *fromdir, char *todir, bool recurse)
6970
{
7071
struct stat fst;
7172

73+
/* If we got a cancel signal during the copy of the directory, quit */
74+
CHECK_FOR_INTERRUPTS();
75+
7276
if (strcmp(xlde->d_name, ".") == 0 ||
7377
strcmp(xlde->d_name, "..") == 0)
7478
continue;
@@ -172,6 +176,9 @@ copy_file(char *fromfile, char *tofile)
172176
*/
173177
for (offset = 0;; offset += nbytes)
174178
{
179+
/* If we got a cancel signal during the copy of the file, quit */
180+
CHECK_FOR_INTERRUPTS();
181+
175182
nbytes = read(srcfd, buffer, COPY_BUF_SIZE);
176183
if (nbytes < 0)
177184
ereport(ERROR,

0 commit comments

Comments
 (0)