@@ -299,28 +299,28 @@ void checker_put (struct checker * dst)
free_checker_class(src);
}
-int checker_check (struct checker * c, int path_state)
+int checker_get_state(struct checker *c)
{
- int r;
+ return c ? c->path_state : PATH_UNCHECKED;
+}
+void checker_check (struct checker * c, int path_state)
+{
if (!c)
- return PATH_WILD;
+ return;
c->msgid = CHECKER_MSGID_NONE;
if (c->disable) {
c->msgid = CHECKER_MSGID_DISABLED;
- return PATH_UNCHECKED;
- }
- if (!strncmp(c->cls->name, NONE, 4))
- return path_state;
-
- if (c->fd < 0) {
+ c->path_state = PATH_UNCHECKED;
+ } else if (!strncmp(c->cls->name, NONE, 4)) {
+ c->path_state = path_state;
+ } else if (c->fd < 0) {
c->msgid = CHECKER_MSGID_NO_FD;
- return PATH_WILD;
+ c->path_state = PATH_WILD;
+ } else {
+ c->path_state = c->cls->check(c);
}
- r = c->cls->check(c);
-
- return r;
}
const char *checker_name(const struct checker *c)
@@ -123,6 +123,7 @@ struct checker {
int fd;
unsigned int timeout;
int disable;
+ int path_state;
short msgid; /* checker-internal extra status */
void * context; /* store for persistent data */
void ** mpcontext; /* store for persistent data shared
@@ -169,7 +170,8 @@ struct checker_context {
};
int start_checker_thread (pthread_t *thread, const pthread_attr_t *attr,
struct checker_context *ctx);
-int checker_check (struct checker *, int);
+int checker_get_state(struct checker *c);
+void checker_check (struct checker *, int);
int checker_is_sync(const struct checker *);
const char *checker_name (const struct checker *);
void reset_checker_classes(void);
@@ -2007,7 +2007,8 @@ get_state (struct path * pp, struct config *conf, int daemon, int oldstate)
checker_set_async(c);
else
checker_set_sync(c);
- state = checker_check(c, oldstate);
+ checker_check(c, oldstate);
+ state = checker_get_state(c);
condlog(3, "%s: %s state = %s", pp->dev,
checker_name(c), checker_state_name(state));
if (state != PATH_UP && state != PATH_GHOST &&
@@ -700,6 +700,7 @@ out:
condlog(3, "%s: path_checker = %s %s", pp->dev,
checker_name(c), origin);
c->timeout = pp->checker_timeout;
+ c->path_state = PATH_UNCHECKED;
return 0;
}