[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [PATCH] Various bugfixes
From: |
Paolo Bonzini |
Subject: |
[Help-smalltalk] [PATCH] Various bugfixes |
Date: |
Fri, 29 Jun 2007 15:38:40 +0200 |
User-agent: |
Thunderbird 2.0.0.4 (Macintosh/20070604) |
Found while developing the next patch I'll send. Applied to both 2.3
and 3.0.
The most notable ones are: 1) a finalization race, which teaches you not
to use finalizable objects in an instance variable, if an object can be
resurrected during its own finalizer; 2) moving #pathTo: to Directory,
the semantics otherwise were not that clear.
Paolo
2007-06-29 Paolo Bonzini <address@hidden>
* kernel/File.st: Move #pathTo:...
* kernel/Directory.st: ... here, and mimic what File>>#pathFrom: does.
* kernel/VFS.st: Free stat into the RealFileHandler's finalizer.
Move responsibility of registering an object with VFS's ObjectMemory
handler to the object, rather than doing this in #addToBeFinalized.
Fixes race where stat was finalized before an object that was later
resurrected.
* libgst/lib.c: Ensure null termination of _gst_image_file_path.
--- orig/kernel/Directory.st
+++ mod/kernel/Directory.st
@@ -169,6 +169,13 @@ create: dirName
!Directory methodsFor: 'accessing'!
+pathTo: destName
+ "Compute the relative path from the receiver to destName."
+ ^File
+ computePathFrom: vfsHandler realFileName, '/somefile'
+ to: (File fullNameFor: destName)
+!
+
fileAt: aName
"Answer a File object for a file named `aName' residing in the
directory represented by the receiver."
--- orig/kernel/File.st
+++ mod/kernel/File.st
@@ -564,13 +564,6 @@ pathFrom: dirName
to: vfsHandler realFileName
!
-pathTo: destName
- "Compute the relative path from the receiver to destName."
- ^File
- computePathFrom: vfsHandler realFileName
- to: (File fullNameFor: destName)
-!
-
symlinkFrom: srcName
"Create the receiver as a symbolic link from srcName (relative to the
path of the receiver)."
--- orig/kernel/VFS.st
+++ mod/kernel/VFS.st
@@ -281,11 +281,6 @@ vfsFor: fileName name: fsName subPath: s
!VFSHandler methodsFor: 'releasing'!
-addToBeFinalized
- "Something that has to be finalized will also be released before quitting."
- VFSHandler addDependent: self.
- super addToBeFinalized!
-
finalize
"Upon finalization, we remove the file that was temporarily holding the
file
contents"
@@ -504,11 +499,19 @@ lastModifyTime
^self getDateAndTime: self stat stMtime value
!
+finalize
+ "Free the statistics for the receiver"
+ | statVar |
+ statVar := stat.
+ stat := nil.
+ statVar free
+!
+
refresh
"Refresh the statistics for the receiver"
stat isNil ifTrue: [
stat := CStatStruct new.
- stat addToBeFinalized
+ self addToBeFinalized
].
self lstatOn: self realFileName into: stat.
File checkError.
@@ -526,8 +529,14 @@ exists
"Answer whether a file with the name contained in the receiver does exist."
stat isNil ifTrue: [
stat := CStatStruct new.
- stat addToBeFinalized.
+ self addToBeFinalized.
].
+ self lstatOn: self realFileName into: stat.
+ File errno == 0 ifFalse: [ ^false ].
+
+ isSymbolicLink := (stat stMode value bitAnd: 8r170000) = 8r120000.
"S_IFLNK"
+ isSymbolicLink ifFalse: [ ^true ].
+
self statOn: self realFileName into: stat.
^File errno == 0
!
@@ -689,6 +698,7 @@ vfsFor: file name: fsName subPath: subPa
name: virtualFileName realFileName: temporaryFileName
"Private - Initialize a new object storing the contents of the
virtualFileName file into temporaryFileName."
+ VFSHandler addDependent: self.
self addToBeFinalized.
self name: virtualFileName.
realFileName := File fullNamFor: temporaryFileName!
@@ -769,6 +779,7 @@ at: aName
handlers isNil ifTrue: [
handlers := LookupTable new.
+ VFSHandler addDependent: self.
self addToBeFinalized
].
--- orig/libgst/lib.c
+++ mod/libgst/lib.c
@@ -631,7 +631,8 @@ init_paths (void)
char *dirname;
int n = p > _gst_binary_image_name ? p - _gst_binary_image_name : 1;
dirname = xmalloc (n + 1);
- strncpy (dirname, _gst_binary_image_name, n);
+ memcpy (dirname, _gst_binary_image_name, n);
+ dirname[n] = 0;
_gst_image_file_path = dirname;
break;
}
--- orig/tests/local.at
+++ mod/tests/local.at
@@ -21,11 +21,11 @@ dnl AT_CHECK_GST([COMMAND-LINE], [IMAGE]
dnl ----------------------------------------------------------------
m4_define([AT_CHECK_GST], [
case $AUTOTEST_PATH in
- tests) GST="$abs_top_builddir/gst -I m4_ifval([$2], [$2],
[$abs_top_builddir/gst.im])" ;;
- *) GST="$AUTOTEST_PATH/gst m4_ifval([$2], [-I $2])" ;;
+ tests) image_path="-I m4_ifval([$2], [$2], [$abs_top_builddir/gst.im])" ;;
+ *) image_path="m4_ifval([$2], [-I $2])" ;;
esac
- AT_CHECK([cd m4_ifval([$3], [$3], [$abs_top_builddir]) && $GST $1 | tr -d
'\r'], 0, [$4], [$5])
+ AT_CHECK([{ (cd m4_ifval([$3], [$3], [$abs_top_builddir]) && gst $image_path
$1); echo exit $? > retcode; } | tr -d '\r'; . retcode], 0, [$4], [$5])
])
dnl AT_DIFF_TEST([FILE], [XFAILS])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-smalltalk] [PATCH] Various bugfixes,
Paolo Bonzini <=