* Fix bug where the UpdateID was not being incremented during a full rescan.

This commit is contained in:
Justin Maggard 2011-04-28 05:47:36 +00:00
parent 1949383062
commit ec4998ebde

View File

@ -201,7 +201,7 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str)
return 0; return 0;
} }
void static void
getfriendlyname(char * buf, int len) getfriendlyname(char * buf, int len)
{ {
char * dot = NULL; char * dot = NULL;
@ -296,7 +296,7 @@ getfriendlyname(char * buf, int len)
#endif #endif
} }
int static int
open_db(void) open_db(void)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
@ -816,7 +816,8 @@ main(int argc, char * * argv)
struct upnphttp * next; struct upnphttp * next;
fd_set readset; /* for select() */ fd_set readset; /* for select() */
fd_set writeset; fd_set writeset;
struct timeval timeout, timeofday, lastnotifytime = {0, 0}, lastupdatetime = {0, 0}; struct timeval timeout, timeofday, lastnotifytime = {0, 0};
time_t lastupdatetime = 0;
int max_fd = -1; int max_fd = -1;
int last_changecnt = 0; int last_changecnt = 0;
short int new_db = 0; short int new_db = 0;
@ -1038,7 +1039,10 @@ main(int argc, char * * argv)
if( scanning ) if( scanning )
{ {
if( !scanner_pid || kill(scanner_pid, 0) ) if( !scanner_pid || kill(scanner_pid, 0) )
{
scanning = 0; scanning = 0;
updateID++;
}
} }
/* select open sockets (SSDP, HTTP listen, and all HTTP soap sockets) */ /* select open sockets (SSDP, HTTP listen, and all HTTP soap sockets) */
@ -1104,14 +1108,14 @@ main(int argc, char * * argv)
#endif #endif
/* increment SystemUpdateID if the content database has changed, /* increment SystemUpdateID if the content database has changed,
* and if there is an active HTTP connection, at most once every 2 seconds */ * and if there is an active HTTP connection, at most once every 2 seconds */
if( i && (time(NULL) >= (lastupdatetime.tv_sec + 2)) ) if( i && (timeofday.tv_sec >= (lastupdatetime + 2)) )
{ {
if( sqlite3_total_changes(db) != last_changecnt ) if( scanning || sqlite3_total_changes(db) != last_changecnt )
{ {
updateID++; updateID++;
last_changecnt = sqlite3_total_changes(db); last_changecnt = sqlite3_total_changes(db);
upnp_event_var_change_notify(EContentDirectory); upnp_event_var_change_notify(EContentDirectory);
memcpy(&lastupdatetime, &timeofday, sizeof(struct timeval)); lastupdatetime = timeofday.tv_sec;
} }
} }
/* process active HTTP connections */ /* process active HTTP connections */