This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
unlink() patch (was Cygwin CVS breaks PostgreSQL drop table)
- To: Cygwin-Patches <cygwin-patches at sources dot redhat dot com>
- Subject: unlink() patch (was Cygwin CVS breaks PostgreSQL drop table)
- From: Jason Tishler <Jason dot Tishler at dothill dot com>
- Date: Tue, 17 Jul 2001 22:10:42 -0400
- Organization: Dot Hill Systems Corp.
On Fri, Jul 13, 2001 at 12:12:29PM -0400, Jason Tishler wrote:
> I will try to dig some more and devise a patch (if I can), but I wanted
> to at least give a heads up in the meantime.
The first attachment, utest.c, demonstrates the root cause of the problem:
$ date > duda
$ utest duda
s = 0, errno = 0
$ ls -l duda
ls: duda: No such file or directory
$ utest duda
s = 0, errno = 0
After the following commit:
http://www.cygwin.com/ml/cygwin-cvs/2001-q2/msg00276.html
Cygwin no longer correctly handles the case when the file passed to
unlink() does not exist -- unlink() incorrectly returns 0.
The second and third attachments are a patch and the corresponding
ChangeLog entry that fix this problem.
BTW, this bug caused PostgreSQL to spin while dropping tables because
as part of its clean up algorithm (which I do not fully grok), it would
continue to delete files foo, foo.1, foo.2, ... until unlink() returned
with an error.
Thanks,
Jason
--
Jason Tishler
Director, Software Engineering Phone: 732.264.8770 x235
Dot Hill Systems Corp. Fax: 732.264.8798
82 Bethany Road, Suite 7 Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA WWW: http://www.dothill.com
#include <unistd.h>
#include <sys/errno.h>
int
main(int argc, char* argv[])
{
int s = unlink(argv[1]);
printf("s = %d, errno = %d\n", s, errno);
}
Index: syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.128
diff -u -p -r1.128 syscalls.cc
--- syscalls.cc 2001/07/14 00:09:33 1.128
+++ syscalls.cc 2001/07/18 01:54:21
@@ -155,7 +155,7 @@ _unlink (const char *ourname)
if (h == INVALID_HANDLE_VALUE)
{
if (GetLastError () == ERROR_FILE_NOT_FOUND)
- goto ok;
+ goto err;
}
else
{
Tue Jul 17 21:55:23 2001 Jason Tishler <jason@tishler.net>
* syscalls.cc (_unlink): Fix handling of the ENOENT case.