|
62 | 62 | :.ipc.connectWithTimeout[hostPort;::]; |
63 | 63 | }; |
64 | 64 |
|
| 65 | +/ Open a connection to the specified target host/port and allow waiting indefinitely until the process responds |
| 66 | +/ @param hostPort (HostPort) The target process to connect to |
| 67 | +/ @return (Integer) The handle to that process if the connection is successful |
| 68 | +/ @see .ipc.connectWithTimeout |
| 69 | +.ipc.connectWait:{[hostPort] |
| 70 | + :.ipc.connectWithTimeout[hostPort; 0]; |
| 71 | + }; |
| 72 | + |
65 | 73 | / Open a connection to the specified target host/port with a maximum timeout period. |
66 | | -/ NOTE: Passwords can be configured to not be printed to via logging. However, the password will always be present |
67 | | -/ in .ipc.outbound |
| 74 | +/ NOTE: Passwords can be configured to not be printed to via logging |
68 | 75 | / @param hostPort (HostPort) The target process to connect to |
69 | 76 | / @param timeout (Integer) The maximum time to wait for a connection. Pass generic null to use the default |
70 | 77 | / @return (Integer) The handle to that process if the connection is successful |
|
77 | 84 | '"IllegalArgumentException"; |
78 | 85 | ]; |
79 | 86 |
|
80 | | - if[.util.isEmpty timeout; |
| 87 | + $[.util.isEmpty timeout; |
81 | 88 | timeout:.ipc.cfg.defaultConnectTimeout; |
| 89 | + 0 > timeout; |
| 90 | + '"IllegalArgumentException" |
82 | 91 | ]; |
83 | 92 |
|
84 | | - logHostPort:string .type.ensureHostPortSymbol hostPort; |
| 93 | + hostPort:.type.ensureHostPortSymbol hostPort; |
| 94 | + |
| 95 | + logHostPort:string hostPort; |
| 96 | + logTimeout:$[timeout in 0 0Wi; "waiting indefinitely"; "timeout ",string[timeout]," ms"]; |
85 | 97 |
|
86 | 98 | if[not .ipc.cfg.logPasswordsDuringConnect; |
87 | 99 | if[4 = count where ":" = string hostPort; |
|
92 | 104 | ]; |
93 | 105 | ]; |
94 | 106 |
|
95 | | - .log.if.info "Attempting to connect to ",logHostPort," (timeout ",string[timeout]," ms)"; |
| 107 | + .log.if.info ("Attempting to connect to {} ({})"; logHostPort; logTimeout); |
96 | 108 |
|
97 | 109 | h:@[hopen; (hostPort; timeout); { (`CONN_FAIL;x) }]; |
98 | 110 |
|
|
114 | 126 | / @see .q.hclose |
115 | 127 | .ipc.disconnect:{[h] |
116 | 128 | closeRes:@[hclose;h;{ (`FAILED_TO_CLOSE;x) }]; |
117 | | - |
| 129 | + |
118 | 130 | .ipc.i.connectionClosed h; |
119 | | - |
| 131 | + |
120 | 132 | if[`FAILED_TO_CLOSE~first closeRes; |
121 | 133 | .log.if.warn "Failed to close handle ",string[h],". Error - ",last closeRes; |
122 | 134 | :0b; |
|
0 commit comments