diff --git a/src/config.c b/src/config.c index 12fff59..23a486e 100644 --- a/src/config.c +++ b/src/config.c @@ -336,7 +336,6 @@ int do_uplink(struct uplink_config_t **lq, int argc, char **argv) clflags |= CLFLAGS_PORT_RO; } // FIXME: other tokens ?? - memset(&req, 0, sizeof(req)); req.ai_family = 0; req.ai_socktype = SOCK_STREAM; @@ -365,15 +364,15 @@ int do_uplink(struct uplink_config_t **lq, int argc, char **argv) return -2; } +#if 0 i = getaddrinfo(argv[4], argv[5], &req, &ai); if (i != 0) { - hlog(LOG_ERR,"Uplink: address parse failure of '%s' '%s'",argv[4],argv[5]); - return i; + hlog(LOG_INFO,"Uplink: address resolving failure of '%s' '%s'",argv[4],argv[5]); + /* But do continue, this is perhaps a temporary glitch ? */ } if (ai) freeaddrinfo(ai); - - +#endif l = hmalloc(sizeof(*l)); l->name = hstrdup(argv[1]); diff --git a/src/uplink.c b/src/uplink.c index c6df53f..57c25ba 100644 --- a/src/uplink.c +++ b/src/uplink.c @@ -53,6 +53,13 @@ struct client_t *uplink_client; int uplink_running; pthread_t uplink_th; +/* global uplink connects, and protocol traffic accounters */ + +struct portaccount_t uplink_connects = { + .mutex = PTHREAD_MUTEX_INITIALIZER, + .refcount = 99, /* Global static blocks have extra-high initial refcount */ +}; + /* * signal handler @@ -107,6 +114,8 @@ void uplink_close(struct client_t *c) return; } + -- uplink_connects.gauge; + uplink_client = NULL; // there can be only one! if ((rc = pthread_mutex_unlock(&uplink_client_mutex))) { @@ -180,19 +189,19 @@ int make_uplink(struct uplink_config_t *l) req.ai_protocol = IPPROTO_SCTP; #endif } else { - fprintf(stderr, "Uplink: Unsupported protocol '%s'\n", l->proto); + hlog(LOG_ERR, "Uplink: Unsupported protocol '%s'\n", l->proto); return -2; } port = atoi(l->port); if (port < 1 || port > 65535) { - fprintf(stderr, "Uplink: unsupported port number '%s'\n", l->port); + hlog(LOG_ERR, "Uplink: unsupported port number '%s'\n", l->port); return -2; } i = getaddrinfo(l->host, l->port, &req, &ai); if (i != 0) { - fprintf(stderr,"Uplink: address parse failure of '%s' '%s'",l->host,l->port); + hlog(LOG_INFO,"Uplink: address resolving failure of '%s' '%s'",l->host,l->port); return i; } @@ -286,6 +295,12 @@ int make_uplink(struct uplink_config_t *l) hlog(LOG_ERR, "make_uplink(): could not unlock new_clients_mutex: %s", strerror(pe)); goto err; } + + ++ uplink_connects.gauge; + ++ uplink_connects.counter; + ++ uplink_connects.refcount; + + c->portaccount = & uplink_connects; return 0;