- fd = accept(apiws->fd, &addr, &lenaddr);
- if (fd >= 0) {
- rc = api_ws_server_accept_client(apiws, fd);
- if (rc >= 0)
- return;
- close(fd);
+ fd = accept(fdev_fd(apiws->fdev), &addr, &lenaddr);
+ if (fd < 0) {
+ ERROR("can't accept connection to %s: %m", apiws->path);
+ } else {
+ fdev = afb_fdev_create(fd);
+ if (!fdev) {
+ ERROR("can't hold accepted connection to %s: %m", apiws->path);
+ close(fd);
+ } else {
+ rc = api_ws_server_accept_client(apiws, fdev);
+ if (rc < 0)
+ ERROR("can't serve accepted connection to %s: %m", apiws->path);
+ }