20d2f29ca6491f11c70c95e041220fe72c37a2dd
galt
  Sun Dec 22 15:06:45 2024 -0800
fix compiler warning about about restrict keywords in pthread_create.

diff --git src/hg/hgTracks/searchTracks.c src/hg/hgTracks/searchTracks.c
index 91ddba0..02df9c0 100644
--- src/hg/hgTracks/searchTracks.c
+++ src/hg/hgTracks/searchTracks.c
@@ -241,62 +241,56 @@
     struct hubSearchTracks *next;
     char *hubUrl; // the url to this hub which is used as a key into the search hash
     int hubId;
     struct hubConnectStatus *hub; // the hubStatus result
     struct slName *searchedTracks; // the track names the search terms matched against
     };
 
 struct paraFetchData
 /* A helper struct for managing connecting to many hubs in parallel  and adding the
  * relevant tracks to the global (struct slRef *)tracks struct. */
     {
     struct paraFetchData *next;
     char *hubName; // the name of the hub for measureTiming results
     struct hubSearchTracks *hst; // the tracks we are adding to the search results
     struct track *tlist; // the resulting tracks to add to the global trackList
-    pthread_t *threadId; // so we can stop the thread if it has been taking too long
     long searchTime; // how many milliseconds did it take to search this hub
     boolean done;
     };
 
 // helper variables for connecting to hubs in parallel
 pthread_mutex_t pfdMutex = PTHREAD_MUTEX_INITIALIZER;
 struct paraFetchData *pfdListInitial = NULL;
 struct paraFetchData *pfdList = NULL;
 struct paraFetchData *pfdRunning = NULL;
 struct paraFetchData *pfdDone = NULL;
 
-void *addUnconnectedHubSearchResults(void *threadParam)
+void *addUnconnectedHubSearchResults()
 /* Add a not yet connected hub to the search results */
 {
-pthread_t *thread = threadParam;
 struct paraFetchData *pfd = NULL;
-// this thread will just happily keep working until waitForSearchResults() finishes,
-// moving it's completed work onto pfdDone, so we can safely detach
-pthread_detach(*thread);
 boolean allDone = FALSE;
 while(1)
     {
     pthread_mutex_lock(&pfdMutex);
     // the wait function will set pfdList = NULL, so don't start up any more
     // stuff if that happens:
     if (!pfdList)
         allDone = TRUE;
     else
         {
         pfd = slPopHead(&pfdList);
-        pfd->threadId = threadParam;
         slAddHead(&pfdRunning, pfd);
         }
     pthread_mutex_unlock(&pfdMutex);
     if (allDone)
         return NULL;
     struct hubSearchTracks *hst = pfd->hst;
     struct track *tracksToAdd = NULL;
     long startTime = clock1000();
     struct errCatch *errCatch = errCatchNew();
     if (errCatchStart(errCatch))
         {
         pfd->done = FALSE;
         boolean foundFirstGenome = FALSE;
         struct hash *trackDbNameHash = newHash(5);
         struct trackDb *tdbList = hubAddTracks(hst->hub, database, &foundFirstGenome, trackDbNameHash, NULL);
@@ -433,36 +427,30 @@
 struct paraFetchData *neverRan = pfdList;
 if (lockStatus == 0)
     {
     // prevent still running threads from continuing
     pfdList = NULL;
     if (measureTiming)
         fprintf(stdout, "<span class='timing'>Successfully aquired lock, adding any succesful thread data\n<br></span>");
     for (pfd = pfdDone; pfd != NULL; pfd = pfd->next)
         {
         struct track *t;
         for (t = pfd->tlist; t != NULL; t = t->next)
             refAdd(&tracks, t);
         if (measureTiming)
             measureTime("'%s' search times", pfd->hubName);
         }
-    for (pfd = pfdRunning; pfd != NULL; pfd = pfd->next)
-        {
-        pthread_cancel(*pfd->threadId);
-        if (measureTiming)
-            measureTime("'%s' search times: timed out", pfd->hubName);
-        }
     for (pfd = neverRan; pfd != NULL; pfd = pfd->next)
         if (measureTiming)
             measureTime("'%s' search times: never ran", pfd->hubName);
     }
 else
     {
     // Should we warn or something that results are still waiting? As of now
     // just silently return instead, and note that no unconnected hub data
     // will show up (we get connected hub results for free because of
     // trackDbCaching)
     if (measureTiming)
         measureTime("Timed out searching hubs");
     }
 if (lockStatus == 0)
     pthread_mutex_unlock(&pfdMutex);
@@ -502,34 +490,37 @@
     hubSearchHashToPfdList(descSearch, searchResultsHash, hubLookup, conn);
     if (measureTiming)
         measureTime("after querying hubSearchText table and ready to start threads");
     int ptMax = atoi(cfgOptionDefault("parallelFetch.threads", "20"));
     int pfdListCount = 0, pt;
     if (ptMax > 0)
         {
         pfdListCount = slCount(pfdList);
         pthread_t *threads = NULL;
         ptMax = min(ptMax, pfdListCount);
         if (ptMax > 0)
             {
             AllocArray(threads, ptMax);
             for (pt = 0; pt < ptMax; pt++)
                 {
-                int rc = pthread_create(&threads[pt], NULL, addUnconnectedHubSearchResults, &threads[pt]);
+                int rc = pthread_create(&threads[pt], NULL, addUnconnectedHubSearchResults, NULL);
                 if (rc )
                     errAbort("Unexpected error in pthread_create");
                 }
+	    pthread_detach(threads[pt]);
+		// this thread will just happily keep working until waitForSearchResults() finishes,
+		// moving it's completed work onto pfdDone, so we can safely detach
             }
         waitForSearchResults(ptMax, threads);
         }
     }
 if (measureTiming)
     measureTime("Total time spent searching hubs");
 }
 
 static void simpleSearchForTracks(char *simpleEntry)
 // Performs the simple search and returns the found tracks.
 {
 // Prepare for trix search
 if (!isEmpty(simpleEntry))
     {
     int trixWordCount = 0;