[PATCH 3/5] base/workers: Fix detection of check basename for special workers
robin.sonefors at op5.com
robin.sonefors at op5.com
Mon Nov 5 14:58:31 CET 2012
From: Robin Sonefors <robin.sonefors at op5.com>
strrchr may search from the end of the string, but it still expects the
pointer it is provided to point to the beginning of the string. Thus, we'd
only check if the last byte was a slash, rather than for the last slash.
Manipulating the cmd_name for basename discovery is unnecessary, so
don't.
Signed-off-by: Robin Sonefors <robin.sonefors at op5.com>
---
base/workers.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/base/workers.c b/base/workers.c
index 0f33a8a..7042724 100644
--- a/base/workers.c
+++ b/base/workers.c
@@ -807,14 +807,12 @@ static worker_process *get_worker(worker_job *job)
cmd_name = job->command;
if ((space = strchr(cmd_name, ' ')) != NULL) {
*space = '\0';
- slash = strrchr(space - 1, '/');
+ slash = strrchr(cmd_name, '/');
}
wp_list = dkhash_get(specialized_workers, cmd_name, NULL);
if (!wp_list && slash) {
- *slash = 0;
- wp_list = dkhash_get(specialized_workers, slash + 1, NULL);
- *(slash++) = '/';
+ wp_list = dkhash_get(specialized_workers, ++slash, NULL);
}
if (wp_list != NULL) {
logit(NSLOG_INFO_MESSAGE, 1, "Found specialized worker(s) for '%s'", (slash && *slash != '/') ? slash : cmd_name);
--
1.7.11.7
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
More information about the Developers
mailing list