From d54da54d67da51f8b4af6a9d0703755b681114d3 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Fri, 29 Apr 2005 14:56:35 +0000 Subject: [PATCH] o checking in instrumented code for AJ to follow up on comms and logging o changed int dm_get_next_registered_device(char **dso_name, char **device, enum event_type *events); to int dm_get_registered_device(char **dso_name, char **device, enum event_type *events, int next) so that the daemon is able to retrive the next one of the list without running into locking issues. o changed dmevent.c to use dm_get_registered_device() o couldn't test this yet because of the comms issues (daemon exits in do_process_request()) --- daemons/dmeventd/dmevent.c | 5 ++++- daemons/dmeventd/dmeventd.c | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/daemons/dmeventd/dmevent.c b/daemons/dmeventd/dmevent.c index c53bb9fb9..559000aa8 100644 --- a/daemons/dmeventd/dmevent.c +++ b/daemons/dmeventd/dmevent.c @@ -95,13 +95,16 @@ static int parse_argv(int argc, char **argv, int main(int argc, char **argv) { int list = 0, next = 0, ret, reg = default_reg; - char *device, *device_arg, *dso_name = default_dso_name, *dso_name_arg; + char *device = NULL, *device_arg = NULL, + *dso_name = default_dso_name, *dso_name_arg = NULL; if (!parse_argv(argc, argv, &dso_name_arg, &device_arg, ®, &list)) exit(EXIT_FAILURE); if (dso_name_arg) dso_name = dso_name_arg; + else + dso_name_arg = dso_name; if (device_arg) device = device_arg; diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index 8db51385f..79447037a 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -183,18 +183,16 @@ static void free_dso_data(struct dso_data *data) static const char delimiter = ' '; static char *fetch_string(char **src) { - char *p, *ret = NULL; + char *p, *ret; - if ((p = strchr(*src, delimiter))) { + if ((p = strchr(*src, delimiter))) *p = 0; - if ((ret = dbg_strdup(*src))) - *src += strlen(ret) + 1; + if ((ret = strdup(*src))) + *src += strlen(ret) + 1; - if (p) - *p = delimiter; - } else if (*src) - ret = dbg_strdup(*src); + if (p) + *p = delimiter; return ret; } @@ -214,6 +212,8 @@ static int parse_message(struct message_data *message_data) { char *p = message_data->msg->msg; +log_print("%s: here\n", __func__); +fflush(stdout); memset(message_data, 0, sizeof(*message_data)); /* @@ -223,6 +223,7 @@ static int parse_message(struct message_data *message_data) if ((message_data->dso_name = fetch_string(&p)) && (message_data->device_path = fetch_string(&p)) && (message_data->events.str = fetch_string(&p))) { +log_print("%s: %s %s %s\n", __func__, message_data->dso_name, message_data->device_path, message_data->events.str); if (message_data->events.str) { enum event_type i = atoi(message_data->events.str); @@ -622,6 +623,8 @@ static int register_for_event(struct message_data *message_data) ret = -ENODEV; goto out; } +log_print("%s\n", __func__); +fflush(stdout); if (!(dso_data = lookup_dso(message_data)) && !(dso_data = load_dso(message_data))) { @@ -887,10 +890,12 @@ log_print("%s: \"%s\"\n", __func__, msg->msg); if (msg->opcode.cmd != CMD_ACTIVE && !parse_message(&message_data)) { stack; +fflush(stdout); return -EINVAL; - } + } -log_print("%s: \"%s\"\n", __func__, message_data.msg->msg); +log_print("%s (2nd): \"%s\"\n", __func__, message_data.msg->msg); +fflush(stdout); /* Check the request type. */ switch (msg->opcode.cmd) {