+ for (i = 0; i < nfds; i++) {
+ pthread_mutex_lock(&listener_thread_data_mutex);
+ pthread_cleanup_push(release_listener_mutex, NULL);
+ epoll_sock = (struct ustcomm_sock *)events[i].data.ptr;
+ if (epoll_sock == listen_sock) {
+ addr_size = sizeof(struct sockaddr);
+ accept_fd = accept(epoll_sock->fd,
+ &addr,
+ (socklen_t *)&addr_size);
+ if (accept_fd == -1) {
+ PERROR("listener_main: accept failed");
+ continue;
+ }
+ ustcomm_init_sock(accept_fd, epoll_fd,
+ &ust_socks);
+ } else {
+ memset(receive_header, 0,
+ sizeof(*receive_header));
+ memset(receive_buffer, 0,
+ sizeof(receive_buffer));
+ result = ustcomm_recv(epoll_sock->fd,
+ receive_header,
+ receive_buffer);
+ if (result == 0) {
+ ustcomm_del_sock(epoll_sock, 0);
+ } else {
+ process_client_cmd(receive_header,
+ receive_buffer,
+ epoll_sock->fd);
+ }
+ }
+ pthread_cleanup_pop(1); /* release listener mutex */
+ }