if (table->allocated_len >= table->size)
return NULL;
- obj = &table->objects[table->allocated_len++];
+ obj = &table->objects[table->allocated_len];
/* wait_fd: create pipe */
ret = pipe(waitfd);
goto error_fcntl;
}
}
- *obj->wait_fd = *waitfd;
+ /* The write end of the pipe needs to be non-blocking */
+ ret = fcntl(waitfd[1], F_SETFL, O_NONBLOCK);
+ if (ret < 0) {
+ PERROR("fcntl");
+ goto error_fcntl;
+ }
+ memcpy(obj->wait_fd, waitfd, sizeof(waitfd));
/* shm_fd: create shm */
obj->memory_map = memory_map;
obj->memory_map_size = memory_map_size;
obj->allocated_len = 0;
+ obj->index = table->allocated_len++;
+
return obj;
error_mmap:
}
}
error_pipe:
- free(obj);
return NULL;
}