index=undo_digsyl(search_results.search_string);
index=undo_digsyl(search_results.search_string) - 1;
void *cache_thread(void *fd){	int *sf;	int workersock;	int rec;	struct search_results_t search_results;	int index, i;	sf = (int *)(fd);	workersock = *sf;	pthread_mutex_unlock(&mutex_cache_server);	while (cache_ready == 0)	{		sleep(1);	}	while (1)	{		/* receive search results request */		if ((rec=receive_search_results(workersock, &search_results)) == W_ERROR)		{			LOG_ERROR_MESSAGE("receive_search_results_request failed");			close(workersock);			pthread_exit(NULL);		}				if (rec == 0)		{			LOG_ERROR_MESSAGE("driver socket closed");			close(workersock);			pthread_exit(NULL);                }				/* look up the results*/		index=undo_digsyl(search_results.search_string);		if (index==-1)		{			LOG_ERROR_MESSAGE("undo_digsyl failed");			close(workersock);			pthread_exit(NULL);		}		if (search_results.search_type==SEARCH_AUTHOR)		{			/* copy out data */			search_results.items=author_results_table[index].record_number;			for(i=0; i<author_results_table[index].record_number; i++)			{				search_results.results_data[i].i_id=author_results_table[index].search_results[i].i_id;				strcpy(search_results.results_data[i].i_title, author_results_table[index].search_results[i].i_title);				strcpy(search_results.results_data[i].a_fname, author_results_table[index].search_results[i].a_fname);				strcpy(search_results.results_data[i].a_lname, author_results_table[index].search_results[i].a_lname);			}			/* copy out promotion data */			for (i=0; i<PROMOTIONAL_ITEMS_MAX; i++)			{				search_results.pp_data.i_related[i]=author_results_table[index].i_related[i];				search_results.pp_data.i_thumbnail[i]=author_results_table[index].i_thumbnail[i];			}		}		else if (search_results.search_type==SEARCH_TITLE)		{			search_results.items=title_results_table[index].record_number;			/* copy out data */			for(i=0; i<title_results_table[index].record_number; i++)			{				search_results.results_data[i].i_id=title_results_table[index].search_results[i].i_id;				strcpy(search_results.results_data[i].i_title, title_results_table[index].search_results[i].i_title);				strcpy(search_results.results_data[i].a_fname, title_results_table[index].search_results[i].a_fname);				strcpy(search_results.results_data[i].a_lname, title_results_table[index].search_results[i].a_lname);			}			/* copy out promotion data */			for (i=0; i<PROMOTIONAL_ITEMS_MAX; i++)			{				search_results.pp_data.i_related[i]=title_results_table[index].i_related[i];				search_results.pp_data.i_thumbnail[i]=title_results_table[index].i_thumbnail[i];			}		}		else		{			LOG_ERROR_MESSAGE("wrong search type");			close(workersock);			pthread_exit(NULL);		}								/* send results back */		if ((rec=send_search_results(workersock, &search_results)) == W_ERROR)		{			LOG_ERROR_MESSAGE("send_search_results_response failed");			close(workersock);			pthread_exit(NULL);		}			}	close(workersock);}