aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r--camel/camel-mime-utils.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 8ce61e0b4e..3c1d4baf1c 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -3761,25 +3761,29 @@ camel_header_msgid_generate (void)
#define COUNT_LOCK() pthread_mutex_lock (&count_lock)
#define COUNT_UNLOCK() pthread_mutex_unlock (&count_lock)
char host[MAXHOSTNAMELEN];
- struct hostent *h = NULL;
+ char *name;
static int count = 0;
char *msgid;
int retval;
-
+ struct addrinfo *ai = NULL, hints = { 0 };
+
retval = gethostname (host, sizeof (host));
-
- if (retval == 0 && *host)
- h = camel_gethostbyname (host, NULL);
- else
- host[0] = '\0';
+ if (retval == 0 && *host) {
+ hints.ai_flags = AI_CANONNAME;
+ ai = camel_getaddrinfo(host, NULL, &hints, NULL);
+ if (ai && ai->ai_canonname)
+ name = ai->ai_canonname;
+ else
+ name = host;
+ } else
+ name = "localhost.localdomain";
COUNT_LOCK ();
- msgid = g_strdup_printf ("%d.%d.%d.camel@%s", (int) time (NULL), getpid (), count++,
- h ? h->h_name : (*host ? host : "localhost.localdomain"));
+ msgid = g_strdup_printf ("%d.%d.%d.camel@%s", (int) time (NULL), getpid (), count++, name);
COUNT_UNLOCK ();
- if (h)
- camel_free_host (h);
+ if (ai)
+ camel_freeaddrinfo(ai);
return msgid;
}