- case 1: {
- if((lenin = read(request_fd, &request, sizeof request)) != sizeof request) {
- logger(LOG_ERR, "Error while reading request from %s %s: %s", device_info,
- device, strerror(errno));
- running = false;
- return false;
- }
-
- if(request.magic != 0xfeedface || request.version != 3 || request.type != REQ_NEW_CONTROL) {
- logger(LOG_ERR, "Unknown magic %x, version %d, request type %d from %s %s",
- request.magic, request.version, request.type, device_info, device);
- running = false;
- return false;
- }
-
- if(connect(write_fd, &request.sock, sizeof request.sock) < 0) {
- logger(LOG_ERR, "Could not bind write %s: %s", device_info, strerror(errno));
- running = false;
- return false;
- }
-
- write(request_fd, &data_sun, sizeof data_sun);
- device_fd = data_fd;
-
- logger(LOG_INFO, "Connection with UML established");
-
- state = 2;
+#ifdef FD_CLOEXEC
+ fcntl(request_fd, F_SETFD, FD_CLOEXEC);
+#endif
+
+ if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno));
+ event_exit();