From: pcarana Date: Fri, 8 Mar 2019 15:28:57 +0000 (-0600) Subject: Remove unused ttl, the client is related to the socket file descriptor X-Git-Tag: v0.0.2~52^2~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a7f08d1f61b24873e6728085ab1e873f7642036;p=thirdparty%2FFORT-validator.git Remove unused ttl, the client is related to the socket file descriptor --- diff --git a/src/clients.c b/src/clients.c index bc81eb0f..4495e3ed 100644 --- a/src/clients.c +++ b/src/clients.c @@ -54,8 +54,7 @@ static struct client } static int -create_client(int fd, struct sockaddr_storage *addr, u_int8_t rtr_version, - time_t ttl) +create_client(int fd, struct sockaddr_storage *addr, u_int8_t rtr_version) { struct client *client; @@ -75,21 +74,19 @@ create_client(int fd, struct sockaddr_storage *addr, u_int8_t rtr_version, client->sin_port = SADDR_IN6(addr)->sin6_port; } client->rtr_version = rtr_version; - client->expiration = time(NULL) + ttl; return clients_db_add_client(client); } int -update_client(int fd, struct sockaddr_storage *addr, u_int8_t rtr_version, - time_t ttl) +update_client(int fd, struct sockaddr_storage *addr, u_int8_t rtr_version) { struct client *client; client = get_client(addr, rtr_version); if (client == NULL) - return create_client(fd, addr, rtr_version, ttl); - client->expiration = time(NULL) + ttl; + return create_client(fd, addr, rtr_version); + client->fd = fd; return 0; } diff --git a/src/clients.h b/src/clients.h index 2f218b88..6888f32c 100644 --- a/src/clients.h +++ b/src/clients.h @@ -2,7 +2,6 @@ #define SRC_CLIENTS_H_ #include -#include struct client { int fd; @@ -13,12 +12,10 @@ struct client { }; in_port_t sin_port; u_int8_t rtr_version; - /* TODO forget clients when the expiration time is reached */ - time_t expiration; }; int clients_db_init(void); -int update_client(int fd, struct sockaddr_storage *, u_int8_t, time_t); +int update_client(int fd, struct sockaddr_storage *, u_int8_t); size_t client_list(struct client **); void clients_db_destroy(void); diff --git a/src/rtr/rtr.c b/src/rtr/rtr.c index 9f332a2e..3b9fac49 100644 --- a/src/rtr/rtr.c +++ b/src/rtr/rtr.c @@ -125,9 +125,7 @@ client_thread_cb(void *param_void) return NULL; /* RTR Version ready, now update client */ - /* TODO Remove this hardcoded ttl */ - err = update_client(param.client_fd, ¶m.client_addr, rtr_version, - 3600); + err = update_client(param.client_fd, ¶m.client_addr, rtr_version); if (err) return NULL; @@ -183,9 +181,6 @@ handle_client_connections(int server_fd) arg->client_fd = client_fd; arg->client_addr = client_addr; - /* - * FIXME Handle session IDs, serial IDs, protocol version - */ errno = pthread_create(&thread, NULL, client_thread_cb, arg); if (errno) { warn("Could not spawn the client's thread");