2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 2N/A * DESCRIPTION: Contains utilities relating to TTL calculation. 2N/A * Constants used in time calculations 2N/A * FUNCTION: has_entry_expired() 2N/A * DESCRIPTION: Determines if an individual entry has expired. 2N/A * INPUTS: Map control structure for an open map 2N/A * OUTPUTS: TRUE = Entry has expired or cannot be found this will cause 2N/A * missing entries to be pulled out of the DIT. 2N/A * FALSE = Entry has not expired 2N/A /* Get expiry time entry for key */ 2N/A * If we failed to get a map expiry key, which must always be 2N/A * present, then something is seriously wrong. Try to recreate 2N/A "for map %s. Will attempt to recreate map",
2N/A * Not a problem just no TTL entry for this entry. Maybe it has 2N/A * not yet been downloaded. Maybe it will be handled by a 2N/A * service other than NIS. Check if the entire map has expired. 2N/A * This prevents repeated LDAP reads when requests are made for 2N/A * nonexistant entries. 2N/A /* Kick of a map update */ 2N/A /* Don't update the entry */ 2N/A * Need to malloc some memory before can syslog the key name 2N/A * but this may fail. Solution log a simple message first THEn 2N/A * a more detailed one if it works. 2N/A "Invalid TTL key in map %s. error %d",
2N/A /* Log the key name */ 2N/A "Could not alloc memory for keyname");
2N/A /* Update it Anyway */ 2N/A /* Get current time */ 2N/A * Because dptr may not be int aligned need to build an int 2N/A * out of what it points to or will get a bus error 2N/A * FUNCTION: has_map_expired() 2N/A * DESCRIPTION: Determines if an entire map has expire 2N/A * INPUTS: Map control structure for an open map 2N/A * OUTPUTS: TRUE = Map has expired 2N/A * FALSE Map has not expired 2N/A /* Set up datum with magic expiry key */ 2N/A /* Call has_entry_expired() with magic map expiry key */ 2N/A * FUNCTION: update_entry_ttl() 2N/A * DESCRIPTION: Updates the TTL for one map entry 2N/A * INPUTS: Map control structure for an open map 2N/A * Flag indication if TTL should be max, min or random 2N/A * OUTPUTS: SUCCESS = TTL updated 2N/A * FAILURE = TTL not updated 2N/A /* Get current time */ 2N/A /* Get TTL from mapping file */ 2N/A /* Convert time into a datum */ 2N/A /* Set expiry time entry for key */ 2N/A * FUNCTION: update_map_ttl() 2N/A * DESCRIPTION: Updates the TTL for entire map. This can be called either with 2N/A * the map open (map_ctrl DBM pointer set up) or the map closed 2N/A * (map_ctrl DBM pointers not set). The latter case will occur 2N/A * when we have just created a new map. 2N/A * This function must open the TTL map but, in either case, must 2N/A * return with the map_ctrl in it's original state. 2N/A * INPUTS: Map control structure for an open map 2N/A * OUTPUTS: SUCCESS = TTL updated 2N/A * FAILURE = TTL not updated 2N/A /* Set up datum with magic expiry key */ 2N/A /* If TTL not open open it */ 2N/A /* Call update_entry_ttl() with magic map expiry key */ 2N/A /* If we had to open TTL file close it */ 2N/A * FUNCTION: add_to_timeval() 2N/A * DESCRIPTION: Adds an int to a timeval 2N/A * NOTE : Seems strange that there is not a library function to do this 2N/A * if one exists then this function can be removed. 2N/A * NOTE : Does not handle UNIX clock wrap round but this is a much bigger 2N/A * INPUTS: Time value to add to 2N/A * Time value to add in seconds 2N/A * OUTPUTS: SUCCESS = Addition successful 2N/A * FAILURE = Addition failed (probably wrapped) 2N/A /* Add seconds part */ 2N/A /* Check for clock wrap */ 2N/A * FUNCTION: is_greater_timeval() 2N/A * DESCRIPTION: Compares two timevals 2N/A * NOTE : Seems strange that there is not a library function to do this 2N/A * if one exists then this function can be removed. 2N/A * INPUTS: First time value 2N/A * Time value to compare it with 2N/A * OUTPUTS: TRUE t1 > t2