|
6 | 6 | * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group |
7 | 7 | * |
8 | 8 | * IDENTIFICATION |
9 | | - * $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.9 2009/05/0509:48:51 mha Exp $ |
| 9 | + * $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.10 2009/05/0521:51:46 tgl Exp $ |
10 | 10 | * |
11 | 11 | *------------------------------------------------------------------------- |
12 | 12 | */ |
@@ -158,23 +158,24 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) |
158 | 158 |
|
159 | 159 | /* |
160 | 160 | * If the segment already existed, CreateFileMapping() will return a |
161 | | - * handle to the existing one. |
| 161 | + * handle to the existing one and set ERROR_ALREADY_EXISTS. |
162 | 162 | */ |
163 | 163 | if (GetLastError()==ERROR_ALREADY_EXISTS) |
164 | 164 | { |
165 | | -CloseHandle(hmap);/* Close theoldhandle, since we got a valid |
| 165 | +CloseHandle(hmap);/* Close the handle, since we got a valid |
166 | 166 | * one to the previous segment. */ |
| 167 | +hmap=NULL; |
167 | 168 | Sleep(1000); |
168 | 169 | continue; |
169 | 170 | } |
170 | 171 | break; |
171 | 172 | } |
172 | 173 |
|
173 | 174 | /* |
174 | | - * If the last call in the loop still returned ERROR_ALREADY_EXISTS, this shared memory |
175 | | - * segment exists and we assume it belongs to somebody else. |
| 175 | + * If the last call in the loop still returned ERROR_ALREADY_EXISTS, this |
| 176 | + *shared memorysegment exists and we assume it belongs to somebody else. |
176 | 177 | */ |
177 | | -if (GetLastError()==ERROR_ALREADY_EXISTS) |
| 178 | +if (!hmap) |
178 | 179 | ereport(FATAL, |
179 | 180 | (errmsg("pre-existing shared memory block is still in use"), |
180 | 181 | errhint("Check if there are any old server processes still running, and terminate them."))); |
|