[MLton-commit] r5479

Matthew Fluet fluet at mlton.org
Thu Mar 29 06:48:18 PST 2007


Patch from Nicolas Bertolotti (PolySpace).

- bug-fix-nethostdb-mingw.patch

This patch fixes the NetHostDB functions getByAddress(), getByName() and
getHostName()  which fail to work properly if the WinSock2 DLL has not been
initialized before we call them.


----------------------------------------------------------------------

U   mlton/trunk/runtime/basis/Net/NetHostDB.c

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/basis/Net/NetHostDB.c
===================================================================
--- mlton/trunk/runtime/basis/Net/NetHostDB.c	2007-03-29 13:30:29 UTC (rev 5478)
+++ mlton/trunk/runtime/basis/Net/NetHostDB.c	2007-03-29 14:48:17 UTC (rev 5479)
@@ -39,15 +39,18 @@
 }
 
 C_Int_t NetHostDB_getByAddress(Vector(Word8_t) addr, C_Socklen_t len) {
+  MLton_initSockets ();
   hostent = gethostbyaddr((const char*)addr, len, AF_INET);
   return (C_Int_t)(hostent != NULL and hostent->h_name != NULL);
 }
 
 C_Int_t NetHostDB_getByName(NullString8_t name) {
+  MLton_initSockets ();
   hostent = gethostbyname((const char*)name);
   return (C_Int_t)(hostent != NULL and hostent->h_name != NULL);
 }
 
 C_Errno_t(C_Int_t) NetHostDB_getHostName(Array(Char8_t) buf, C_Size_t len) {
+  MLton_initSockets ();
   return gethostname ((char*)buf, len);
 }




More information about the MLton-commit mailing list