Diff

Differences From Artifact [d44c0f8297]:

To Artifact [3f7bad2ab6]:


   135    135   struct filed_fileinfo *filed_fileinfo_fdcache = NULL;
   136    136   unsigned int filed_fileinfo_fdcache_size = 0;
   137    137   
   138    138   /** Logging **/
   139    139   struct filed_log_entry *filed_log_msg_list;
   140    140   pthread_mutex_t filed_log_msg_list_mutex;
   141    141   pthread_cond_t filed_log_msg_list_ready;
          142  +
          143  +/* Signal Handler */
          144  +static void filed_signal_handler(int signal_number) {
          145  +	struct filed_fileinfo *cache;
          146  +	unsigned int idx;
          147  +
          148  +	switch (signal_number) {
          149  +		case SIGHUP:
          150  +			for (idx = 0; idx < filed_fileinfo_fdcache_size; idx++) {
          151  +				cache = &filed_fileinfo_fdcache[idx];
          152  +
          153  +				pthread_mutex_lock(&cache->mutex);
          154  +
          155  +				cache->path[0] = '\0';
          156  +				if (cache->fd >= 0) {
          157  +					close(cache->fd);
          158  +
          159  +					cache->fd = -1;
          160  +				}
          161  +
          162  +				cache->lastmod = "";
          163  +				cache->type = "";
          164  +
          165  +				pthread_mutex_unlock(&cache->mutex);
          166  +			}
          167  +			break;
          168  +	}
          169  +
          170  +	return;
          171  +}
   142    172   
   143    173   /* Initialize cache */
   144    174   static int filed_init_cache(unsigned int cache_size) {
   145    175   	unsigned int idx;
   146    176   	int mutex_init_ret;
   147    177   
   148    178   	/* Cache may not be re-initialized */
................................................................................
   187    217   	called = 1;
   188    218   
   189    219   	/* Attempt to lock all memory to physical RAM (but don't care if we can't) */
   190    220   	mlockall(MCL_CURRENT | MCL_FUTURE);
   191    221   
   192    222   	/* Ignore SIGPIPE */
   193    223   	signal(SIGPIPE, SIG_IGN);
          224  +
          225  +	/* Handle SIGHUP to release all caches */
          226  +	signal(SIGHUP, filed_signal_handler);
   194    227   
   195    228   	/* Initialize cache structure */
   196    229   	cache_ret = filed_init_cache(cache_size);
   197    230   	if (cache_ret != 0) {
   198    231   		return(cache_ret);
   199    232   	}
   200    233