diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-07-01 20:12:40 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-07-01 20:12:40 +0000 |
commit | 71d6d0750d8115b646417b62cc97bab7f9872cf5 (patch) | |
tree | 5886bf16c34b28121e780105fb4328d5018df42a /src | |
parent | 600fc1dc9d6bbb66a76975ea6b431b44c76e7e83 (diff) | |
download | postgresql-71d6d0750d8115b646417b62cc97bab7f9872cf5.tar.gz postgresql-71d6d0750d8115b646417b62cc97bab7f9872cf5.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/port/copydir.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/port/copydir.c b/src/port/copydir.c index 0927e62fe61..b9c6a9a6104 100644 --- a/src/port/copydir.c +++ b/src/port/copydir.c @@ -11,7 +11,7 @@ * as a service. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/copydir.c,v 1.36 2010/03/01 14:54:00 tgl Exp $ + * $PostgreSQL: pgsql/src/port/copydir.c,v 1.37 2010/07/01 20:12:40 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -23,6 +23,7 @@ #include <sys/stat.h> #include "storage/fd.h" +#include "miscadmin.h" /* * On Windows, call non-macro versions of palloc; we can't reference @@ -69,6 +70,9 @@ copydir(char *fromdir, char *todir, bool recurse) { struct stat fst; + /* If we got a cancel signal during the copy of the directory, quit */ + CHECK_FOR_INTERRUPTS(); + if (strcmp(xlde->d_name, ".") == 0 || strcmp(xlde->d_name, "..") == 0) continue; @@ -172,6 +176,9 @@ copy_file(char *fromfile, char *tofile) */ for (offset = 0;; offset += nbytes) { + /* If we got a cancel signal during the copy of the file, quit */ + CHECK_FOR_INTERRUPTS(); + nbytes = read(srcfd, buffer, COPY_BUF_SIZE); if (nbytes < 0) ereport(ERROR, |