ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, wait_fd, &epoll_event);
if (ret < 0) {
perror("[epoll] add");
- goto end;
+ goto error;
}
if (timeout > 0) {
perror("epoll_wait");
}
+error:
+ close(epollfd);
end:
return;
}
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, wait_fd, &epoll_event);
if (ret < 0) {
perror("[eppoll] add");
- goto end;
+ goto error;
}
if (timeout > 0) {
perror("epoll_pwait");
}
+error:
+ close(epollfd);
end:
return;
}
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, wait_fd, &epoll_event);
if (ret < 0) {
perror("[eppoll] add");
- goto end;
+ goto error;
}
ret = syscall(SYS_epoll_pwait, epollfd,
perror("# epoll_pwait");
}
+error:
+ close(epollfd);
end:
return;
}
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, wait_fd, &epoll_event);
if (ret < 0) {
perror("[eppoll] add");
- goto end;
+ goto error;
}
ret = syscall(SYS_epoll_pwait, epollfd, &epoll_event, INT_MAX, -1,
perror("# epoll_pwait");
}
+error:
+ close(epollfd);
end:
return;
}
-1, 0);
if (epoll_event == MAP_FAILED) {
perror("mmap");
- goto end;
+ goto error;
}
for (i = 0; i < MAX_FDS; i++) {
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, fds[i], epoll_event);
if (ret < 0) {
perror("[eppoll] add");
- goto end_unmap;
+ goto error_unmap;
}
}
stop_thread = 0;
(void *) epoll_event);
if (ret != 0) {
fprintf(stderr, "[error] pthread_create\n");
- goto end_unmap;
+ goto error_unmap;
}
ret = epoll_pwait(epollfd, epoll_event, 1, 1, NULL);
ret = pthread_join(writer, NULL);
if (ret) {
fprintf(stderr, "[error] pthread_join\n");
- goto end_unmap;
+ goto error_unmap;
}
-end_unmap:
+error_unmap:
for (i = 0; i < MAX_FDS; i++) {
ret = close(fds[i]);
if (ret != 0) {
perror("munmap");
}
+error:
+ close(epollfd);
end:
return;
}