catta_log_error("pipe() in catta_interface_monitor_init_osdep failed");
return -1;
}
- catta_set_nonblock(m->osdep.pipefd[0]);
- catta_set_nonblock(m->osdep.pipefd[1]);
+ if(catta_set_nonblock(m->osdep.pipefd[0]) < 0 ||
+ catta_set_nonblock(m->osdep.pipefd[1]) < 0)
+ {
+ catta_log_error(__FILE__": catta_set_nonblock failed: %s", errnostrsocket());
+ goto fail;
+ }
m->osdep.icnhandle = NULL;
m->osdep.acnhandle = NULL;
m);
if(!m->osdep.watch) {
catta_log_error(__FILE__": Failed to create watch.");
- return -1;
+ goto fail;
}
// request async notification on interface changes
catta_log_error("NotifyUnicastIpAddressChange failed: %u", (unsigned int)r);
return 0;
+
+fail:
+ closesocket(m->osdep.pipefd[0]);
+ closesocket(m->osdep.pipefd[1]);
+ return -1;
}
void catta_interface_monitor_free_osdep(CattaInterfaceMonitor *m)
#include <catta/malloc.h>
#include <catta/timeval.h>
#include <catta/simple-watch.h>
+#include <catta/log.h>
#include "fdutil.h" // catta_set_nonblock
#include "internal.h" // closesocket
winsock_init(); // on Windows, pipe uses sockets; no-op on other platforms
if (pipe(s->wakeup_pipe) < 0) {
- catta_free(s);
- winsock_exit();
- return NULL;
+ catta_log_error(__FILE__": pipe() failed: %s", errnostrsocket());
+ goto fail;
}
- catta_set_nonblock(s->wakeup_pipe[0]);
- catta_set_nonblock(s->wakeup_pipe[1]);
+ if (catta_set_nonblock(s->wakeup_pipe[0]) < 0 ||
+ catta_set_nonblock(s->wakeup_pipe[1]) < 0)
+ {
+ catta_log_error(__FILE__": O_NONBLOCK failed: %s", errnostrsocket());
+ goto fail;
+ }
s->api.userdata = s;
CATTA_LLIST_HEAD_INIT(CattaTimeout, s->timeouts);
return s;
+
+fail:
+ catta_free(s);
+ winsock_exit();
+ return NULL;
}
void catta_simple_poll_free(CattaSimplePoll *s) {