void d_msg(const char *file, int line, int level, const char *fmt,...);
void p_msg(const char *file, int line, int level, const char *fmt,...);
void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
-void j_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
-void q_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
+void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
+void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
int32_t n;
char Job[MAX_NAME_LENGTH];
char MsgType[20];
- int type, level;
+ int type;
+ utime_t mtime; /* message time */
JCR *jcr = bs->jcr();
char *msg;
/*
* Here we are expecting a message of the following format:
* Jmsg Job=nnn type=nnn level=nnn Message-string
+ * Note, level should really be mtime, but that changes
+ * the protocol.
*/
if (bs->msg[0] == 'J') { /* Job message */
- if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%d",
- Job, &type, &level) != 3) {
+ if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%lld",
+ Job, &type, &mtime) != 3) {
Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
continue;
}
msg++; /* skip leading space */
}
Dmsg1(900, "Dispatch msg: %s", msg);
- dispatch_message(jcr, type, level, msg);
+ dispatch_message(jcr, type, mtime, msg);
continue;
}
/*
jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data,
jcr->write_part_after_job, jcr->job->PreferMountedVolumes,
edit_int64(jcr->spool_size, ed2));
- Dmsg1(100, ">stored: %s\n", sd->msg);
+ Dmsg1(100, ">stored: %s", sd->msg);
if (bget_dirmsg(sd) > 0) {
Dmsg1(100, "<stored: %s", sd->msg);
if (sscanf(sd->msg, OKjob, &jcr->VolSessionId,
/* ua_output.c */
void prtit(void *ctx, const char *msg);
bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool);
-RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays);
+RUN *find_next_run(RUN *run, JOB *job, utime_t &runtime, int ndays);
/* ua_restore.c */
int get_next_jobid_from_list(char **p, JobId_t *JobId);
JCR *jcr;
USTORE store;
RUN *run;
- time_t runtime;
+ utime_t runtime;
bool found = false;
MEDIA_DBR mr;
POOL_DBR pr;
* For a given job, we examine all his run records
* to see if it is scheduled today or tomorrow.
*/
-RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays)
+RUN *find_next_run(RUN *run, JOB *job, utime_t &runtime, int ndays)
{
time_t now, future, endtime;
SCHED *sched;
runtm.tm_min = run->minute;
runtm.tm_sec = 0;
runtime = mktime(&runtm);
- Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
+ Dmsg2(200, "now=%d runtime=%lld\n", now, runtime);
if ((runtime > now) && (runtime < endtime)) {
Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
return run; /* found it, return run resource */
JOB *job;
int level;
int priority;
- time_t runtime;
+ utime_t runtime;
POOL *pool;
STORE *store;
};
*/
static void list_scheduled_jobs(UAContext *ua)
{
- time_t runtime;
+ utime_t runtime;
RUN *run;
JOB *job;
int level, num_jobs = 0;
typedef struct PrivateCurFile {
hlink link;
char *fname;
- time_t ctime;
- time_t mtime;
+ utime_t ctime;
+ utime_t mtime;
bool seen;
} CurFile;
static bRC baculaSetValue(bpContext *ctx, bVariable var, void *value);
static bRC baculaRegisterEvents(bpContext *ctx, ...);
static bRC baculaJobMsg(bpContext *ctx, const char *file, int line,
- int type, time_t mtime, const char *fmt, ...);
+ int type, utime_t mtime, const char *fmt, ...);
static bRC baculaDebugMsg(bpContext *ctx, const char *file, int line,
int level, const char *fmt, ...);
static void *baculaMalloc(bpContext *ctx, const char *file, int line,
}
static bRC baculaJobMsg(bpContext *ctx, const char *file, int line,
- int type, time_t mtime, const char *fmt, ...)
+ int type, utime_t mtime, const char *fmt, ...)
{
va_list arg_ptr;
char buf[2000];
bRC (*getBaculaValue)(bpContext *ctx, bVariable var, void *value);
bRC (*setBaculaValue)(bpContext *ctx, bVariable var, void *value);
bRC (*JobMessage)(bpContext *ctx, const char *file, int line,
- int type, time_t mtime, const char *fmt, ...);
+ int type, utime_t mtime, const char *fmt, ...);
bRC (*DebugMessage)(bpContext *ctx, const char *file, int line,
int level, const char *fmt, ...);
void *(*baculaMalloc)(bpContext *ctx, const char *file, int line,
-/*
- * Define Host machine
- *
- * Version $Id$
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Define Host machine
+ *
+ * Version $Id$
+ *
+ */
#define HOST_OS "@host@@post_host@"
#define BACULA "@BACULA@"
#define DISTNAME "@DISTNAME@"
#define DISTVER "@DISTVER@"
-
POOLMEM *acl_text; /* text of ACL for backup */
int32_t last_type; /* type of last file saved/verified */
int incremental; /* set if incremental for SINCE */
- time_t mtime; /* begin time for SINCE */
+ utime_t mtime; /* begin time for SINCE */
int listing; /* job listing in estimate */
long Ticket; /* Ticket */
char *big_buf; /* I/O buffer */
uint32_t VolSessionTime;
uint32_t JobFiles;
uint64_t JobBytes;
- time_t start_time;
- time_t end_time;
+ utime_t start_time;
+ utime_t end_time;
char Job[MAX_NAME_LENGTH];
};
#include "jcr.h"
#include <netdb.h>
-extern time_t watchdog_time;
-
#ifndef INADDR_NONE
#define INADDR_NONE -1
#endif
-/*
- * Copyright Patrick Powell 1995
- *
- * This code is based on code written by Patrick Powell
- * (papowell@astart.com) It may be used for any purpose as long
- * as this notice remains intact on all source code distributions.
- *
- * Adapted for Bacula -- note there were lots of bugs in
- * the original code: %lld and %s were seriously broken, and
- * with FP turned off %f seg faulted.
- *
- * Kern Sibbald, November MMV
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Copyright Patrick Powell 1995
+ *
+ * This code is based on code written by Patrick Powell
+ * (papowell@astart.com) It may be used for any purpose as long
+ * as this notice remains intact on all source code distributions.
+ *
+ * Adapted for Bacula -- note there were lots of bugs in
+ * the original code: %lld and %s were seriously broken, and
+ * with FP turned off %f seg faulted.
+ *
+ * Kern Sibbald, November MMV
+ *
+ * Version $Id$
+ */
* to recall this routine if he/she REALLY wants to sleep the
* requested time.
*/
-int bmicrosleep(time_t sec, long usec)
+int bmicrosleep(int32_t sec, int32_t usec)
{
struct timespec timeout;
struct timeval tv;
timeout.tv_sec++;
}
- Dmsg2(200, "pthread_cond_timedwait sec=%d usec=%d\n", sec, usec);
+ Dmsg2(200, "pthread_cond_timedwait sec=%lld usec=%d\n", sec, usec);
/* Note, this unlocks mutex during the sleep */
P(timer_mutex);
stat = pthread_cond_timedwait(&timer, &timer_mutex, &timeout);
#include <math.h>
/* Formatted time for user display: dd-Mon-yyyy hh:mm */
-char *bstrftime(char *dt, int maxlen, utime_t tim)
+char *bstrftime(char *dt, int maxlen, utime_t utime)
{
- time_t ttime = (time_t)tim;
+ time_t time = (time_t)utime;
struct tm tm;
/* ***FIXME**** the format and localtime_r() should be user configurable */
- (void)localtime_r(&ttime, &tm);
+ (void)localtime_r(&time, &tm);
strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm);
return dt;
}
/* Formatted time for user display: dd-Mon-yyyy hh:mm:ss */
-char *bstrftimes(char *dt, int maxlen, utime_t tim)
+char *bstrftimes(char *dt, int maxlen, utime_t utime)
{
- time_t ttime = (time_t)tim;
+ time_t time = (time_t)utime;
struct tm tm;
/* ***FIXME**** the format and localtime_r() should be user configurable */
- (void)localtime_r(&ttime, &tm);
+ (void)localtime_r(&time, &tm);
strftime(dt, maxlen, "%d-%b-%Y %H:%M:%S", &tm);
return dt;
}
/* Formatted time for user display: dd-Mon hh:mm */
-char *bstrftime_ny(char *dt, int maxlen, utime_t tim)
+char *bstrftime_ny(char *dt, int maxlen, utime_t utime)
{
- time_t ttime = (time_t)tim;
+ time_t time = (time_t)utime;
struct tm tm;
/* ***FIXME**** the format and localtime_r() should be user configurable */
- (void)localtime_r(&ttime, &tm);
+ (void)localtime_r(&time, &tm);
strftime(dt, maxlen, "%d-%b %H:%M", &tm);
return dt;
}
/* Formatted time for user display: dd-Mon-yy hh:mm (no century) */
-char *bstrftime_nc(char *dt, int maxlen, utime_t tim)
+char *bstrftime_nc(char *dt, int maxlen, utime_t utime)
{
- time_t ttime = (time_t)tim;
+ time_t time = (time_t)utime;
struct tm tm;
char *p, *q;
/* ***FIXME**** the format and localtime_r() should be user configurable */
- (void)localtime_r(&ttime, &tm);
+ (void)localtime_r(&time, &tm);
/* NOTE! since the compiler complains about %y, I use %y and cut the century */
strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm);
/* overlay the century */
/* Unix time to standard time string yyyy-mm-dd hh:mm:ss */
-char *bstrutime(char *dt, int maxlen, utime_t tim)
+char *bstrutime(char *dt, int maxlen, utime_t utime)
{
- time_t ttime = (time_t)tim;
+ time_t time = (time_t)utime;
struct tm tm;
- (void)localtime_r(&ttime, &tm);
+ (void)localtime_r(&time, &tm);
strftime(dt, maxlen, "%Y-%m-%d %H:%M:%S", &tm);
return dt;
}
utime_t str_to_utime(char *str)
{
struct tm tm;
- time_t ttime;
+ time_t time;
/* Check for bad argument */
if (!str || *str == 0) {
}
tm.tm_wday = tm.tm_yday = 0;
tm.tm_isdst = -1;
- ttime = mktime(&tm);
- if (ttime == -1) {
- ttime = 0;
+ time = mktime(&tm);
+ if (time == -1) {
+ time = 0;
}
- return (utime_t)ttime;
+ return (utime_t)time;
}
int woy, fty, tm_yday;
time_t time4;
struct tm tm;
+
memset(&tm, 0, sizeof(struct tm));
(void)localtime_r(&stime, &tm);
tm_yday = tm.tm_yday;
const int dbglvl = 3400;
/* External variables we reference */
-extern time_t watchdog_time;
/* External referenced functions */
void free_bregexps(alist *bregexps);
}
}
}
-
int verbose = 0; /* increase User messages */
int debug_level = 0; /* debug level */
bool dbg_timestamp = false; /* print timestamp in debug output */
-time_t daemon_start_time = 0; /* Daemon start time */
+utime_t daemon_start_time = 0; /* Daemon start time */
const char *version = VERSION " (" BDATE ")";
char my_name[30]; /* daemon name is stored here */
char host_name[50]; /* host machine name */
/*
* Handle sending the message to the appropriate place
*/
-void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
+void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
{
DEST *d;
char dt[MAX_TIME_LENGTH];
* Most messages are prefixed by a date and time. If mtime is
* zero, then we use the current time. If mtime is 1 (special
* kludge), we do not prefix the date and time. Otherwise,
- * we assume mtime is a time_t and use it.
+ * we assume mtime is a utime_t and use it.
*/
if (mtime == 0) {
mtime = time(NULL);
case MD_DIRECTOR:
Dmsg1(850, "DIRECTOR for following msg: %s", msg);
if (jcr && jcr->dir_bsock && !jcr->dir_bsock->errors) {
- bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%d %s",
+ bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%lld %s",
jcr->Job, type, mtime, msg);
}
break;
int len;
va_list arg_ptr;
bool details = true;
- time_t mtime;
+ utime_t mtime;
if (level < 0) {
details = false;
*
*/
void
-Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
+Jmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...)
{
char rbuf[5000];
va_list arg_ptr;
* If we come here, prefix the message with the file:line-number,
* then pass it on to the normal Jmsg routine.
*/
-void j_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...)
+void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...)
{
va_list arg_ptr;
int i, len, maxlen;
* sending a message, it is a bit messy to recursively call
* yourself when the bnet packet is not reentrant).
*/
-void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
+void Qmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...)
{
va_list arg_ptr;
int len, maxlen;
* If we come here, prefix the message with the file:line-number,
* then pass it on to the normal Qmsg routine.
*/
-void q_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...)
+void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...)
{
va_list arg_ptr;
int i, len, maxlen;
struct MQUEUE_ITEM {
dlink link;
int type;
- time_t mtime;
+ utime_t mtime;
char msg[1];
};
void d_msg(const char *file, int line, int level, const char *fmt,...);
void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
-void Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
-void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
+void Jmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...);
+void Qmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...);
bool get_trace(void);
struct B_DB;
extern DLL_IMP_EXP int verbose;
extern DLL_IMP_EXP char my_name[];
extern DLL_IMP_EXP const char * working_directory;
-extern DLL_IMP_EXP time_t daemon_start_time;
+extern DLL_IMP_EXP utime_t daemon_start_time;
extern DLL_IMP_EXP int console_msg_pending;
extern DLL_IMP_EXP FILE * con_fd; /* Console file descriptor */
extern DLL_IMP_EXP brwlock_t con_lock; /* Console lock structure */
-
void create_pid_file (char *dir, const char *progname, int port);
int delete_pid_file (char *dir, const char *progname, int port);
void drop (char *uid, char *gid);
-int bmicrosleep (time_t sec, long usec);
+int bmicrosleep (int32_t sec, int32_t usec);
char *bfgets (char *s, int size, FILE *fd);
void make_unique_filename (POOLMEM **name, int Id, char *what);
#ifndef HAVE_STRTOLL
void close_msg (JCR *jcr);
void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code);
void rem_msg_dest (MSGS *msg, int dest, int type, char *where);
-void Jmsg (JCR *jcr, int type, time_t mtime, const char *fmt, ...);
-void dispatch_message (JCR *jcr, int type, time_t mtime, char *buf);
+void Jmsg (JCR *jcr, int type, utime_t mtime, const char *fmt, ...);
+void dispatch_message (JCR *jcr, int type, utime_t mtime, char *buf);
void init_console_msg (const char *wd);
void free_msgs_res (MSGS *msgs);
void dequeue_messages (JCR *jcr);
void bash_spaces (POOL_MEM &pm);
void unbash_spaces (char *str);
void unbash_spaces (POOL_MEM &pm);
-char * encode_time (time_t time, char *buf);
+char * encode_time (utime_t time, char *buf);
char * encode_mode (mode_t mode, char *buf);
int do_shell_expansion (char *name, int name_len);
void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2005-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
#include "bacula.h"
#include <assert.h>
-extern time_t watchdog_time;
#ifdef HAVE_TLS /* Is TLS enabled? */
}
}
-char *encode_time(time_t time, char *buf)
+char *encode_time(utime_t utime, char *buf)
{
struct tm tm;
int n = 0;
+ time_t time = utime;
#if defined(HAVE_WIN32)
/*
#include "jcr.h"
/* Exported globals */
-time_t watchdog_time = 0; /* this has granularity of SLEEP_TIME */
-time_t watchdog_sleep_time = 60; /* examine things every 60 seconds */
+utime_t watchdog_time = 0; /* this has granularity of SLEEP_TIME */
+utime_t watchdog_sleep_time = 60; /* examine things every 60 seconds */
/* Locals */
static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
struct timespec timeout;
struct timeval tv;
struct timezone tz;
- time_t next_time;
+ utime_t next_time;
Dmsg0(800, "NicB-reworked watchdog thread entered\n");
-/*
- * Watchdog timer routines
- *
- * Kern Sibbald, December MMII
- *
-*/
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Watchdog timer routines
+ *
+ * Kern Sibbald, December MMII
+ *
+*/
enum {
TYPE_CHILD = 1,
struct s_watchdog_t {
bool one_shot;
- time_t interval;
+ utime_t interval;
void (*callback)(struct s_watchdog_t *wd);
void (*destructor)(struct s_watchdog_t *wd);
void *data;
/* Private data below - don't touch outside of watchdog.c */
dlink link;
- time_t next_fire;
+ utime_t next_fire;
};
typedef struct s_watchdog_t watchdog_t;
/* Exported globals */
-extern time_t DLL_IMP_EXP watchdog_time; /* this has granularity of SLEEP_TIME */
-extern time_t DLL_IMP_EXP watchdog_sleep_time; /* examine things every 60 seconds */
+extern utime_t DLL_IMP_EXP watchdog_time; /* this has granularity of SLEEP_TIME */
+extern utime_t DLL_IMP_EXP watchdog_sleep_time; /* examine things every 60 seconds */
if (dev->VolHdr.VerNum >= 11) {
char dt[50];
- bstrftime(dt, sizeof(dt), btime_to_unix(dev->VolHdr.label_btime));
+ bstrftime(dt, sizeof(dt), btime_to_utime(dev->VolHdr.label_btime));
Pmsg1(-1, _("Date label written: %s\n"), dt);
} else {
- dt.julian_day_number = dev->VolHdr.label_date;
- dt.julian_day_fraction = dev->VolHdr.label_time;
- tm_decode(&dt, &tm);
- Pmsg5(-1,
-_("Date label written: %04d-%02d-%02d at %02d:%02d\n"),
- tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min);
+ dt.julian_day_number = dev->VolHdr.label_date;
+ dt.julian_day_fraction = dev->VolHdr.label_time;
+ tm_decode(&dt, &tm);
+ Pmsg5(-1,
+ _("Date label written: %04d-%02d-%02d at %02d:%02d\n"),
+ tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min);
}
bail_out:
}
if (label.VerNum >= 11) {
char dt[50];
- bstrftime(dt, sizeof(dt), btime_to_unix(label.write_btime));
+ bstrftime(dt, sizeof(dt), btime_to_utime(label.write_btime));
Pmsg1(-1, _("Date written : %s\n"), dt);
} else {
dt.julian_day_number = label.write_date;
switch (rec->FileIndex) {
case SOS_LABEL:
unser_session_label(&label, rec);
- bstrftimes(dt, sizeof(dt), btime_to_unix(label.write_btime));
+ bstrftimes(dt, sizeof(dt), btime_to_utime(label.write_btime));
Pmsg6(-1, _("%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d\n"),
type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, label.JobId);
Pmsg4(-1, _(" Job=%s Date=%s Level=%c Type=%c\n"),
case EOS_LABEL:
char ed1[30], ed2[30];
unser_session_label(&label, rec);
- bstrftimes(dt, sizeof(dt), btime_to_unix(label.write_btime));
+ bstrftimes(dt, sizeof(dt), btime_to_utime(label.write_btime));
Pmsg6(-1, _("%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d\n"),
type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, label.JobId);
Pmsg7(-1, _(" Date=%s Level=%c Type=%c Files=%s Bytes=%s Errors=%d Status=%c\n"),
-/*
- * Record, and label definitions for Bacula
- * media data format.
- *
- * Kern Sibbald, MM
- *
- * Version $Id$
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Record, and label definitions for Bacula
+ * media data format.
+ *
+ * Kern Sibbald, MM
+ *
+ * Version $Id$
+ *
+ */
#ifndef __RECORD_H
General:
22Nov08
+kes Remove all time_t from arguments in favor of utime_t, which is
+ machine independent.
kes Add more debug to match_bsr.c and use %u for unsigned debug editing.
20Nov08
ebl Apply patch for bug #1182 about Recycle flag