git.samba.org
/
tridge
/
hacksm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
107fac1
)
allow fork per message
author
Andrew Tridgell
<tridge@samba.org>
Sun, 17 Aug 2008 23:43:38 +0000
(09:43 +1000)
committer
Andrew Tridgell
<tridge@samba.org>
Sun, 17 Aug 2008 23:43:38 +0000
(09:43 +1000)
hacksmd.c
patch
|
blob
|
history
diff --git
a/hacksmd.c
b/hacksmd.c
index c9b6db8727f651e4c198594ecd54decc70b4d182..442d9e787840b4c5386bbf2a9957e1d276c08049 100644
(file)
--- a/
hacksmd.c
+++ b/
hacksmd.c
@@
-10,9
+10,11
@@
static struct {
bool blocking_wait;
unsigned debug;
static struct {
bool blocking_wait;
unsigned debug;
+ bool use_fork;
} options = {
.blocking_wait = true,
.debug = 2,
} options = {
.blocking_wait = true,
.debug = 2,
+ .use_fork = false,
};
static struct {
};
static struct {
@@
-455,7
+457,16
@@
static void hsm_wait_events(void)
for (msg=(dm_eventmsg_t *)buf;
msg;
msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *)) {
for (msg=(dm_eventmsg_t *)buf;
msg;
msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *)) {
- hsm_handle_message(msg);
+ /* optionally fork on each message, thus
+ giving parallelism and allowing us to delay
+ recalls, simulating slow tape speeds */
+ if (options.use_fork) {
+ if (fork() != 0) continue;
+ hsm_handle_message(msg);
+ _exit(0);
+ } else {
+ hsm_handle_message(msg);
+ }
}
}
}
}
}
}
@@
-522,6
+533,7
@@
static void usage(void)
printf("\t\t -c cleanup lost tokens\n");
printf("\t\t -N use a non-blocking event wait\n");
printf("\t\t -d level choose debug level\n");
printf("\t\t -c cleanup lost tokens\n");
printf("\t\t -N use a non-blocking event wait\n");
printf("\t\t -d level choose debug level\n");
+ printf("\t\t -F fork to handle each event\n");
exit(0);
}
exit(0);
}
@@
-532,7
+544,7
@@
int main(int argc, char * const argv[])
bool cleanup = false;
/* parse command-line options */
bool cleanup = false;
/* parse command-line options */
- while ((opt = getopt(argc, argv, "chNd:")) != -1) {
+ while ((opt = getopt(argc, argv, "chNd:
F
")) != -1) {
switch (opt) {
case 'c':
cleanup = true;
switch (opt) {
case 'c':
cleanup = true;
@@
-543,6
+555,9
@@
int main(int argc, char * const argv[])
case 'N':
options.blocking_wait = false;
break;
case 'N':
options.blocking_wait = false;
break;
+ case 'F':
+ options.use_fork = true;
+ break;
case 'h':
default:
usage();
case 'h':
default:
usage();