equal
deleted
inserted
replaced
99 * Do something to apply an endpoint to a socket |
99 * Do something to apply an endpoint to a socket |
100 */ |
100 */ |
101 static int _socket_do (struct config_endpoint *endpoint, int *sock, int sock_type, struct sockaddr_storage *addr, enum socket_op sockop) { |
101 static int _socket_do (struct config_endpoint *endpoint, int *sock, int sock_type, struct sockaddr_storage *addr, enum socket_op sockop) { |
102 struct addrinfo *res = NULL, *info, _fake_res; |
102 struct addrinfo *res = NULL, *info, _fake_res; |
103 struct sockaddr_un _fake_addr_un; |
103 struct sockaddr_un _fake_addr_un; |
|
104 int err = -1; |
104 |
105 |
105 if (endpoint->family == PF_UNIX) { |
106 if (endpoint->family == PF_UNIX) { |
106 // getaddrinfo doesn't handle PF_UNIX, so we need to build a fake result |
107 // getaddrinfo doesn't handle PF_UNIX, so we need to build a fake result |
107 |
108 |
108 // build the sockaddr_un |
109 // build the sockaddr_un |
187 break; |
188 break; |
188 } |
189 } |
189 |
190 |
190 if (*sock == -1) |
191 if (*sock == -1) |
191 ERROR("no working results from getaddrinfo: %s#%s", endpoint->af.inet.addr, endpoint->af.inet.port); |
192 ERROR("no working results from getaddrinfo: %s#%s", endpoint->af.inet.addr, endpoint->af.inet.port); |
192 |
193 |
193 return 0; |
194 // success |
|
195 err = 0; |
194 |
196 |
195 error: |
197 error: |
196 if (res != 0 && res != &_fake_res) |
198 if (res != 0 && res != &_fake_res) |
197 freeaddrinfo(res); |
199 freeaddrinfo(res); |
198 |
200 |
199 return -1; |
201 return err; |
200 } |
202 } |
201 |
203 |