* Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define _GNU_SOURCE
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <config.h>
-#include <common/lttngerr.h>
+#include <common/error.h>
+#include <common/defaults.h>
#include "poll.h"
ret = epoll_create1(flags);
if (ret < 0) {
/* At this point, every error is fatal */
- perror("epoll_create1");
+ PERROR("epoll_create1");
goto error;
}
/* This *must* be freed by using lttng_poll_free() */
events->events = zmalloc(size * sizeof(struct epoll_event));
if (events->events == NULL) {
- perror("zmalloc epoll set");
+ PERROR("zmalloc epoll set");
goto error_close;
}
return 0;
error_close:
- close(events->epfd);
+ ret = close(events->epfd);
+ if (ret) {
+ PERROR("close");
+ }
error:
return -1;
}
if (ret < 0) {
switch (errno) {
case EEXIST:
+ /* If exist, it's OK. */
+ goto end;
case ENOSPC:
case EPERM:
- /* Print perror and goto end not failing. Show must go on. */
- perror("epoll_ctl ADD");
+ /* Print PERROR and goto end not failing. Show must go on. */
+ PERROR("epoll_ctl ADD");
goto end;
default:
- perror("epoll_ctl ADD fatal");
+ PERROR("epoll_ctl ADD fatal");
goto error;
}
}
new_size = 2 * events->events_size;
ptr = realloc(events->events, new_size * sizeof(struct epoll_event));
if (ptr == NULL) {
- perror("realloc epoll add");
+ PERROR("realloc epoll add");
goto error;
}
events->events = ptr;
switch (errno) {
case ENOENT:
case EPERM:
- /* Print perror and goto end not failing. Show must go on. */
- perror("epoll_ctl DEL");
+ /* Print PERROR and goto end not failing. Show must go on. */
+ PERROR("epoll_ctl DEL");
goto end;
default:
- perror("epoll_ctl DEL fatal");
+ PERROR("epoll_ctl DEL fatal");
goto error;
}
- perror("epoll_ctl del");
+ PERROR("epoll_ctl del");
goto error;
}
} while (ret == -1 && errno == EINTR);
if (ret < 0) {
/* At this point, every error is fatal */
- perror("epoll_wait");
+ PERROR("epoll_wait");
goto error;
}
int ret, fd;
char buf[64];
- poll_max_size = LTTNG_POLL_DEFAULT_SIZE;
+ poll_max_size = DEFAULT_POLL_SIZE;
- fd = open(LTTNG_EPOLL_PROC_PATH, O_RDONLY);
+ fd = open(COMPAT_EPOLL_PROC_PATH, O_RDONLY);
if (fd < 0) {
return;
}
ret = read(fd, buf, sizeof(buf));
if (ret < 0) {
- perror("read set max size");
+ PERROR("read set max size");
goto error;
}
poll_max_size = atoi(buf);
if (poll_max_size <= 0) {
/* Extra precaution */
- poll_max_size = LTTNG_POLL_DEFAULT_SIZE;
+ poll_max_size = DEFAULT_POLL_SIZE;
}
DBG("epoll set max size is %d", poll_max_size);
error:
- close(fd);
+ ret = close(fd);
+ if (ret) {
+ PERROR("close");
+ }
}