Fossil SCM

Improved logging of backoffice operations.

drh 2020-07-01 20:16 trunk
Commit 71b9f354758a14d4c0622f6df858e3a2e6231916ce425ea9965f709e4ddbc59c
3 files changed +10 -4 +93 -9 +4 -1
+10 -4
--- src/alerts.c
+++ src/alerts.c
@@ -2554,13 +2554,14 @@
25542554
** the process malfunctions or crashes, some notifications may never
25552555
** be sent. But that is better than some recurring bug causing
25562556
** subscribers to be flooded with repeated notifications every 60
25572557
** seconds!
25582558
*/
2559
-void alert_send_alerts(u32 flags){
2559
+int alert_send_alerts(u32 flags){
25602560
EmailEvent *pEvents, *p;
25612561
int nEvent = 0;
2562
+ int nSent = 0;
25622563
Stmt q;
25632564
const char *zDigest = "false";
25642565
Blob hdr, body;
25652566
const char *zUrl;
25662567
const char *zRepoName;
@@ -2700,10 +2701,11 @@
27002701
blob_append(&fhdr, blob_buffer(&p->hdr), blob_size(&p->hdr));
27012702
blob_init(&fbody, blob_buffer(&p->txt), blob_size(&p->txt));
27022703
blob_appendf(&fbody, "\n-- \nSubscription info: %s/alerts/%s\n",
27032704
zUrl, zCode);
27042705
alert_send(pSender,&fhdr,&fbody,p->zFromName);
2706
+ nSent++;
27052707
blob_reset(&fhdr);
27062708
blob_reset(&fbody);
27072709
}else{
27082710
/* Events other than forum posts are gathered together into
27092711
** a single email message */
@@ -2723,10 +2725,11 @@
27232725
}
27242726
if( nHit==0 ) continue;
27252727
blob_appendf(&body,"\n-- \nSubscription info: %s/alerts/%s\n",
27262728
zUrl, zCode);
27272729
alert_send(pSender,&hdr,&body,0);
2730
+ nSent++;
27282731
blob_truncate(&hdr, 0);
27292732
blob_truncate(&body, 0);
27302733
}
27312734
blob_reset(&hdr);
27322735
blob_reset(&body);
@@ -2739,10 +2742,11 @@
27392742
db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;");
27402743
27412744
send_alert_done:
27422745
alert_sender_free(pSender);
27432746
if( g.fSqlTrace ) fossil_trace("-- END alert_send_alerts(%u)\n", flags);
2747
+ return nSent;
27442748
}
27452749
27462750
/*
27472751
** Do backoffice processing for email notifications. In other words,
27482752
** check to see if any email notifications need to occur, and then
@@ -2752,19 +2756,21 @@
27522756
**
27532757
** The mFlags option is zero or more of the SENDALERT_* flags. Normally
27542758
** this flag is zero, but the test-set-alert command sets it to
27552759
** SENDALERT_TRACE.
27562760
*/
2757
-void alert_backoffice(u32 mFlags){
2761
+int alert_backoffice(u32 mFlags){
27582762
int iJulianDay;
2759
- if( !alert_tables_exist() ) return;
2763
+ int nSent = 0;
2764
+ if( !alert_tables_exist() ) return 0;
27602765
alert_send_alerts(mFlags);
27612766
iJulianDay = db_int(0, "SELECT julianday('now')");
27622767
if( iJulianDay>db_get_int("email-last-digest",0) ){
27632768
db_set_int("email-last-digest",iJulianDay,0);
2764
- alert_send_alerts(SENDALERT_DIGEST|mFlags);
2769
+ nSent = alert_send_alerts(SENDALERT_DIGEST|mFlags);
27652770
}
2771
+ return nSent;
27662772
}
27672773
27682774
/*
27692775
** WEBPAGE: contact_admin
27702776
**
27712777
--- src/alerts.c
+++ src/alerts.c
@@ -2554,13 +2554,14 @@
2554 ** the process malfunctions or crashes, some notifications may never
2555 ** be sent. But that is better than some recurring bug causing
2556 ** subscribers to be flooded with repeated notifications every 60
2557 ** seconds!
2558 */
2559 void alert_send_alerts(u32 flags){
2560 EmailEvent *pEvents, *p;
2561 int nEvent = 0;
 
2562 Stmt q;
2563 const char *zDigest = "false";
2564 Blob hdr, body;
2565 const char *zUrl;
2566 const char *zRepoName;
@@ -2700,10 +2701,11 @@
2700 blob_append(&fhdr, blob_buffer(&p->hdr), blob_size(&p->hdr));
2701 blob_init(&fbody, blob_buffer(&p->txt), blob_size(&p->txt));
2702 blob_appendf(&fbody, "\n-- \nSubscription info: %s/alerts/%s\n",
2703 zUrl, zCode);
2704 alert_send(pSender,&fhdr,&fbody,p->zFromName);
 
2705 blob_reset(&fhdr);
2706 blob_reset(&fbody);
2707 }else{
2708 /* Events other than forum posts are gathered together into
2709 ** a single email message */
@@ -2723,10 +2725,11 @@
2723 }
2724 if( nHit==0 ) continue;
2725 blob_appendf(&body,"\n-- \nSubscription info: %s/alerts/%s\n",
2726 zUrl, zCode);
2727 alert_send(pSender,&hdr,&body,0);
 
2728 blob_truncate(&hdr, 0);
2729 blob_truncate(&body, 0);
2730 }
2731 blob_reset(&hdr);
2732 blob_reset(&body);
@@ -2739,10 +2742,11 @@
2739 db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;");
2740
2741 send_alert_done:
2742 alert_sender_free(pSender);
2743 if( g.fSqlTrace ) fossil_trace("-- END alert_send_alerts(%u)\n", flags);
 
2744 }
2745
2746 /*
2747 ** Do backoffice processing for email notifications. In other words,
2748 ** check to see if any email notifications need to occur, and then
@@ -2752,19 +2756,21 @@
2752 **
2753 ** The mFlags option is zero or more of the SENDALERT_* flags. Normally
2754 ** this flag is zero, but the test-set-alert command sets it to
2755 ** SENDALERT_TRACE.
2756 */
2757 void alert_backoffice(u32 mFlags){
2758 int iJulianDay;
2759 if( !alert_tables_exist() ) return;
 
2760 alert_send_alerts(mFlags);
2761 iJulianDay = db_int(0, "SELECT julianday('now')");
2762 if( iJulianDay>db_get_int("email-last-digest",0) ){
2763 db_set_int("email-last-digest",iJulianDay,0);
2764 alert_send_alerts(SENDALERT_DIGEST|mFlags);
2765 }
 
2766 }
2767
2768 /*
2769 ** WEBPAGE: contact_admin
2770 **
2771
--- src/alerts.c
+++ src/alerts.c
@@ -2554,13 +2554,14 @@
2554 ** the process malfunctions or crashes, some notifications may never
2555 ** be sent. But that is better than some recurring bug causing
2556 ** subscribers to be flooded with repeated notifications every 60
2557 ** seconds!
2558 */
2559 int alert_send_alerts(u32 flags){
2560 EmailEvent *pEvents, *p;
2561 int nEvent = 0;
2562 int nSent = 0;
2563 Stmt q;
2564 const char *zDigest = "false";
2565 Blob hdr, body;
2566 const char *zUrl;
2567 const char *zRepoName;
@@ -2700,10 +2701,11 @@
2701 blob_append(&fhdr, blob_buffer(&p->hdr), blob_size(&p->hdr));
2702 blob_init(&fbody, blob_buffer(&p->txt), blob_size(&p->txt));
2703 blob_appendf(&fbody, "\n-- \nSubscription info: %s/alerts/%s\n",
2704 zUrl, zCode);
2705 alert_send(pSender,&fhdr,&fbody,p->zFromName);
2706 nSent++;
2707 blob_reset(&fhdr);
2708 blob_reset(&fbody);
2709 }else{
2710 /* Events other than forum posts are gathered together into
2711 ** a single email message */
@@ -2723,10 +2725,11 @@
2725 }
2726 if( nHit==0 ) continue;
2727 blob_appendf(&body,"\n-- \nSubscription info: %s/alerts/%s\n",
2728 zUrl, zCode);
2729 alert_send(pSender,&hdr,&body,0);
2730 nSent++;
2731 blob_truncate(&hdr, 0);
2732 blob_truncate(&body, 0);
2733 }
2734 blob_reset(&hdr);
2735 blob_reset(&body);
@@ -2739,10 +2742,11 @@
2742 db_multi_exec("DELETE FROM pending_alert WHERE sentDigest AND sentSep;");
2743
2744 send_alert_done:
2745 alert_sender_free(pSender);
2746 if( g.fSqlTrace ) fossil_trace("-- END alert_send_alerts(%u)\n", flags);
2747 return nSent;
2748 }
2749
2750 /*
2751 ** Do backoffice processing for email notifications. In other words,
2752 ** check to see if any email notifications need to occur, and then
@@ -2752,19 +2756,21 @@
2756 **
2757 ** The mFlags option is zero or more of the SENDALERT_* flags. Normally
2758 ** this flag is zero, but the test-set-alert command sets it to
2759 ** SENDALERT_TRACE.
2760 */
2761 int alert_backoffice(u32 mFlags){
2762 int iJulianDay;
2763 int nSent = 0;
2764 if( !alert_tables_exist() ) return 0;
2765 alert_send_alerts(mFlags);
2766 iJulianDay = db_int(0, "SELECT julianday('now')");
2767 if( iJulianDay>db_get_int("email-last-digest",0) ){
2768 db_set_int("email-last-digest",iJulianDay,0);
2769 nSent = alert_send_alerts(SENDALERT_DIGEST|mFlags);
2770 }
2771 return nSent;
2772 }
2773
2774 /*
2775 ** WEBPAGE: contact_admin
2776 **
2777
+93 -9
--- src/backoffice.c
+++ src/backoffice.c
@@ -77,10 +77,12 @@
7777
#else
7878
# include <unistd.h>
7979
# include <sys/types.h>
8080
# include <signal.h>
8181
# include <errno.h>
82
+# include <sys/time.h>
83
+# include <sys/resource.h>
8284
# include <fcntl.h>
8385
# define GETPID getpid
8486
#endif
8587
#include <time.h>
8688
@@ -121,13 +123,32 @@
121123
** should run if backoffice process is needed. It is set by the
122124
** backoffice_check_if_needed() routine which must be run while the database
123125
** file is open. Later, after the database is closed, the
124126
** backoffice_run_if_needed() will consult this variable to see if it
125127
** should be a no-op.
128
+**
129
+** The magic string "x" in this variable means "do not run the backoffice".
126130
*/
127131
static char *backofficeDb = 0;
128132
133
+/*
134
+** Log backoffice activity to a file named here. If not NULL, this
135
+** overrides the "backoffice-logfile" setting of the database. If NULL,
136
+** the "backoffice-logfile" setting is used instead.
137
+*/
138
+static char *backofficeLogfile = 0;
139
+
140
+/*
141
+** Write backoffice log messages to this connection:
142
+*/
143
+static FILE *backofficeLog = 0;
144
+
145
+/*
146
+** Prefix for backoffice log messages
147
+*/
148
+static char *backofficeLogPrefix = 0;
149
+
129150
/* End of state variables
130151
****************************************************************************/
131152
132153
/*
133154
** This function emits a diagnostic message related to the processing in
@@ -514,32 +535,92 @@
514535
}
515536
}
516537
}
517538
return;
518539
}
540
+
541
+/*
542
+** Append to a message to the backoffice log, if the log is open.
543
+*/
544
+void backoffice_log(const char *zFormat, ...){
545
+ va_list ap;
546
+ if( backofficeLog==0 ) return;
547
+ fprintf(backofficeLog, "%s ", backofficeLogPrefix);
548
+ va_start(ap, zFormat);
549
+ vfprintf(backofficeLog, zFormat, ap);
550
+ fflush(backofficeLog);
551
+ va_end(ap);
552
+}
553
+
554
+#if !defined(_WIN32)
555
+/*
556
+** Capture routine for signals while running backoffice.
557
+*/
558
+static void backoffice_signal_handler(int sig){
559
+ const char *zSig = "(unk)";
560
+ if( sig==SIGSEGV ) zSig = "SIGSEGV";
561
+ if( sig==SIGFPE ) zSig = "SIGFPE";
562
+ if( sig==SIGABRT ) zSig = "SIGABRT";
563
+ if( sig==SIGILL ) zSig = "SIGILL";
564
+ backoffice_log("caught signal %d %s\n", sig, zSig);
565
+ exit(1);
566
+}
567
+#endif
568
+
569
+#if !defined(_WIN32)
570
+/*
571
+** Convert a struct timeval into an integer number of microseconds
572
+*/
573
+static long long int tvms(struct timeval *p){
574
+ return ((long long int)p->tv_sec)*1000000 + (long long int)p->tv_usec;
575
+}
576
+#endif
577
+
519578
520579
/*
521580
** This routine runs to do the backoffice processing. When adding new
522581
** backoffice processing tasks, add them here.
523582
*/
524583
void backoffice_work(void){
525584
/* Log the backoffice run for testing purposes. For production deployments
526585
** the "backoffice-logfile" property should be unset and the following code
527586
** should be a no-op. */
528
- char *zLog = db_get("backoffice-logfile",0);
587
+ char *zLog = backofficeLogfile;
588
+ int nAlert = 0;
589
+ int nSmtp = 0;
590
+#if !defined(_WIN32)
591
+ struct timeval sStart, sEnd;
592
+#endif
593
+ if( zLog==0 ) db_get("backoffice-logfile",0);
529594
if( zLog && zLog[0] ){
530
- FILE *pLog = fossil_fopen(zLog, "a");
531
- if( pLog ){
532
- char *zDate = db_text(0, "SELECT datetime('now');");
533
- fprintf(pLog, "%s (%d) backoffice running\n", zDate, GETPID());
534
- fclose(pLog);
535
- }
595
+ backofficeLog = fossil_fopen(zLog, "a");
596
+ backofficeLogPrefix = mprintf("%d %s",
597
+ GETPID(), db_get("project-name","???"));
598
+ backoffice_log("start %s\n", db_text(0, "SELECT datetime('now');"));
599
+#if !defined(_WIN32)
600
+ gettimeofday(&sStart, 0);
601
+ signal(SIGSEGV, backoffice_signal_handler);
602
+ signal(SIGABRT, backoffice_signal_handler);
603
+ signal(SIGFPE, backoffice_signal_handler);
604
+ signal(SIGILL, backoffice_signal_handler);
605
+#endif
536606
}
537607
538608
/* Here is where the actual work of the backoffice happens */
539
- alert_backoffice(0);
540
- smtp_cleanup();
609
+ nAlert = alert_backoffice(0);
610
+ if( nAlert ) backoffice_log("%d alerts sent\n", nAlert);
611
+ nSmtp = smtp_cleanup();
612
+ if( nSmtp ) backoffice_log("%d SMTP cleanup ops\n", nSmtp);
613
+
614
+ /* Close the log */
615
+ if( backofficeLog ){
616
+#if !defined(_WIN32)
617
+ gettimeofday(&sEnd,0);
618
+ backoffice_log("elapse time %d us\n", tvms(&sEnd) - tvms(&sStart));
619
+#endif
620
+ fclose(backofficeLog);
621
+ }
541622
}
542623
543624
/*
544625
** COMMAND: backoffice*
545626
**
@@ -554,10 +635,12 @@
554635
** on collection of repositories.
555636
**
556637
** OPTIONS:
557638
**
558639
** --debug Show what this command is doing.
640
+**
641
+** --logfile FILE Append a log of backoffice actions onto FILE.
559642
**
560643
** --min N When polling, invoke backoffice at least
561644
** once every N seconds even if the repository
562645
** never changes. 0 or negative means disable
563646
** this feature. Default: 3600 (once per hour).
@@ -581,10 +664,11 @@
581664
const char *zPoll;
582665
int bDebug = 0;
583666
unsigned int nCmd = 0;
584667
if( find_option("trace",0,0)!=0 ) g.fAnyTrace = 1;
585668
if( find_option("nodelay",0,0)!=0 ) backofficeNoDelay = 1;
669
+ backofficeLogfile = find_option("logfile",0,1);
586670
zPoll = find_option("poll",0,1);
587671
nPoll = zPoll ? atoi(zPoll) : 0;
588672
zPoll = find_option("min",0,1);
589673
nMin = zPoll ? atoi(zPoll) : 3600;
590674
bDebug = find_option("debug",0,0)!=0;
591675
--- src/backoffice.c
+++ src/backoffice.c
@@ -77,10 +77,12 @@
77 #else
78 # include <unistd.h>
79 # include <sys/types.h>
80 # include <signal.h>
81 # include <errno.h>
 
 
82 # include <fcntl.h>
83 # define GETPID getpid
84 #endif
85 #include <time.h>
86
@@ -121,13 +123,32 @@
121 ** should run if backoffice process is needed. It is set by the
122 ** backoffice_check_if_needed() routine which must be run while the database
123 ** file is open. Later, after the database is closed, the
124 ** backoffice_run_if_needed() will consult this variable to see if it
125 ** should be a no-op.
 
 
126 */
127 static char *backofficeDb = 0;
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129 /* End of state variables
130 ****************************************************************************/
131
132 /*
133 ** This function emits a diagnostic message related to the processing in
@@ -514,32 +535,92 @@
514 }
515 }
516 }
517 return;
518 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
520 /*
521 ** This routine runs to do the backoffice processing. When adding new
522 ** backoffice processing tasks, add them here.
523 */
524 void backoffice_work(void){
525 /* Log the backoffice run for testing purposes. For production deployments
526 ** the "backoffice-logfile" property should be unset and the following code
527 ** should be a no-op. */
528 char *zLog = db_get("backoffice-logfile",0);
 
 
 
 
 
 
529 if( zLog && zLog[0] ){
530 FILE *pLog = fossil_fopen(zLog, "a");
531 if( pLog ){
532 char *zDate = db_text(0, "SELECT datetime('now');");
533 fprintf(pLog, "%s (%d) backoffice running\n", zDate, GETPID());
534 fclose(pLog);
535 }
 
 
 
 
 
536 }
537
538 /* Here is where the actual work of the backoffice happens */
539 alert_backoffice(0);
540 smtp_cleanup();
 
 
 
 
 
 
 
 
 
 
 
541 }
542
543 /*
544 ** COMMAND: backoffice*
545 **
@@ -554,10 +635,12 @@
554 ** on collection of repositories.
555 **
556 ** OPTIONS:
557 **
558 ** --debug Show what this command is doing.
 
 
559 **
560 ** --min N When polling, invoke backoffice at least
561 ** once every N seconds even if the repository
562 ** never changes. 0 or negative means disable
563 ** this feature. Default: 3600 (once per hour).
@@ -581,10 +664,11 @@
581 const char *zPoll;
582 int bDebug = 0;
583 unsigned int nCmd = 0;
584 if( find_option("trace",0,0)!=0 ) g.fAnyTrace = 1;
585 if( find_option("nodelay",0,0)!=0 ) backofficeNoDelay = 1;
 
586 zPoll = find_option("poll",0,1);
587 nPoll = zPoll ? atoi(zPoll) : 0;
588 zPoll = find_option("min",0,1);
589 nMin = zPoll ? atoi(zPoll) : 3600;
590 bDebug = find_option("debug",0,0)!=0;
591
--- src/backoffice.c
+++ src/backoffice.c
@@ -77,10 +77,12 @@
77 #else
78 # include <unistd.h>
79 # include <sys/types.h>
80 # include <signal.h>
81 # include <errno.h>
82 # include <sys/time.h>
83 # include <sys/resource.h>
84 # include <fcntl.h>
85 # define GETPID getpid
86 #endif
87 #include <time.h>
88
@@ -121,13 +123,32 @@
123 ** should run if backoffice process is needed. It is set by the
124 ** backoffice_check_if_needed() routine which must be run while the database
125 ** file is open. Later, after the database is closed, the
126 ** backoffice_run_if_needed() will consult this variable to see if it
127 ** should be a no-op.
128 **
129 ** The magic string "x" in this variable means "do not run the backoffice".
130 */
131 static char *backofficeDb = 0;
132
133 /*
134 ** Log backoffice activity to a file named here. If not NULL, this
135 ** overrides the "backoffice-logfile" setting of the database. If NULL,
136 ** the "backoffice-logfile" setting is used instead.
137 */
138 static char *backofficeLogfile = 0;
139
140 /*
141 ** Write backoffice log messages to this connection:
142 */
143 static FILE *backofficeLog = 0;
144
145 /*
146 ** Prefix for backoffice log messages
147 */
148 static char *backofficeLogPrefix = 0;
149
150 /* End of state variables
151 ****************************************************************************/
152
153 /*
154 ** This function emits a diagnostic message related to the processing in
@@ -514,32 +535,92 @@
535 }
536 }
537 }
538 return;
539 }
540
541 /*
542 ** Append to a message to the backoffice log, if the log is open.
543 */
544 void backoffice_log(const char *zFormat, ...){
545 va_list ap;
546 if( backofficeLog==0 ) return;
547 fprintf(backofficeLog, "%s ", backofficeLogPrefix);
548 va_start(ap, zFormat);
549 vfprintf(backofficeLog, zFormat, ap);
550 fflush(backofficeLog);
551 va_end(ap);
552 }
553
554 #if !defined(_WIN32)
555 /*
556 ** Capture routine for signals while running backoffice.
557 */
558 static void backoffice_signal_handler(int sig){
559 const char *zSig = "(unk)";
560 if( sig==SIGSEGV ) zSig = "SIGSEGV";
561 if( sig==SIGFPE ) zSig = "SIGFPE";
562 if( sig==SIGABRT ) zSig = "SIGABRT";
563 if( sig==SIGILL ) zSig = "SIGILL";
564 backoffice_log("caught signal %d %s\n", sig, zSig);
565 exit(1);
566 }
567 #endif
568
569 #if !defined(_WIN32)
570 /*
571 ** Convert a struct timeval into an integer number of microseconds
572 */
573 static long long int tvms(struct timeval *p){
574 return ((long long int)p->tv_sec)*1000000 + (long long int)p->tv_usec;
575 }
576 #endif
577
578
579 /*
580 ** This routine runs to do the backoffice processing. When adding new
581 ** backoffice processing tasks, add them here.
582 */
583 void backoffice_work(void){
584 /* Log the backoffice run for testing purposes. For production deployments
585 ** the "backoffice-logfile" property should be unset and the following code
586 ** should be a no-op. */
587 char *zLog = backofficeLogfile;
588 int nAlert = 0;
589 int nSmtp = 0;
590 #if !defined(_WIN32)
591 struct timeval sStart, sEnd;
592 #endif
593 if( zLog==0 ) db_get("backoffice-logfile",0);
594 if( zLog && zLog[0] ){
595 backofficeLog = fossil_fopen(zLog, "a");
596 backofficeLogPrefix = mprintf("%d %s",
597 GETPID(), db_get("project-name","???"));
598 backoffice_log("start %s\n", db_text(0, "SELECT datetime('now');"));
599 #if !defined(_WIN32)
600 gettimeofday(&sStart, 0);
601 signal(SIGSEGV, backoffice_signal_handler);
602 signal(SIGABRT, backoffice_signal_handler);
603 signal(SIGFPE, backoffice_signal_handler);
604 signal(SIGILL, backoffice_signal_handler);
605 #endif
606 }
607
608 /* Here is where the actual work of the backoffice happens */
609 nAlert = alert_backoffice(0);
610 if( nAlert ) backoffice_log("%d alerts sent\n", nAlert);
611 nSmtp = smtp_cleanup();
612 if( nSmtp ) backoffice_log("%d SMTP cleanup ops\n", nSmtp);
613
614 /* Close the log */
615 if( backofficeLog ){
616 #if !defined(_WIN32)
617 gettimeofday(&sEnd,0);
618 backoffice_log("elapse time %d us\n", tvms(&sEnd) - tvms(&sStart));
619 #endif
620 fclose(backofficeLog);
621 }
622 }
623
624 /*
625 ** COMMAND: backoffice*
626 **
@@ -554,10 +635,12 @@
635 ** on collection of repositories.
636 **
637 ** OPTIONS:
638 **
639 ** --debug Show what this command is doing.
640 **
641 ** --logfile FILE Append a log of backoffice actions onto FILE.
642 **
643 ** --min N When polling, invoke backoffice at least
644 ** once every N seconds even if the repository
645 ** never changes. 0 or negative means disable
646 ** this feature. Default: 3600 (once per hour).
@@ -581,10 +664,11 @@
664 const char *zPoll;
665 int bDebug = 0;
666 unsigned int nCmd = 0;
667 if( find_option("trace",0,0)!=0 ) g.fAnyTrace = 1;
668 if( find_option("nodelay",0,0)!=0 ) backofficeNoDelay = 1;
669 backofficeLogfile = find_option("logfile",0,1);
670 zPoll = find_option("poll",0,1);
671 nPoll = zPoll ? atoi(zPoll) : 0;
672 zPoll = find_option("min",0,1);
673 nMin = zPoll ? atoi(zPoll) : 3600;
674 bDebug = find_option("debug",0,0)!=0;
675
+4 -1
--- src/smtp.c
+++ src/smtp.c
@@ -1236,19 +1236,22 @@
12361236
}
12371237
12381238
/*
12391239
** Remove stale content from the emailblob table.
12401240
*/
1241
-void smtp_cleanup(void){
1241
+int smtp_cleanup(void){
1242
+ int nAction = 0;
12421243
if( db_table_exists("repository","emailblob") ){
12431244
db_begin_transaction();
12441245
db_multi_exec(
12451246
"UPDATE emailblob SET ets=NULL WHERE enref<=0;"
12461247
"DELETE FROM emailblob WHERE enref<=0;"
12471248
);
1249
+ nAction = db_changes();
12481250
db_end_transaction(0);
12491251
}
1252
+ return nAction;
12501253
}
12511254
12521255
/*
12531256
** COMMAND: test-emailblob-refcheck
12541257
**
12551258
--- src/smtp.c
+++ src/smtp.c
@@ -1236,19 +1236,22 @@
1236 }
1237
1238 /*
1239 ** Remove stale content from the emailblob table.
1240 */
1241 void smtp_cleanup(void){
 
1242 if( db_table_exists("repository","emailblob") ){
1243 db_begin_transaction();
1244 db_multi_exec(
1245 "UPDATE emailblob SET ets=NULL WHERE enref<=0;"
1246 "DELETE FROM emailblob WHERE enref<=0;"
1247 );
 
1248 db_end_transaction(0);
1249 }
 
1250 }
1251
1252 /*
1253 ** COMMAND: test-emailblob-refcheck
1254 **
1255
--- src/smtp.c
+++ src/smtp.c
@@ -1236,19 +1236,22 @@
1236 }
1237
1238 /*
1239 ** Remove stale content from the emailblob table.
1240 */
1241 int smtp_cleanup(void){
1242 int nAction = 0;
1243 if( db_table_exists("repository","emailblob") ){
1244 db_begin_transaction();
1245 db_multi_exec(
1246 "UPDATE emailblob SET ets=NULL WHERE enref<=0;"
1247 "DELETE FROM emailblob WHERE enref<=0;"
1248 );
1249 nAction = db_changes();
1250 db_end_transaction(0);
1251 }
1252 return nAction;
1253 }
1254
1255 /*
1256 ** COMMAND: test-emailblob-refcheck
1257 **
1258

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button