bb0c928c8f742748411ec50a2e155880b2d57e49 kent Thu Sep 12 14:09:25 2013 -0700 Adding parallelFetchInterruptable, which has a callback that checks for interrupt. diff --git src/inc/paraFetch.h src/inc/paraFetch.h index d34a460..2253a93 100644 --- src/inc/paraFetch.h +++ src/inc/paraFetch.h @@ -1,23 +1,30 @@ /* paraFetch - fetch things from remote URLs in parallel. */ #ifndef PARAFETCH_H #define PARAFETCH_H boolean parallelFetch(char *url, char *outPath, int numConnections, int numRetries, boolean newer, boolean progress); /* Open multiple parallel connections to URL to speed downloading */ +boolean parallelFetchInterruptable(char *url, char *outPath, int numConnections, int numRetries, + boolean newer, boolean progress, + boolean (*interrupt)(void *context), void *context); +/* Open multiple parallel connections to URL to speed downloading. If interrupt function + * is non-NULL, then it gets called passing the context parameter, and if it returns + * TRUE the fetch is interrupted. */ + struct parallelConn /* struct to information on a parallel connection */ { struct parallelConn *next; /* next connection */ int sd; /* socket descriptor */ off_t rangeStart; /* where does the range start */ off_t partSize; /* range size */ off_t received; /* bytes received */ }; boolean paraFetchReadStatus(char *origPath, struct parallelConn **pPcList, char **pUrl, off_t *pFileSize, char **pDateString, off_t *pTotalDownloaded); /* Read a status file - which is just origPath plus .paraFetchStatus. This is updated during * transit by parallelFetch. Returns FALSE if status file not there - possibly because