process: associate open connections with clients

This commit is contained in:
Justin Maggard
2014-06-09 18:48:49 -07:00
parent e9a653d6e8
commit a46a8e5e89
5 changed files with 102 additions and 16 deletions

View File

@ -372,7 +372,7 @@ rescan:
#if USE_FORK
scanning = 1;
sqlite3_close(db);
*scanner_pid = process_fork();
*scanner_pid = fork();
open_db(&db);
if (*scanner_pid == 0) /* child (scanner) process */
{
@ -969,6 +969,13 @@ init(int argc, char **argv)
DPRINTF(E_FATAL, L_GENERAL, "Failed to switch to uid '%d'. [%s] EXITING.\n",
uid, strerror(errno));
children = calloc(runtime_vars.max_connections, sizeof(struct child));
if (!children)
{
DPRINTF(E_ERROR, L_GENERAL, "Allocation failed\n");
return 1;
}
return 0;
}
@ -1285,7 +1292,10 @@ main(int argc, char **argv)
shutdown:
/* kill the scanner */
if (scanning && scanner_pid)
kill(scanner_pid, 9);
kill(scanner_pid, SIGKILL);
/* kill other child processes */
process_reap_children();
/* close out open sockets */
while (upnphttphead.lh_first != NULL)