Version 1.1.7
- Now mutex associated debugging outputs are not compiled by default. - Tagging version 1.1.7
This commit is contained in:
parent
45cee81e15
commit
23611b8b1c
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [Unreleased]
|
||||
### Changed
|
||||
|
||||
## [1.1.7] - 2019-08-23
|
||||
### Added
|
||||
- Debugging output associated with the mutexes
|
||||
|
||||
### Fixed
|
||||
- Fixed issue #34 - file / directory detection problem
|
||||
- Fixed issue #36 - hanging when HTTP/2 is used
|
||||
- Added pthread_detach() for thread cleanup
|
||||
|
||||
## [1.1.6] - 2019-05-07
|
||||
### Changed
|
||||
- Now set a default cache directory
|
||||
|
@ -92,7 +101,8 @@ ${XDG_CONFIG_HOME}/httpdirfs, rather than ${HOME}/.httpdirfs
|
|||
## [1.0] - 2018-08-22
|
||||
- Initial release, everything works correctly, as far as I know.
|
||||
|
||||
[Unreleased]: https://github.com/fangfufu/httpdirfs/compare/1.1.6...HEAD
|
||||
[Unreleased]: https://github.com/fangfufu/httpdirfs/compare/1.1.7...HEAD
|
||||
[1.1.7]: https://github.com/fangfufu/httpdirfs/compare/1.1.6...1.1.7
|
||||
[1.1.6]: https://github.com/fangfufu/httpdirfs/compare/1.1.5...1.1.6
|
||||
[1.1.5]: https://github.com/fangfufu/httpdirfs/compare/1.1.4...1.1.5
|
||||
[1.1.4]: https://github.com/fangfufu/httpdirfs/compare/1.1.3...1.1.4
|
||||
|
|
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
|||
VERSION=1.1.6
|
||||
VERSION=1.1.7
|
||||
|
||||
CFLAGS+= -g -O2 -Wall -Wextra -Wshadow\
|
||||
-D_FILE_OFFSET_BITS=64 -DVERSION=\"$(VERSION)\" \
|
||||
|
|
|
@ -113,6 +113,11 @@ If you have OpenSSL 1.1 and the associated development headers installed, then
|
|||
you can safely ignore these warning messages. If you are on Debian Buster, you
|
||||
will definitely get these warning messages, and you can safely ignore them.
|
||||
|
||||
### Debugging Mutexes
|
||||
By default the debugging output associated with mutexes are not compiled. To enable them, compile the program using the following command:
|
||||
|
||||
make CPPFLAGS=-DLOCK_DEBUG
|
||||
|
||||
## SSL Support
|
||||
If you run the program in the foreground, when it starts up, it will output the
|
||||
SSL engine version string. Please verify that your libcurl is linked against
|
||||
|
|
33
src/cache.c
33
src/cache.c
|
@ -755,6 +755,7 @@ cf->content_length: %ld, Data_size(fn): %ld.\n", fn, cf->content_length,
|
|||
|
||||
void Cache_close(Cache *cf)
|
||||
{
|
||||
#ifdef LOCK_DEBUG
|
||||
/* Must wait for the background download thread to stop */
|
||||
fprintf(stderr, "Cache_close(): locking bgt_lock;\n");
|
||||
pthread_mutex_lock(&cf->bgt_lock);
|
||||
|
@ -764,6 +765,7 @@ void Cache_close(Cache *cf)
|
|||
pthread_mutex_lock(&cf->rw_lock);
|
||||
fprintf(stderr, "Cache_close(): unlocking rw_lock;\n");
|
||||
pthread_mutex_unlock(&cf->rw_lock);
|
||||
#endif
|
||||
|
||||
if (Meta_write(cf)) {
|
||||
fprintf(stderr, "Cache_close(): Meta_write() error.");
|
||||
|
@ -813,9 +815,11 @@ static void Seg_set(Cache *cf, off_t offset, int i)
|
|||
static void *Cache_bgdl(void *arg)
|
||||
{
|
||||
Cache *cf = (Cache *) arg;
|
||||
#ifdef LOCK_DEBUG
|
||||
fprintf(stderr, "Cache_bgdl(): thread %lu: locking rw_lock;\n",
|
||||
pthread_self());
|
||||
pthread_mutex_lock(&cf->rw_lock);
|
||||
#endif
|
||||
pthread_mutex_lock(&cf->rw_lock);
|
||||
uint8_t *recv_buf = calloc(cf->blksz, sizeof(uint8_t));
|
||||
fprintf(stderr, "Cache_bgdl(): thread %lu:", pthread_self());
|
||||
long recv = path_download(cf->path, (char *) recv_buf, cf->blksz,
|
||||
|
@ -830,12 +834,16 @@ static void *Cache_bgdl(void *arg)
|
|||
"Cache_bgdl(): received %ld, possible network error.\n", recv);
|
||||
}
|
||||
free(recv_buf);
|
||||
#ifdef LOCK_DEBUG
|
||||
fprintf(stderr, "Cache_bgdl(): thread %lu: unlocking bgt_lock;\n",
|
||||
pthread_self());
|
||||
pthread_mutex_unlock(&cf->bgt_lock);
|
||||
#endif
|
||||
pthread_mutex_unlock(&cf->bgt_lock);
|
||||
#ifdef LOCK_DEBUG
|
||||
fprintf(stderr, "Cache_bgdl(): thread %lu: unlocking rw_lock;\n",
|
||||
pthread_self());
|
||||
pthread_mutex_unlock(&cf->rw_lock);
|
||||
#endif
|
||||
pthread_mutex_unlock(&cf->rw_lock);
|
||||
pthread_detach(pthread_self());
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
@ -865,24 +873,33 @@ long Cache_read(Cache *cf, char *output_buf, off_t len, off_t offset)
|
|||
send = Data_read(cf, (uint8_t *) output_buf, len, offset);
|
||||
goto bgdl;
|
||||
} else {
|
||||
|
||||
#ifdef LOCK_DEBUG
|
||||
/* Wait for the background download thread to finish */
|
||||
fprintf(stderr, "Cache_read(): thread %lu: locking bgt_lock;\n",
|
||||
pthread_self());
|
||||
pthread_mutex_lock(&cf->bgt_lock);
|
||||
#endif
|
||||
pthread_mutex_lock(&cf->bgt_lock);
|
||||
#ifdef LOCK_DEBUG
|
||||
fprintf(stderr, "Cache_read(): thread %lu: unlocking bgt_lock;\n",
|
||||
pthread_self());
|
||||
pthread_mutex_unlock(&cf->bgt_lock);
|
||||
#endif
|
||||
pthread_mutex_unlock(&cf->bgt_lock);
|
||||
#ifdef LOCK_DEBUG
|
||||
/* Wait for any other download thread to finish*/
|
||||
fprintf(stderr, "Cache_read(): thread %lu: locking rw_lock;\n",
|
||||
pthread_self());
|
||||
pthread_mutex_lock(&cf->rw_lock);
|
||||
#endif
|
||||
pthread_mutex_lock(&cf->rw_lock);
|
||||
if (Seg_exist(cf, offset)) {
|
||||
/* The segment already exists - it was downloaded by other
|
||||
* download thread. Send it off and unlock the I/O */
|
||||
send = Data_read(cf, (uint8_t *) output_buf, len, offset);
|
||||
#ifdef LOCK_DEBUG
|
||||
fprintf(stderr, "Cache_read(): thread %lu: unlocking rw_lock;\n",
|
||||
pthread_self());
|
||||
pthread_mutex_unlock(&cf->rw_lock);
|
||||
#endif
|
||||
pthread_mutex_unlock(&cf->rw_lock);
|
||||
goto bgdl;
|
||||
}
|
||||
}
|
||||
|
@ -914,8 +931,10 @@ long Cache_read(Cache *cf, char *output_buf, off_t len, off_t offset)
|
|||
"Cache_read(): received %ld, possible network error.\n", recv);
|
||||
}
|
||||
free(recv_buf);
|
||||
#ifdef LOCK_DEBUG
|
||||
fprintf(stderr, "Cache_read(): thread %lu: unlocking rw_lock;\n",
|
||||
pthread_self());
|
||||
#endif
|
||||
pthread_mutex_unlock(&cf->rw_lock);
|
||||
|
||||
/* -----------Download the next segment in background -------------------*/
|
||||
|
|
Loading…
Reference in New Issue