If we fail to create the listening socket, the main thread should not
be left running without the listener.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
sockfd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (sockfd < 0) {
printf("Failed to create socket: %m\n");
sockfd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (sockfd < 0) {
printf("Failed to create socket: %m\n");
}
addr.sin_family = AF_INET;
}
addr.sin_family = AF_INET;
if (ret == -1) {
if (errno != EINTR) {
printf("epoll_wait: %m\n");
if (ret == -1) {
if (errno != EINTR) {
printf("epoll_wait: %m\n");
close_socket:
close(sockfd);
close_socket:
close(sockfd);
struct tm *now;
time_t t;
struct tm *now;
time_t t;
+ ret = 0;
+ if (exit_all)
+ break;
+
ret = bme280_set_sensor_mode(BME280_FORCED_MODE, dev);
if (ret) {
fprintf(stderr, "Failed to set sensor mode (code %+d).", ret);
ret = bme280_set_sensor_mode(BME280_FORCED_MODE, dev);
if (ret) {
fprintf(stderr, "Failed to set sensor mode (code %+d).", ret);