Differences From Artifact [e992bd3e10]:
- File
src/OFKernelEventObserver.m
— part of check-in
[45518ae7b7]
at
2016-03-20 14:07:47
on branch trunk
— Use the locked queue for kqueue and epoll as well
_readObjects must only be changed from the thread running the observer
and not from a thread adding or removing objects to observe. This is
already handled by the locked queue used by poll and select, so the best
way to solve this is to use the locked queue for kqueue and epoll as
well. (user: js, size: 8571) [annotate] [blame] [check-ins using]
To Artifact [abf69b00a7]:
- File
src/OFKernelEventObserver.m
— part of check-in
[12b8a7552e]
at
2016-03-27 23:10:53
on branch trunk
— Add socket support for Nintendo 3DS
This removes the port registry that existed for the Wii and instead
tries binding to random ports in a loop until it succeeds or errno is
not EADDRINUSE. This is done for the Wii and Nintendo 3DS now.This also includes several other socket-related cleanups. (user: js, size: 8862) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #define __NO_EXT_QNX #include "config.h" #import "OFKernelEventObserver.h" #import "OFKernelEventObserver+Private.h" #import "OFArray.h" #import "OFDataArray.h" #import "OFStream.h" #import "OFStream+Private.h" | > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #define __NO_EXT_QNX #include "config.h" #include <errno.h> #import "OFKernelEventObserver.h" #import "OFKernelEventObserver+Private.h" #import "OFArray.h" #import "OFDataArray.h" #import "OFStream.h" #import "OFStream+Private.h" |
︙ | ︙ | |||
97 98 99 100 101 102 103 | } - init { self = [super init]; @try { | | < < < > | < > > > > > > > > > > > > > > > > > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | } - init { self = [super init]; @try { #if !defined(OF_HAVE_PIPE) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS) socklen_t cancelAddrLen; #endif _readObjects = [[OFMutableArray alloc] init]; _writeObjects = [[OFMutableArray alloc] init]; #ifdef OF_HAVE_PIPE if (pipe(_cancelFD)) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; #else _cancelFD[0] = _cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0); if (_cancelFD[0] == INVALID_SOCKET) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; _cancelAddr.sin_family = AF_INET; _cancelAddr.sin_port = 0; _cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); # ifdef OF_WII _cancelAddr.sin_len = 8; # endif # if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) if (bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) != 0) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; cancelAddrLen = sizeof(_cancelAddr); if (of_getsockname(_cancelFD[0], (struct sockaddr*)&_cancelAddr, &cancelAddrLen) != 0) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; # else for (;;) { uint16_t rnd = 0; int ret; while (rnd < 1024) rnd = (uint16_t)rand(); _cancelAddr.sin_port = OF_BSWAP16_IF_LE(rnd); ret = bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)); if (ret == 0) break; if (of_socket_errno() != EADDRINUSE) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; } # endif #endif #ifdef OF_HAVE_THREADS _mutex = [[OFMutex alloc] init]; #endif |
︙ | ︙ | |||
160 161 162 163 164 165 166 | - (void)dealloc { close(_cancelFD[0]); if (_cancelFD[1] != _cancelFD[0]) close(_cancelFD[1]); | < < < < | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | - (void)dealloc { close(_cancelFD[0]); if (_cancelFD[1] != _cancelFD[0]) close(_cancelFD[1]); [_readObjects release]; [_writeObjects release]; #ifdef OF_HAVE_THREADS [_mutex release]; #endif |
︙ | ︙ |