aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-04-02 14:44:24 +0300
committerSergey Poznyakoff <gray@gnu.org>2021-04-02 14:45:52 +0300
commit99b1750fa71707d77b3ef41cf880766c46013637 (patch)
tree0537534715b17020c051a9b1f0a9d4fed17c1e47
parent0d8697ef746f29b10cc5cd457db428ec676e42f4 (diff)
downloadmicron-99b1750fa71707d77b3ef41cf880766c46013637.tar.gz
micron-99b1750fa71707d77b3ef41cf880766c46013637.tar.bz2
Free structures allocated for deleted cronjobs
* src/micrond.c (crontab_deleted): Call crontab_forget. * src/micrond.h (cronjob) <fileid>: Change type to unsigned.
-rw-r--r--src/micrond.c16
-rw-r--r--src/micrond.h2
2 files changed, 10 insertions, 8 deletions
diff --git a/src/micrond.c b/src/micrond.c
index f400f43..0d0e1e2 100644
--- a/src/micrond.c
+++ b/src/micrond.c
@@ -1006,7 +1006,7 @@ static pthread_mutex_t cronjob_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t cronjob_cond = PTHREAD_COND_INITIALIZER;
static void
-cronjob_head_remove(int fileid)
+cronjob_head_remove(unsigned fileid)
{
struct cronjob *cp, *prev;
LIST_FOREACH_SAFE(cp, prev, &cronjob_head, list) {
@@ -1066,7 +1066,7 @@ find_percent(char *p)
static struct cronjob *
cronjob_alloc(struct cronjob_options const *opt,
- int fileid, int type,
+ unsigned fileid, int type,
struct micronexp const *schedule,
struct passwd const *pwd,
char const *command, struct micron_environ *env)
@@ -1184,7 +1184,7 @@ cronjob_arm(struct cronjob *job, int apply_now)
}
struct crontab {
- int fileid;
+ unsigned fileid;
struct crongroup *crongroup;
char *filename;
struct list_head list;
@@ -1193,7 +1193,7 @@ struct crontab {
};
static struct list_head crontabs = LIST_HEAD_INITIALIZER(crontabs);
-static int next_fileid;
+static unsigned next_fileid;
static struct crontab *
crontab_find(struct crongroup *cgrp, char const *filename, int alloc)
@@ -2617,10 +2617,12 @@ crongroup_forget_crontabs(struct crongroup *cgrp)
void
crontab_deleted(struct crongroup *cgrp, char const *name)
{
- struct crontab *cp = crontab_find(cgrp, name, 1);
+ struct crontab *cp;
pthread_mutex_lock(&cronjob_mutex);
- cronjob_head_remove(cp->fileid);
- pthread_cond_broadcast(&cronjob_cond);
+ if ((cp = crontab_find(cgrp, name, 0)) != NULL) {
+ crontab_forget(cp);
+ pthread_cond_broadcast(&cronjob_cond);
+ }
pthread_mutex_unlock(&cronjob_mutex);
}
diff --git a/src/micrond.h b/src/micrond.h
index 5d42311..46ffb8d 100644
--- a/src/micrond.h
+++ b/src/micrond.h
@@ -52,7 +52,7 @@ struct cronjob {
struct list_head list; /* Links to the next and prev crontab entries */
struct list_head runq; /* Links to the next and prev runqueue
entries */
- int fileid; /* Crontab identifier */
+ unsigned fileid; /* Crontab identifier */
int syslog_facility;
char *syslog_tag;
char *mailto;

Return to:

Send suggestions and report system problems to the System administrator.