diff options
Diffstat (limited to 'src/job.c')
-rw-r--r-- | src/job.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -22,24 +22,25 @@ | |||
22 | #define STATE_ACTIVE 0x04 | 22 | #define STATE_ACTIVE 0x04 |
23 | 23 | ||
24 | struct job | 24 | struct job |
25 | { | 25 | { |
26 | struct job *next, *prev; | 26 | struct job *next, *prev; |
27 | int state; | 27 | int state; |
28 | const struct spool *spool; | 28 | struct spool *spool; |
29 | uid_t uid; | 29 | uid_t uid; |
30 | pid_t pid; | 30 | pid_t pid; |
31 | time_t timestamp; | 31 | time_t timestamp; |
32 | int exit_status; | 32 | int exit_status; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | struct job *queue; | 35 | struct job *queue; |
36 | size_t jobmax; | 36 | size_t jobmax; |
37 | size_t jobcnt; | 37 | size_t jobcnt; |
38 | 38 | ||
39 | static struct spool fake_spool = { "all spools" }; | 39 | struct spool fake_spool = { "all spools" }, |
40 | inotify_spool = { "inotify" } ; | ||
40 | 41 | ||
41 | static int wakeup; | 42 | static int wakeup; |
42 | 43 | ||
43 | RETSIGTYPE | 44 | RETSIGTYPE |
44 | queue_signal (int sig) | 45 | queue_signal (int sig) |
45 | { | 46 | { |
@@ -73,19 +74,28 @@ job_active_count () | |||
73 | for (job = queue; job; job = job->next) | 74 | for (job = queue; job; job = job->next) |
74 | if (job->state & STATE_ACTIVE) | 75 | if (job->state & STATE_ACTIVE) |
75 | count++; | 76 | count++; |
76 | return count; | 77 | return count; |
77 | } | 78 | } |
78 | 79 | ||
80 | static int | ||
81 | procspool (struct spool *spool, void *data) | ||
82 | { | ||
83 | spool_commit_triplets (spool); | ||
84 | return 0; | ||
85 | } | ||
86 | |||
79 | int | 87 | int |
80 | wydawca_scanner (struct job *job) | 88 | wydawca_scanner (struct job *job) |
81 | { | 89 | { |
82 | int rc; | 90 | int rc; |
83 | initstats(); | 91 | initstats(); |
84 | timer_start ("wydawca"); | 92 | timer_start ("wydawca"); |
85 | if (job->spool == &fake_spool) | 93 | if (job->spool == &inotify_spool) |
94 | rc = for_each_spool (procspool, NULL); | ||
95 | else if (job->spool == &fake_spool) | ||
86 | rc = scan_all_spools (1, &job->uid); | 96 | rc = scan_all_spools (1, &job->uid); |
87 | else | 97 | else |
88 | { | 98 | { |
89 | spool_create_timers (); | 99 | spool_create_timers (); |
90 | rc = scan_spool (job->spool, 1, &job->uid); | 100 | rc = scan_spool (job->spool, 1, &job->uid); |
91 | } | 101 | } |
@@ -188,13 +198,13 @@ job_insert (struct job *job, struct job *elt) | |||
188 | 198 | ||
189 | if (p) | 199 | if (p) |
190 | p->prev = job; | 200 | p->prev = job; |
191 | } | 201 | } |
192 | 202 | ||
193 | void | 203 | void |
194 | schedule_job (const struct spool *spool, uid_t uid) | 204 | schedule_job (struct spool *spool, uid_t uid) |
195 | { | 205 | { |
196 | struct job *job; | 206 | struct job *job; |
197 | 207 | ||
198 | if (!spool) | 208 | if (!spool) |
199 | spool = &fake_spool; | 209 | spool = &fake_spool; |
200 | 210 | ||