#include <stdlib.h> // wcstombs
#include <catta/malloc.h>
#include <catta/log.h>
+#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <assert.h>
+#include "compat/windows/wincompat.h"
#include "hashmap.h"
#include "util.h" // catta_format_mac_address
#include "fdutil.h" // catta_set_nonblock
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)