ObjFW  Diff

Differences From Artifact [1f08d5d8ea]:

  • File src/OFFile.m — part of check-in [3b43d51006] at 2020-01-14 00:16:04 on branch trunk — More consistent -[close] behavior

    This means refusing to close twice, calling -[close] from -[dealloc] and
    not calling -[cancelAsyncRequests].

    Calling -[cancelAsyncRequests] in -[close] is too dangerous, as -[close]
    gets called by -[dealloc]: If the queue is the last reference to the
    object, at the point where -[cancelAsyncRequests] removes it from the
    queue, the object will start to deallocate and call into
    -[cancelAsyncRequests] again, which is still in the middle of removing
    it and now finds itself with an inconsistent state. (user: js, size: 11853) [annotate] [blame] [check-ins using] [more...]

To Artifact [14d95d3e71]:


28
29
30
31
32
33
34

35
36
37
38
39
40
41
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif

#import "OFFile.h"
#import "OFLocale.h"
#import "OFString.h"

#import "OFURL.h"

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"







>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif

#import "OFFile.h"
#import "OFLocale.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURL.h"

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
216
217
218
219
220
221
222
223

224
225


226

227
228
229

230
231
232


233
234
235
236
237
238
239

#ifndef OF_AMIGAOS
		if ((flags = parseMode(mode.UTF8String)) == -1)
			@throw [OFInvalidArgumentException exception];

		flags |= O_BINARY | O_CLOEXEC;

# if defined(OF_WINDOWS)

		if ((handle = _wopen(path.UTF16String, flags,
		    _S_IREAD | _S_IWRITE)) == -1)


# elif defined(HAVE_OPEN64)

		if ((handle = open64([path cStringWithEncoding:
		    [OFLocale encoding]], flags, 0666)) == -1)
# else

		if ((handle = open([path cStringWithEncoding:
		    [OFLocale encoding]], flags, 0666)) == -1)
# endif


			@throw [OFOpenItemFailedException
			    exceptionWithPath: path
					 mode: mode
					errNo: errno];
#else
		if ((handle = malloc(sizeof(*handle))) == NULL)
			@throw [OFOutOfMemoryException







|
>
|
|
>
>
|
>
|
|

>
|
|

>
>







217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247

#ifndef OF_AMIGAOS
		if ((flags = parseMode(mode.UTF8String)) == -1)
			@throw [OFInvalidArgumentException exception];

		flags |= O_BINARY | O_CLOEXEC;

# ifdef OF_WINDOWS
		if ([OFSystemInfo isWindowsNT])
			handle = _wopen(path.UTF16String, flags,
			    _S_IREAD | _S_IWRITE);
		else
# endif
# ifdef HAVE_OPEN64
			handle = open64(
			    [path cStringWithEncoding: [OFLocale encoding]],
			    flags, 0666);
# else
			handle = open(
			    [path cStringWithEncoding: [OFLocale encoding]],
			    flags, 0666);
# endif

		if (handle == -1)
			@throw [OFOpenItemFailedException
			    exceptionWithPath: path
					 mode: mode
					errNo: errno];
#else
		if ((handle = malloc(sizeof(*handle))) == NULL)
			@throw [OFOutOfMemoryException