diff --git a/src/db.c b/src/db.c index 57a93dea..4a682e75 100644 --- a/src/db.c +++ b/src/db.c @@ -268,6 +268,15 @@ static const char *sort_clause[] = static char *db_path; static __thread sqlite3 *hdl; +/* + * Starting database revision. A number of 2 ensures that remote clients + * always get a fresh update. (they start with 1) + */ +static int db_rev = 2; +/* Update the database revision number. Don't worry about multiple threads, + we don't care about an accurate count of the number of revisions, just + that revisions have occurred or not. */ +#define db_rev_increment() { db_rev ++; } /* Forward */ static int @@ -279,6 +288,14 @@ db_smartpl_count_items(const char *smartpl_query); struct playlist_info * db_pl_fetch_byid(int id); +/* + * db_revision_number - return current database revision number to external modules + */ +int +db_revision_number() +{ + return db_rev; +} char * db_escape_string(const char *str) @@ -2007,6 +2024,7 @@ db_file_add(struct media_file_info *mfi) } sqlite3_free(query); + db_rev_increment(); return 0; @@ -2081,6 +2099,7 @@ db_file_update(struct media_file_info *mfi) } sqlite3_free(query); + db_rev_increment(); return 0; diff --git a/src/db.h b/src/db.h index b3468a3b..87c1493f 100644 --- a/src/db.h +++ b/src/db.h @@ -470,6 +470,8 @@ db_watch_enum_end(struct watch_enum *we); int db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd); +int +db_revision_number(void); int db_perthread_init(void); diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 637c0b8f..d3af6270 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -65,12 +65,6 @@ extern struct event_base *evbase_httpd; /* How often we poll for database changes */ #define DAAP_UPDATE_MONITOR_TIMEOUT 10 -/* XXX Workaround before adding revision support in db.c; - Client will not get dynamic updates. The state of the - database at the time of connection is all the client - gets. */ -#define db_revision_number() (2) - struct uri_map { regex_t preg; char *regexp;