@@ -39,8 +39,9 @@ static DTMConn DtmConnect(char *host, int port)
39
39
DTMConn dtm ;
40
40
int sd ;
41
41
42
- if (strcmp ( host , "localhost" ) == 0 )
42
+ if (host == NULL )
43
43
{
44
+ // use a UNIX socket
44
45
struct sockaddr sock ;
45
46
int len = offsetof(struct sockaddr ,sa_data )+ snprintf (sock .sa_data ,sizeof (sock .sa_data ),"%s/p%u" ,dtm_unix_sock_dir ,port );
46
47
sock .sa_family = AF_UNIX ;
@@ -62,6 +63,7 @@ static DTMConn DtmConnect(char *host, int port)
62
63
}
63
64
else
64
65
{
66
+ // use an IP socket
65
67
struct addrinfo * addrs = NULL ;
66
68
struct addrinfo hint ;
67
69
char portstr [6 ];
@@ -227,7 +229,9 @@ void DtmGlobalConfig(char *host, int port, char* sock_dir) {
227
229
free (dtmhost );
228
230
dtmhost = NULL ;
229
231
}
230
- dtmhost = strdup (host );
232
+ if (host ) {
233
+ dtmhost = strdup (host );
234
+ }
231
235
dtmport = port ;
232
236
dtm_unix_sock_dir = sock_dir ;
233
237
}
@@ -237,14 +241,14 @@ static DTMConn GetConnection()
237
241
static DTMConn dtm = NULL ;
238
242
if (dtm == NULL )
239
243
{
240
- if (dtmhost ) {
241
- dtm = DtmConnect (dtmhost ,dtmport );
242
- if (dtm == NULL )
243
- {
244
- elog (ERROR ,"Failed to connect to DTMD %s:%d" ,dtmhost ,dtmport );
244
+ dtm = DtmConnect (dtmhost ,dtmport );
245
+ if (dtm == NULL )
246
+ {
247
+ if (dtmhost ) {
248
+ elog (ERROR ,"Failed to connect to DTMD at tcp %s:%d" ,dtmhost ,dtmport );
249
+ }else {
250
+ elog (ERROR ,"Failed to connect to DTMD at unix %d" ,dtmport );
245
251
}
246
- }else {
247
- /* elog(ERROR, "DTMD address not specified"); */
248
252
}
249
253
}
250
254
return dtm ;