Skip to content

Commit 2d1e8cf

Browse files
committed
drivers/dummy-ups.c: fix upsdrv_tweak_prognames() to only set upscli procname/proctag with duplicates if cookies differ [#3378, #3379]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 11ecd94 commit 2d1e8cf

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/dummy-ups.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,21 @@ void upsdrv_help(void)
426426
/* optionally tweak prognames[] entries */
427427
void upsdrv_tweak_prognames(void)
428428
{
429+
void *cookie = nut_common_cookie();
430+
429431
/* Here we actually tweak libupsclient logging more,
430432
* relying on this method being called early in main.c */
431-
upscli_upslog_start_sync(upslog_start_sync(NULL), nut_common_cookie());
432-
upscli_upslog_set_debug_level(nut_debug_level, nut_common_cookie());
433-
upscli_upslog_setprocname(xstrdup(getmyprocname()), nut_common_cookie());
433+
upscli_upslog_start_sync(upslog_start_sync(NULL), cookie);
434+
upscli_upslog_set_debug_level(nut_debug_level, cookie);
435+
434436
/* FIXME: All other calls to setproctag() in main.c would currently
435437
* be invisible to upscli_*() as that object file has no idea about
436438
* the library in this one driver... should we introduce a callback? */
437-
upscli_upslog_setproctag(xstrdup(getproctag()), nut_common_cookie());
439+
if (cookie != upscli_upslog_cookie()) {
440+
/* Send over a copy */
441+
upscli_upslog_setprocname(xstrdup(getmyprocname()), cookie);
442+
upscli_upslog_setproctag(xstrdup(getproctag()), cookie);
443+
}
438444
}
439445

440446
void upsdrv_makevartable(void)

0 commit comments

Comments
 (0)