scope reduction, commenting
This commit is contained in:
parent
9ec23c6239
commit
9b688d7cb0
@ -287,6 +287,8 @@ TALER_MHD_open_unix_path (const char *unix_path,
|
||||
"set socket '%s' to mode %o\n",
|
||||
unix_path,
|
||||
unix_mode);
|
||||
|
||||
/* extract and return actual socket handle from 'nh' */
|
||||
{
|
||||
int fd;
|
||||
|
||||
@ -315,15 +317,13 @@ TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
uint16_t *port)
|
||||
{
|
||||
char *bind_to;
|
||||
char *serve_unixpath;
|
||||
mode_t unixpath_mode;
|
||||
char port_str[6];
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *res;
|
||||
int ec;
|
||||
struct GNUNET_NETWORK_Handle *nh;
|
||||
|
||||
*port = 0;
|
||||
{
|
||||
char *serve_unixpath;
|
||||
mode_t unixpath_mode;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_MHD_parse_config (cfg,
|
||||
section,
|
||||
@ -334,19 +334,29 @@ TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
if (NULL != serve_unixpath)
|
||||
return TALER_MHD_open_unix_path (serve_unixpath,
|
||||
unixpath_mode);
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
section,
|
||||
"BIND_TO",
|
||||
&bind_to))
|
||||
return -1; /* only set port */
|
||||
|
||||
/* let's have fun binding... */
|
||||
{
|
||||
char port_str[6];
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *res;
|
||||
int ec;
|
||||
|
||||
GNUNET_snprintf (port_str,
|
||||
sizeof (port_str),
|
||||
"%u",
|
||||
(unsigned int) *port);
|
||||
*port = 0; /* do NOT return port in case of errors */
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
memset (&hints,
|
||||
0,
|
||||
sizeof (hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
@ -355,6 +365,7 @@ TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
| AI_IDN
|
||||
#endif
|
||||
;
|
||||
|
||||
if (0 !=
|
||||
(ec = getaddrinfo (bind_to,
|
||||
port_str,
|
||||
@ -363,7 +374,8 @@ TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to resolve BIND_TO address `%s': %s\n",
|
||||
bind_to, gai_strerror (ec));
|
||||
bind_to,
|
||||
gai_strerror (ec));
|
||||
GNUNET_free (bind_to);
|
||||
return -1;
|
||||
}
|
||||
@ -389,6 +401,8 @@ TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
return -1;
|
||||
}
|
||||
freeaddrinfo (res);
|
||||
}
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_NETWORK_socket_listen (nh,
|
||||
UNIX_BACKLOG))
|
||||
@ -398,6 +412,8 @@ TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
GNUNET_SCHEDULER_shutdown ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* extract and return actual socket handle from 'nh' */
|
||||
{
|
||||
int fh;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user