projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement System.Double runtime support
[mono.git]
/
mono
/
utils
/
networking-posix.c
diff --git
a/mono/utils/networking-posix.c
b/mono/utils/networking-posix.c
index 2fe8da9d9f8fa855d4ba6b1dfbdc189f9d8709a4..6a82e68b5a60add404b2d2c00599862fee10d01a 100644
(file)
--- a/
mono/utils/networking-posix.c
+++ b/
mono/utils/networking-posix.c
@@
-7,7
+7,7
@@
* (C) 2015 Xamarin
*/
* (C) 2015 Xamarin
*/
-#include <
mono/utils/networkin
g.h>
+#include <
confi
g.h>
#include <glib.h>
#ifdef HAVE_NETDB_H
#include <glib.h>
#ifdef HAVE_NETDB_H
@@
-26,6
+26,9
@@
#include <ifaddrs.h>
#endif
#include <ifaddrs.h>
#endif
+#include <mono/utils/networking.h>
+#include <mono/utils/mono-threads-coop.h>
+
static void*
get_address_from_sockaddr (struct sockaddr *sa)
{
static void*
get_address_from_sockaddr (struct sockaddr *sa)
{
@@
-47,6
+50,7
@@
mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInf
struct addrinfo hints, *res = NULL, *info;
MonoAddressEntry *cur = NULL, *prev = NULL;
MonoAddressInfo *addr_info;
struct addrinfo hints, *res = NULL, *info;
MonoAddressEntry *cur = NULL, *prev = NULL;
MonoAddressInfo *addr_info;
+ int ret;
memset (&hints, 0, sizeof (struct addrinfo));
*result = NULL;
memset (&hints, 0, sizeof (struct addrinfo));
*result = NULL;
@@
-68,7
+72,12
@@
mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInf
hints.ai_flags = AI_ADDRCONFIG;
#endif
sprintf (service_name, "%d", port);
hints.ai_flags = AI_ADDRCONFIG;
#endif
sprintf (service_name, "%d", port);
- if (getaddrinfo (hostname, service_name, &hints, &info))
+
+ MONO_PREPARE_BLOCKING;
+ ret = getaddrinfo (hostname, service_name, &hints, &info);
+ MONO_FINISH_BLOCKING;
+
+ if (ret)
return 1; /* FIXME propagate the error */
res = info;
return 1; /* FIXME propagate the error */
res = info;
@@
-76,11
+85,6
@@
mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInf
while (res) {
cur = g_new0 (MonoAddressEntry, 1);
while (res) {
cur = g_new0 (MonoAddressEntry, 1);
- if (prev)
- prev->next = cur;
- else
- addr_info->entries = cur;
-
cur->family = res->ai_family;
cur->socktype = res->ai_socktype;
cur->protocol = res->ai_protocol;
cur->family = res->ai_family;
cur->socktype = res->ai_socktype;
cur->protocol = res->ai_protocol;
@@
-91,12
+95,20
@@
mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInf
cur->address_len = sizeof (struct in6_addr);
cur->address.v6 = ((struct sockaddr_in6*)res->ai_addr)->sin6_addr;
} else {
cur->address_len = sizeof (struct in6_addr);
cur->address.v6 = ((struct sockaddr_in6*)res->ai_addr)->sin6_addr;
} else {
- g_error ("Cannot handle address family %d", cur->family);
+ g_warning ("Cannot handle address family %d", cur->family);
+ res = res->ai_next;
+ g_free (cur);
+ continue;
}
if (res->ai_canonname)
cur->canonical_name = g_strdup (res->ai_canonname);
}
if (res->ai_canonname)
cur->canonical_name = g_strdup (res->ai_canonname);
+ if (prev)
+ prev->next = cur;
+ else
+ addr_info->entries = cur;
+
prev = cur;
res = res->ai_next;
}
prev = cur;
res = res->ai_next;
}
@@
-179,7
+191,7
@@
mono_get_local_interfaces (int family, int *interface_count)
memset (&ifc, 0, sizeof (ifc));
ifc.ifc_len = IFCONF_BUFF_SIZE;
memset (&ifc, 0, sizeof (ifc));
ifc.ifc_len = IFCONF_BUFF_SIZE;
- ifc.ifc_buf = g_malloc (IFCONF_BUFF_SIZE); /* We can't have such huge buffers on the stack. */
+ ifc.ifc_buf =
(char *)
g_malloc (IFCONF_BUFF_SIZE); /* We can't have such huge buffers on the stack. */
if (ioctl (fd, SIOCGIFCONF, &ifc) < 0)
goto done;
if (ioctl (fd, SIOCGIFCONF, &ifc) < 0)
goto done;
@@
-216,7
+228,8
@@
mono_get_local_interfaces (int family, int *interface_count)
++if_count;
}
++if_count;
}
- result_ptr = result = g_malloc (if_count * mono_address_size_for_family (family));
+ result = (char *)g_malloc (if_count * mono_address_size_for_family (family));
+ result_ptr = (char *)result;
FOREACH_IFR (ifr, ifc) {
if (ifr->ifr_name [0] == '\0')
continue;
FOREACH_IFR (ifr, ifc) {
if (ifr->ifr_name [0] == '\0')
continue;
@@
-339,4
+352,4
@@
mono_networking_shutdown (void)
{
//nothing really
}
{
//nothing really
}
-#endif
\ No newline at end of file
+#endif