]>
Commit | Line | Data |
---|---|---|
5fe7e92a JB |
1 | --- postgresql-8.3.1/src/bin/pg_ctl/pg_ctl.c.orig 2008-03-01 00:31:42.000000000 +0100 |
2 | +++ postgresql-8.3.1/src/bin/pg_ctl/pg_ctl.c 2008-03-20 22:59:22.658133220 +0100 | |
3 | @@ -412,12 +412,12 @@ | |
4aa5c0b3 | 4 | PGconn *conn; |
0796510c | 5 | bool success = false; |
6 | int i; | |
4aa5c0b3 JB |
7 | - char portstr[32]; |
8 | + char portstr[32], sockstr[MAXPGPATH]; | |
0796510c | 9 | char *p; |
5fe7e92a | 10 | char *q; |
4aa5c0b3 JB |
11 | - char connstr[128]; /* Should be way more than enough! */ |
12 | + char connstr[128+MAXPGPATH]; /* Should be way more than enough! */ | |
0796510c | 13 | |
4aa5c0b3 JB |
14 | - *portstr = '\0'; |
15 | + *portstr = *sockstr = '\0'; | |
0796510c | 16 | |
5fe7e92a JB |
17 | /* |
18 | * Look in post_opts for a -p switch. | |
19 | @@ -448,6 +448,21 @@ | |
20 | strlcpy(portstr, p, Min((q - p) + 1, sizeof(portstr))); | |
4aa5c0b3 | 21 | /* keep looking, maybe there is another -p */ |
5fe7e92a | 22 | p = q; |
4aa5c0b3 JB |
23 | + } else if (strncmp(p, "-k", strlen("-k")) == 0) |
24 | + { | |
5fe7e92a | 25 | + p += 2; |
4aa5c0b3 JB |
26 | + /* advance past whitespace/quoting */ |
27 | + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') | |
28 | + p++; | |
5fe7e92a JB |
29 | + /* find end of value (not including any ending quote!) */ |
30 | + q = p; | |
31 | + while (*q && | |
32 | + !(isspace((unsigned char) *q) || *q == '\'' || *q == '"')) | |
33 | + q++; | |
34 | + /* and save the argument value */ | |
35 | + strlcpy(sockstr, p, Min(q - p + 1, sizeof(sockstr))); | |
4aa5c0b3 | 36 | + /* keep looking, maybe there is another -k */ |
5fe7e92a | 37 | + p = q; |
4aa5c0b3 JB |
38 | } |
39 | /* Advance to next whitespace */ | |
40 | while (*p && !isspace((unsigned char) *p)) | |
5fe7e92a JB |
41 | @@ -460,7 +475,7 @@ |
42 | * This parsing code isn't amazingly bright either, but it should be | |
43 | * okay for valid port settings. | |
44 | */ | |
0796510c | 45 | - if (!*portstr) |
46 | + if (!*portstr || !*sockstr) | |
47 | { | |
48 | char **optlines; | |
49 | ||
5fe7e92a | 50 | @@ -473,8 +488,7 @@ |
0796510c | 51 | |
52 | while (isspace((unsigned char) *p)) | |
53 | p++; | |
5fe7e92a | 54 | - if (strncmp(p, "port", 4) != 0) |
0796510c | 55 | - continue; |
5fe7e92a JB |
56 | + if (!strncmp(p, "port", 4)) { |
57 | p += 4; | |
58 | while (isspace((unsigned char) *p)) | |
0796510c | 59 | p++; |
5fe7e92a JB |
60 | @@ -493,6 +507,26 @@ |
61 | /* and save the argument value */ | |
62 | strlcpy(portstr, p, Min((q - p) + 1, sizeof(portstr))); | |
63 | /* keep looking, maybe there is another */ | |
64 | + } else if(!strncmp(p, "unix_socket_directory", 21)) { | |
65 | + p += 21; | |
0796510c | 66 | + while (isspace((unsigned char) *p)) |
67 | + p++; | |
68 | + if (*p != '=') | |
69 | + continue; | |
5fe7e92a JB |
70 | + p++; |
71 | + /* advance past any whitespace/quoting */ | |
0796510c | 72 | + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') |
73 | + p++; | |
5fe7e92a JB |
74 | + /* find end of value (not including any ending quote/comment!) */ |
75 | + q = p; | |
76 | + while (*q && | |
77 | + !(isspace((unsigned char) *q) || | |
78 | + *q == '\'' || *q == '"' || *q == '#')) | |
79 | + q++; | |
80 | + /* and save the argument value */ | |
81 | + strlcpy(sockstr, p, Min((q - p) + 1, sizeof(sockstr))); | |
82 | + /* keep looking, maybe there is another */ | |
0796510c | 83 | + } |
0796510c | 84 | } |
85 | } | |
4aa5c0b3 | 86 | } |
5fe7e92a | 87 | @@ -510,7 +544,8 @@ |
4aa5c0b3 JB |
88 | * probably timeout first |
89 | */ | |
90 | snprintf(connstr, sizeof(connstr), | |
91 | - "dbname=postgres port=%s connect_timeout=5", portstr); | |
92 | + "dbname=postgres port=%s connect_timeout=5%s%s", portstr, | |
93 | + (*sockstr ? " host=" : ""), sockstr); | |
0796510c | 94 | |
95 | for (i = 0; i < wait_seconds; i++) | |
96 | { |