api: epoll_create() and epoll_create1() should return NULL on failure
This commit is contained in:
parent
98fc483e76
commit
981b3caf4e
@ -62,7 +62,7 @@ HANDLE epoll_create1(int flags);
|
||||
* Create a new epoll instance (port).
|
||||
* `size` is ignored but most be greater than zero.
|
||||
* `flags` must be zero as there are no supported flags.
|
||||
* Returns `INVALID_HANDLE_VALUE` on failure.
|
||||
* Returns `NULL` on failure.
|
||||
* [man page][man epoll_create]
|
||||
|
||||
### epoll_close
|
||||
|
||||
@ -35,8 +35,9 @@ static HANDLE _epoll_create(void) {
|
||||
if (reflock_tree_add(&_epoll_handle_tree,
|
||||
&port_info->handle_tree_node,
|
||||
(uintptr_t) ephnd) < 0) {
|
||||
/* This should never happen. */
|
||||
ep_port_delete(port_info);
|
||||
return_error(INVALID_HANDLE_VALUE, ERROR_ALREADY_EXISTS);
|
||||
return_error(NULL, ERROR_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
return ephnd;
|
||||
@ -44,14 +45,14 @@ static HANDLE _epoll_create(void) {
|
||||
|
||||
HANDLE epoll_create(int size) {
|
||||
if (size <= 0)
|
||||
return_error(INVALID_HANDLE_VALUE, ERROR_INVALID_PARAMETER);
|
||||
return_error(NULL, ERROR_INVALID_PARAMETER);
|
||||
|
||||
return _epoll_create();
|
||||
}
|
||||
|
||||
HANDLE epoll_create1(int flags) {
|
||||
if (flags != 0)
|
||||
return_error(INVALID_HANDLE_VALUE, ERROR_INVALID_PARAMETER);
|
||||
return_error(NULL, ERROR_INVALID_PARAMETER);
|
||||
|
||||
return _epoll_create();
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ int main(void) {
|
||||
int r;
|
||||
|
||||
ephnd = epoll_create1(0);
|
||||
check(ephnd != INVALID_HANDLE_VALUE);
|
||||
check(ephnd != NULL);
|
||||
|
||||
sock1 = create_and_add_socket(ephnd, EPOLLIN);
|
||||
sock2 = create_and_add_socket(ephnd, EPOLLIN);
|
||||
|
||||
@ -107,7 +107,7 @@ int main(void) {
|
||||
|
||||
/* Create epoll port. */
|
||||
port = epoll_create1(0);
|
||||
check(port != INVALID_HANDLE_VALUE);
|
||||
check(port != NULL);
|
||||
ports[i] = port;
|
||||
|
||||
/* Register recv_sock with the epoll port. */
|
||||
|
||||
@ -65,7 +65,7 @@ int main(void) {
|
||||
{
|
||||
/* Create an epoll instance. */
|
||||
epoll_port = epoll_create(1);
|
||||
check(epoll_port > 0);
|
||||
check(epoll_port != NULL);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@ -24,7 +24,7 @@ int main(void) {
|
||||
struct epoll_event ev;
|
||||
|
||||
epoll_hnd = epoll_create1(0);
|
||||
check(epoll_hnd && epoll_hnd != INVALID_HANDLE_VALUE);
|
||||
check(epoll_hnd != NULL);
|
||||
|
||||
srv = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
r = ioctlsocket(srv, FIONBIO, &one);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user