*/
/*
- * Copyright (C) 2011-2013 Simon Ruderich
+ * Copyright (C) 2011-2014 Simon Ruderich
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
return -1;
}
if (optval != 0) {
- fprintf(stderr, LOG_PREFIX "connect() failed (SO_ERROR)");
+ fprintf(stderr, LOG_PREFIX "connect() failed (SO_ERROR)\n");
errno = EINVAL;
return -1;
}
fds[0].fd = sockfd;
fds[0].events = POLLERR | POLLHUP;
/* Either poll for read or write possibility. */
- if (1 == mode) {
+ if (mode == 1) {
fds[0].events |= POLLIN | POLLPRI;
- } else if (0 == mode) {
+ } else if (mode == 0) {
fds[0].events |= POLLOUT;
} else {
abort();
return -1;
}
- if (fds[0].revents & POLLERR || fds[0].revents & POLLHUP) {
- fprintf(stderr, LOG_PREFIX "poll(): POLLERR | POLLHUP\n");
+ if (fds[0].revents & POLLERR) {
+ fprintf(stderr, LOG_PREFIX "poll(): POLLERR\n");
+ return -1;
+ }
+ if (fds[0].revents & POLLHUP) {
+ fprintf(stderr, LOG_PREFIX "poll(): POLLHUP\n");
return -1;
}