diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1996-04-01 15:26:38 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1996-04-01 15:26:38 +0000 |
commit | 13f9fab941ab9f3d0f7e7f5cdd8849ee09a0dc9c (patch) | |
tree | 1b98ed21efb611011906bacbb87f23bbcbb4feb7 /otherlibs/unix/gethost.c | |
parent | 97e6ed9a731f2f1dff903c08481e61b518721387 (diff) |
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
Diffstat (limited to 'otherlibs/unix/gethost.c')
-rw-r--r-- | otherlibs/unix/gethost.c | 13 |
1 files changed, 11 insertions, 2 deletions
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); } |