Hi,
I have noticed some forks during valgrind check, I think it will be better
to use functions instead of the unix command. This patch replace the fork
and exec domainnanme by a simple call to getdomainname(). It is faster and
we sould have less message during valgrind and strace investigation's.
Best regards
--
Arnaud Versini
From 1f15cd04c17af93c7603e8d90137df9a91e86493 Mon Sep 17 00:00:00 2001
From: Arnaud Versini <arnaud.versini@gmail.com>
Date: Sat, 12 Nov 2011 19:17:03 +0100
Subject: [PATCH] Replace domainname command by getdomainname syscall or
function
---
sal/osl/unx/socket.c | 51 ++++---------------------------------------------
1 files changed, 5 insertions(+), 46 deletions(-)
diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c
index b60fb2d..9c33eaf 100644
--- a/sal/osl/unx/socket.c
+++ b/sal/osl/unx/socket.c
@@ -811,52 +811,11 @@ static struct hostent* _osl_gethostbyname_r (
static sal_Bool _osl_getDomainName (sal_Char *buffer, sal_Int32 bufsiz)
{
- sal_Bool result;
- int p[2];
-
- result = sal_False;
- if (pipe (p) == 0)
- {
- pid_t pid;
- int nStatus;
-
- pid = fork();
- if (pid == 0)
- {
- char *argv[] =
- {
- "/bin/domainname",
- NULL
- };
-
- close (p[0]);
- dup2 (p[1], 1);
- close (p[1]);
-
- execv ("/bin/domainname", argv);
- // arriving here means exec failed
- _exit(-1);
- }
- else if (pid > 0)
- {
- sal_Int32 k = 0, n = bufsiz;
-
- close (p[1]);
- if ((k = read (p[0], buffer, n - 1)) > 0)
- {
- buffer[k] = 0;
- if (buffer[k - 1] == '\n')
- buffer[k - 1] = 0;
- result = sal_True;
- }
- close (p[0]);
- waitpid (pid, &nStatus, 0);
- }
- else
- {
- close (p[0]);
- close (p[1]);
- }
+ sal_Bool result = (getdomainname(buffer, bufsiz) == 0);
+ if (!result) {
+ OSL_TRACE("osl_getDomainName failed. Errno: %d; %s\n",
+ errno,
+ strerror(errno));
}
return (result);
}
--
1.7.5.4
Context
- [Libreoffice] [PATCH] Replace command domainname by getdomainname() on Unix · Arnaud Versini
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.