-int send_message_path(const char *path, const char *msg, char **reply, int signalpid)
+struct ustcomm_sock * ustcomm_init_sock(int fd, int epoll_fd,
+ struct list_head *list)
+{
+ struct epoll_event ev;
+ struct ustcomm_sock *sock;
+
+ sock = malloc(sizeof(struct ustcomm_sock));
+ if (!sock) {
+ perror("malloc: couldn't allocate ustcomm_sock");
+ return NULL;
+ }
+
+ ev.events = EPOLLIN;
+ ev.data.ptr = sock;
+ sock->fd = fd;
+
+ if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, sock->fd, &ev) == -1) {
+ perror("epoll_ctl: failed to add socket\n");
+ free(sock);
+ return NULL;
+ }
+
+ sock->epoll_fd = epoll_fd;
+ if (list) {
+ list_add(&sock->list, list);
+ } else {
+ INIT_LIST_HEAD(&sock->list);
+ }
+
+ return sock;
+}
+
+void ustcomm_del_sock(struct ustcomm_sock *sock, int keep_in_epoll)
+{
+ list_del(&sock->list);
+ if (!keep_in_epoll) {
+ if (epoll_ctl(sock->epoll_fd, EPOLL_CTL_DEL, sock->fd, NULL) == -1) {
+ PERROR("epoll_ctl: failed to delete socket");
+ }
+ }
+ close(sock->fd);
+ free(sock);
+}
+
+struct ustcomm_sock * ustcomm_init_named_socket(const char *name,
+ int epoll_fd)