From 13f9fab941ab9f3d0f7e7f5cdd8849ee09a0dc9c Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 1 Apr 1996 15:26:38 +0000 Subject: Adaptation aux threads: un GC mineur peut se declencher et deplacer des objets des qu'on rentre en blocking_section. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@720 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- otherlibs/unix/gethost.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'otherlibs/unix/gethost.c') diff --git a/otherlibs/unix/gethost.c b/otherlibs/unix/gethost.c index 999cdc2ca..a634d2a43 100644 --- a/otherlibs/unix/gethost.c +++ b/otherlibs/unix/gethost.c @@ -61,8 +61,12 @@ static value alloc_host_entry(entry) value unix_gethostbyaddr(a) /* ML */ value a; { + uint32 addr; struct hostent * entry; - entry = gethostbyaddr((char *) &GET_INET_ADDR(a), 4, AF_INET); + addr = GET_INET_ADDR(a); + enter_blocking_section(); + entry = gethostbyaddr((char *) &addr, 4, AF_INET); + leave_blocking_section(); if (entry == (struct hostent *) NULL) raise_not_found(); return alloc_host_entry(entry); } @@ -70,8 +74,13 @@ value unix_gethostbyaddr(a) /* ML */ value unix_gethostbyname(name) /* ML */ value name; { + char hostname[256]; struct hostent * entry; - entry = gethostbyname(String_val(name)); + strncpy(hostname, String_val(name), sizeof(hostname) - 1); + hostname[sizeof(hostname) - 1] = 0; + enter_blocking_section(); + entry = gethostbyname(hostname); + leave_blocking_section(); if (entry == (struct hostent *) NULL) raise_not_found(); return alloc_host_entry(entry); } -- cgit v1.2.3-70-g09d2