From: Jennifer Richards Date: Wed, 11 Jan 2017 16:24:37 +0000 (-0500) Subject: Bring back tids_start() function. X-Git-Tag: v2.1.1~2 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=commitdiff_plain;h=acabdc87e86f8d8749ac20ab127cfca52c417123 Bring back tids_start() function. --- diff --git a/tid/example/tids_main.c b/tid/example/tids_main.c index 9b87ef7..7b58840 100644 --- a/tid/example/tids_main.c +++ b/tid/example/tids_main.c @@ -355,11 +355,6 @@ int main (int argc, TIDS_INSTANCE *tids; TR_NAME *gssname = NULL; struct cmdline_args opts={NULL}; -#define MAX_SOCKETS 10 - int tids_socket[MAX_SOCKETS]; - size_t n_sockets; - struct pollfd poll_fds[MAX_SOCKETS]; - size_t ii=0; /* parse the command line*/ argp_parse(&argp, argc, argv, 0, 0, &opts); @@ -391,31 +386,7 @@ int main (int argc, } tids->ipaddr = opts.ip_address; - - /* get listener for tids port */ - n_sockets = tids_get_listener(tids, &tids_req_handler, auth_handler, opts.hostname, TID_PORT, gssname, - tids_socket, MAX_SOCKETS); - - for (ii=0; ii 0) { - for (ii=0; ii #include #include +#include #include #include #include @@ -430,7 +431,7 @@ int tids_get_listener(TIDS_INSTANCE *tids, tids->tids_port = port; n_fd=tids_listen(tids, port, fd_out, max_fd); - if (n_fd==0) + if (n_fd<=0) tr_debug("tids_get_listener: Error opening port %d"); else { /* opening port succeeded */ @@ -492,6 +493,66 @@ int tids_accept(TIDS_INSTANCE *tids, int listen) return 0; } +/* Process tids requests forever. Should not return except on error. */ +#define MAX_SOCKETS 10 +int tids_start (TIDS_INSTANCE *tids, + TIDS_REQ_FUNC *req_handler, + tids_auth_func *auth_handler, + const char *hostname, + unsigned int port, + void *cookie) +{ + int fd[MAX_SOCKETS]={0}; + size_t n_fd=0; + struct pollfd poll_fd[MAX_SOCKETS]={{0}}; + int ii=0; + + n_fd=tids_get_listener(tids, req_handler, auth_handler, hostname, port, cookie, fd, MAX_SOCKETS); + if (n_fd <= 0) { + perror ("Error from tids_listen()"); + return 1; + } + + tr_info("Trust Path Query Server starting on host %s:%d.", hostname, port); + + /* set up the poll structs */ + for (ii=0; ii