ObjFW  Check-in [aebd220efc]

Overview
Comment:Use CLOEXEC for kqueue
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: aebd220efc25c3b5bb3fc0f1ae6fedeb4c3f10d5cbce9ff7ab9008362ce86bae
User & Date: js on 2014-12-13 17:50:05
Other Links: manifest | tags
Context
2014-12-14
17:35
OFProcess: Use posix_spawnp if available check-in: e9984d112a user: js tags: trunk
2014-12-13
17:50
Use CLOEXEC for kqueue check-in: aebd220efc user: js tags: trunk
16:53
Fix compilation with GCC check-in: 12ceeb7853 user: js tags: trunk
Changes

Modified configure.ac from [673fd6e03c] to [af044ec26c].

740
741
742
743
744
745
746


747
748
749
750
751
752
753

	AC_CHECK_FUNCS([paccept accept4])

	AC_CHECK_FUNC(kqueue, [
		AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue])
		AC_SUBST(OFKERNELEVENTOBSERVER_KQUEUE_M,
			"OFKernelEventObserver_kqueue.m")


	])
	AC_CHECK_HEADER(poll.h, [
		AC_DEFINE(HAVE_POLL_H, 1, [Whether we have poll.h])
		AC_SUBST(OFKERNELEVENTOBSERVER_POLL_M,
			"OFKernelEventObserver_poll.m")
	])
	AC_CHECK_HEADER(sys/select.h, [







>
>







740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755

	AC_CHECK_FUNCS([paccept accept4])

	AC_CHECK_FUNC(kqueue, [
		AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue])
		AC_SUBST(OFKERNELEVENTOBSERVER_KQUEUE_M,
			"OFKernelEventObserver_kqueue.m")

		AC_CHECK_FUNCS(kqueue1)
	])
	AC_CHECK_HEADER(poll.h, [
		AC_DEFINE(HAVE_POLL_H, 1, [Whether we have poll.h])
		AC_SUBST(OFKERNELEVENTOBSERVER_POLL_M,
			"OFKernelEventObserver_poll.m")
	])
	AC_CHECK_HEADER(sys/select.h, [

Modified src/OFKernelEventObserver_kqueue.m from [70736e006a] to [dab6fa946c].

41
42
43
44
45
46
47







48
49
50




51
52
53
54
55
56
57

@implementation OFKernelEventObserver_kqueue
- init
{
	self = [super init];

	@try {







		if ((_kernelQueue = kqueue()) == -1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];





		_changeList = [[OFDataArray alloc] initWithItemSize:
		    sizeof(struct kevent)];
		_removedArray = [[OFMutableArray alloc] init];

		[self OF_addFileDescriptorForReading: _cancelFD[0]];
	} @catch (id e) {







>
>
>
>
>
>
>



>
>
>
>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

@implementation OFKernelEventObserver_kqueue
- init
{
	self = [super init];

	@try {
#ifdef HAVE_KQUEUE1
		if ((_kernelQueue = kqueue1(O_CLOEXEC)) == -1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];
#else
		int flags;

		if ((_kernelQueue = kqueue()) == -1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];

		if ((flags = fcntl(_kernelQueue, F_GETFD, 0)) != -1)
			fcntl(_kernelQueue, F_SETFD, flags | FD_CLOEXEC);
#endif

		_changeList = [[OFDataArray alloc] initWithItemSize:
		    sizeof(struct kevent)];
		_removedArray = [[OFMutableArray alloc] init];

		[self OF_addFileDescriptorForReading: _cancelFD[0]];
	} @catch (id e) {