This flag was set to TRUE when a recurring action got cancelled. However, immediately after it's set the object gets freed. It's unsafe to rely on this flag for anything, so remove it to avoid letting anyone get misled.
Signed-off-by: Russell Bryant russell@russellbryant.net --- src/lib/services.c | 1 - src/lib/services_linux.c | 2 +- src/lib/services_private.h | 1 - 3 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/src/lib/services.c b/src/lib/services.c index 44d7f4d..f199ed5 100644 --- a/src/lib/services.c +++ b/src/lib/services.c @@ -126,7 +126,6 @@ services_action_cancel(const char *name, const char *action, int interval) return FALSE; }
- op->opaque->cancel = TRUE; mh_debug("Removing %s", op->id); if (op->opaque->repeat_timer) { g_source_remove(op->opaque->repeat_timer); diff --git a/src/lib/services_linux.c b/src/lib/services_linux.c index 632d881..82e307f 100644 --- a/src/lib/services_linux.c +++ b/src/lib/services_linux.c @@ -234,7 +234,7 @@ operation_finished(mainloop_child_t *p, int status, int signo, int exitcode) } }
- if (op->interval && op->opaque->cancel == FALSE) { + if (op->interval) { recurring = 1; op->opaque->repeat_timer = g_timeout_add(op->interval, recurring_action_timer, diff --git a/src/lib/services_private.h b/src/lib/services_private.h index c413528..5a147ef 100644 --- a/src/lib/services_private.h +++ b/src/lib/services_private.h @@ -2,7 +2,6 @@ struct svc_action_private_s { char *exec; char *args[4]; - gboolean cancel;
guint repeat_timer; void (*callback)(svc_action_t *op);
Move the doxygen comment block for this API call to the header file. Documentation for other public API calls are in the header files. This is a handy place to put the docs as the documentation will be in the header files that get installed.
Signed-off-by: Russell Bryant russell@russellbryant.net --- src/include/matahari/dnssrv.h | 12 +++++++++++- src/lib/dnssrv_linux.c | 10 ---------- 2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/include/matahari/dnssrv.h b/src/include/matahari/dnssrv.h index 0ce0acb..55a66b3 100644 --- a/src/include/matahari/dnssrv.h +++ b/src/include/matahari/dnssrv.h @@ -27,6 +27,16 @@
#include <sys/types.h>
-extern int mh_srv_lookup(const char *query, char *target, size_t len); +/** + * Domain lookup providing a Matahari broker + * + * \param[in] srv record query i.e. "_matahari._tcp.matahariproject.org + * \param[in] set buffer to hold domain retrieved + * \param[in] set buffer length + * + * \return 0 or greater for successful match + */ +extern int +mh_srv_lookup(const char *query, char *target, size_t len);
#endif /* __MH_DNSSRV_H__ */ diff --git a/src/lib/dnssrv_linux.c b/src/lib/dnssrv_linux.c index 90be3f3..cd5d101 100644 --- a/src/lib/dnssrv_linux.c +++ b/src/lib/dnssrv_linux.c @@ -28,16 +28,6 @@
#include "matahari/dnssrv.h"
-/** - * Domain lookup providing a Matahari broker - * - * \param[in] srv record query i.e. "_matahari._tcp.matahariproject.org - * \param[in] set buffer to hold domain retrieved - * \param[in] set buffer length - * - * \return 0 or greater for successful match - */ - int mh_srv_lookup(const char *query, char *target, size_t len) {
ack
On Tue, Jun 21, 2011 at 3:47 AM, Russell Bryant russell@russellbryant.net wrote:
Move the doxygen comment block for this API call to the header file. Documentation for other public API calls are in the header files. This is a handy place to put the docs as the documentation will be in the header files that get installed.
Signed-off-by: Russell Bryant russell@russellbryant.net
src/include/matahari/dnssrv.h | 12 +++++++++++- src/lib/dnssrv_linux.c | 10 ---------- 2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/include/matahari/dnssrv.h b/src/include/matahari/dnssrv.h index 0ce0acb..55a66b3 100644 --- a/src/include/matahari/dnssrv.h +++ b/src/include/matahari/dnssrv.h @@ -27,6 +27,16 @@
#include <sys/types.h>
-extern int mh_srv_lookup(const char *query, char *target, size_t len); +/**
- Domain lookup providing a Matahari broker
- \param[in] srv record query i.e. "_matahari._tcp.matahariproject.org
- \param[in] set buffer to hold domain retrieved
- \param[in] set buffer length
- \return 0 or greater for successful match
- */
+extern int +mh_srv_lookup(const char *query, char *target, size_t len);
#endif /* __MH_DNSSRV_H__ */ diff --git a/src/lib/dnssrv_linux.c b/src/lib/dnssrv_linux.c index 90be3f3..cd5d101 100644 --- a/src/lib/dnssrv_linux.c +++ b/src/lib/dnssrv_linux.c @@ -28,16 +28,6 @@
#include "matahari/dnssrv.h"
-/**
- Domain lookup providing a Matahari broker
- \param[in] srv record query i.e. "_matahari._tcp.matahariproject.org
- \param[in] set buffer to hold domain retrieved
- \param[in] set buffer length
- \return 0 or greater for successful match
- */
int mh_srv_lookup(const char *query, char *target, size_t len) { -- 1.7.5.4
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
This patch fixes a memory leak in the handling of custom agent options on Windows. The output buffer passed back from RegistryRead() was not being freed.
Signed-off-by: Russell Bryant russell@russellbryant.net --- src/lib/mh_agent.cpp | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp index 8baa433..0c6efd1 100644 --- a/src/lib/mh_agent.cpp +++ b/src/lib/mh_agent.cpp @@ -241,6 +241,8 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari matahari_options[lpc].callback( matahari_options[lpc].code, matahari_options[lpc].long_name, value, matahari_options[lpc].userdata); + free(value); + value = NULL; } free(name_ws); }
Ack
On Tue, Jun 21, 2011 at 3:47 AM, Russell Bryant russell@russellbryant.net wrote:
This patch fixes a memory leak in the handling of custom agent options on Windows. The output buffer passed back from RegistryRead() was not being freed.
Signed-off-by: Russell Bryant russell@russellbryant.net
src/lib/mh_agent.cpp | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp index 8baa433..0c6efd1 100644 --- a/src/lib/mh_agent.cpp +++ b/src/lib/mh_agent.cpp @@ -241,6 +241,8 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari matahari_options[lpc].callback( matahari_options[lpc].code, matahari_options[lpc].long_name, value, matahari_options[lpc].userdata);
- free(value);
- value = NULL;
} free(name_ws); } -- 1.7.5.4
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
This patch converts a number of places that were using the MAX_CHAR define to using DIMOF(matahari_options). The result is the exact same but makes the code a bit more explicit. It also makes the code slightly less error prone since none of these places will be subject to an error being introduced if the array length was changed.
Signed-off-by: Russell Bryant russell@russellbryant.net --- src/lib/mh_agent.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp index 0c6efd1..d3183d7 100644 --- a/src/lib/mh_agent.cpp +++ b/src/lib/mh_agent.cpp @@ -172,7 +172,7 @@ int print_help(int code, const char *name, const char *arg, void *userdata) #endif
printf("\nCustom options:\n"); - for(lpc = 0; lpc < MAX_CHAR; lpc++) { + for(lpc = 0; lpc < DIMOF(matahari_options); lpc++) { if(matahari_options[lpc].callback && matahari_options[lpc].callback != connection_option) { printf("\t-%c | --%s\t %s\n", matahari_options[lpc].code, @@ -232,7 +232,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari value = NULL; }
- for (lpc = 0; lpc < MAX_CHAR; lpc++) { + for (lpc = 0; lpc < DIMOF(matahari_options); lpc++) { if (matahari_options[lpc].callback) { wchar_t *name_ws = char2wide(matahari_options[lpc].long_name); if (RegistryRead (HKEY_LOCAL_MACHINE, @@ -252,7 +252,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari int idx = 0; int num_options = 0; int opt_string_len = 0; - char opt_string[2*MAX_CHAR]; + char opt_string[2 * DIMOF(matahari_options)]; struct option *long_opts = (struct option *)calloc(1, sizeof(struct option));
/* Force more local-only processing */ @@ -260,7 +260,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari mh_add_option('v', no_argument, "verbose", NULL, NULL, NULL);
opt_string[0] = 0; - for(lpc = 0; lpc < MAX_CHAR; lpc++) { + for(lpc = 0; lpc < DIMOF(matahari_options); lpc++) { if(matahari_options[lpc].code) { long_opts = (struct option *)realloc(long_opts, (2 + num_options) * sizeof(struct option)); long_opts[num_options].name = matahari_options[lpc].long_name; @@ -319,7 +319,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari } break; default: - if(arg > 0 && arg < MAX_CHAR && matahari_options[arg].callback) { + if(arg > 0 && arg < DIMOF(matahari_options) && matahari_options[arg].callback) { matahari_options[arg].callback( matahari_options[arg].code, matahari_options[arg].long_name, optarg, matahari_options[arg].userdata); @@ -383,7 +383,7 @@ int mh_add_option(int code, int has_arg, const char *name, const char *description, void *userdata, int(*callback)(int code, const char *name, const char *arg, void *userdata)) { - if(code > 0 && code < MAX_CHAR) { + if(code > 0 && code < DIMOF(matahari_options)) { if(matahari_options[code].code != 0) { mh_err("Replacing '-%c|--%s' with '-%c|--%s'", matahari_options[code].code, matahari_options[code].long_name, code, name);
Sounds plausible :-) ack
On Tue, Jun 21, 2011 at 3:47 AM, Russell Bryant russell@russellbryant.net wrote:
This patch converts a number of places that were using the MAX_CHAR define to using DIMOF(matahari_options). The result is the exact same but makes the code a bit more explicit. It also makes the code slightly less error prone since none of these places will be subject to an error being introduced if the array length was changed.
Signed-off-by: Russell Bryant russell@russellbryant.net
src/lib/mh_agent.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp index 0c6efd1..d3183d7 100644 --- a/src/lib/mh_agent.cpp +++ b/src/lib/mh_agent.cpp @@ -172,7 +172,7 @@ int print_help(int code, const char *name, const char *arg, void *userdata) #endif
printf("\nCustom options:\n");
- for(lpc = 0; lpc < MAX_CHAR; lpc++) {
- for(lpc = 0; lpc < DIMOF(matahari_options); lpc++) {
if(matahari_options[lpc].callback && matahari_options[lpc].callback != connection_option) { printf("\t-%c | --%s\t %s\n", matahari_options[lpc].code, @@ -232,7 +232,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari value = NULL; }
- for (lpc = 0; lpc < MAX_CHAR; lpc++) {
- for (lpc = 0; lpc < DIMOF(matahari_options); lpc++) {
if (matahari_options[lpc].callback) { wchar_t *name_ws = char2wide(matahari_options[lpc].long_name); if (RegistryRead (HKEY_LOCAL_MACHINE, @@ -252,7 +252,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari int idx = 0; int num_options = 0; int opt_string_len = 0;
- char opt_string[2*MAX_CHAR];
- char opt_string[2 * DIMOF(matahari_options)];
struct option *long_opts = (struct option *)calloc(1, sizeof(struct option));
/* Force more local-only processing */ @@ -260,7 +260,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari mh_add_option('v', no_argument, "verbose", NULL, NULL, NULL);
opt_string[0] = 0;
- for(lpc = 0; lpc < MAX_CHAR; lpc++) {
- for(lpc = 0; lpc < DIMOF(matahari_options); lpc++) {
if(matahari_options[lpc].code) { long_opts = (struct option *)realloc(long_opts, (2 + num_options) * sizeof(struct option)); long_opts[num_options].name = matahari_options[lpc].long_name; @@ -319,7 +319,7 @@ mh_parse_options(const char *proc_name, int argc, char **argv, qpid::types::Vari } break; default:
- if(arg > 0 && arg < MAX_CHAR && matahari_options[arg].callback) {
- if(arg > 0 && arg < DIMOF(matahari_options) && matahari_options[arg].callback) {
matahari_options[arg].callback( matahari_options[arg].code, matahari_options[arg].long_name, optarg, matahari_options[arg].userdata); @@ -383,7 +383,7 @@ int mh_add_option(int code, int has_arg, const char *name, const char *description, void *userdata, int(*callback)(int code, const char *name, const char *arg, void *userdata)) {
- if(code > 0 && code < MAX_CHAR) {
- if(code > 0 && code < DIMOF(matahari_options)) {
if(matahari_options[code].code != 0) { mh_err("Replacing '-%c|--%s' with '-%c|--%s'", matahari_options[code].code, matahari_options[code].long_name, code, name); -- 1.7.5.4
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
ack. inherited from the lrmd but not relevant now.
On Tue, Jun 21, 2011 at 3:47 AM, Russell Bryant russell@russellbryant.net wrote:
This flag was set to TRUE when a recurring action got cancelled. However, immediately after it's set the object gets freed. It's unsafe to rely on this flag for anything, so remove it to avoid letting anyone get misled.
Signed-off-by: Russell Bryant russell@russellbryant.net
src/lib/services.c | 1 - src/lib/services_linux.c | 2 +- src/lib/services_private.h | 1 - 3 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/src/lib/services.c b/src/lib/services.c index 44d7f4d..f199ed5 100644 --- a/src/lib/services.c +++ b/src/lib/services.c @@ -126,7 +126,6 @@ services_action_cancel(const char *name, const char *action, int interval) return FALSE; }
- op->opaque->cancel = TRUE;
mh_debug("Removing %s", op->id); if (op->opaque->repeat_timer) { g_source_remove(op->opaque->repeat_timer); diff --git a/src/lib/services_linux.c b/src/lib/services_linux.c index 632d881..82e307f 100644 --- a/src/lib/services_linux.c +++ b/src/lib/services_linux.c @@ -234,7 +234,7 @@ operation_finished(mainloop_child_t *p, int status, int signo, int exitcode) } }
- if (op->interval && op->opaque->cancel == FALSE) {
- if (op->interval) {
recurring = 1; op->opaque->repeat_timer = g_timeout_add(op->interval, recurring_action_timer, diff --git a/src/lib/services_private.h b/src/lib/services_private.h index c413528..5a147ef 100644 --- a/src/lib/services_private.h +++ b/src/lib/services_private.h @@ -2,7 +2,6 @@ struct svc_action_private_s { char *exec; char *args[4];
- gboolean cancel;
guint repeat_timer; void (*callback)(svc_action_t *op); -- 1.7.5.4
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
matahari@lists.fedorahosted.org