summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
authorGravatar grunfink2025-05-28 09:07:19 +0200
committerGravatar grunfink2025-05-28 09:07:19 +0200
commita1369b39c1bd3d2036af12368997648454ca5564 (patch)
treefb18610c75bbda7b80b6726ebd80373fedd606c9 /httpd.c
parentDon't prepend a # before a hashtag that is really an URL. (diff)
downloadpenes-snac2-a1369b39c1bd3d2036af12368997648454ca5564.tar.gz
penes-snac2-a1369b39c1bd3d2036af12368997648454ca5564.tar.xz
penes-snac2-a1369b39c1bd3d2036af12368997648454ca5564.zip
Activated hashtag RSS polling.
Diffstat (limited to '')
-rw-r--r--httpd.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/httpd.c b/httpd.c
index 41b2515..c94a542 100644
--- a/httpd.c
+++ b/httpd.c
@@ -705,34 +705,36 @@ static pthread_cond_t sleep_cond;
705static void *background_thread(void *arg) 705static void *background_thread(void *arg)
706/* background thread (queue management and other things) */ 706/* background thread (queue management and other things) */
707{ 707{
708 time_t purge_time; 708 time_t t, purge_time, rss_time;
709 709
710 (void)arg; 710 (void)arg;
711 711
712 t = time(NULL);
713
712 /* first purge time */ 714 /* first purge time */
713 purge_time = time(NULL) + 10 * 60; 715 purge_time = t + 10 * 60;
716
717 /* first RSS polling time */
718 rss_time = t + 15 * 60;
714 719
715 srv_log(xs_fmt("background thread started")); 720 srv_log(xs_fmt("background thread started"));
716 721
717 while (p_state->srv_running) { 722 while (p_state->srv_running) {
718 time_t t;
719 int cnt = 0; 723 int cnt = 0;
720 724
721 p_state->th_state[0] = THST_QUEUE; 725 p_state->th_state[0] = THST_QUEUE;
722 726
723 { 727 {
724 xs *list = user_list(); 728 xs *list = user_list();
725 char *p;
726 const char *uid; 729 const char *uid;
727 730
728 /* process queues for all users */ 731 /* process queues for all users */
729 p = list; 732 xs_list_foreach(list, uid) {
730 while (xs_list_iter(&p, &uid)) { 733 snac user;
731 snac snac;
732 734
733 if (user_open(&snac, uid)) { 735 if (user_open(&user, uid)) {
734 cnt += process_user_queue(&snac); 736 cnt += process_user_queue(&user);
735 user_free(&snac); 737 user_free(&user);
736 } 738 }
737 } 739 }
738 } 740 }
@@ -740,8 +742,10 @@ static void *background_thread(void *arg)
740 /* global queue */ 742 /* global queue */
741 cnt += process_queue(); 743 cnt += process_queue();
742 744
745 t = time(NULL);
746
743 /* time to purge? */ 747 /* time to purge? */
744 if ((t = time(NULL)) > purge_time) { 748 if (t > purge_time) {
745 /* next purge time is tomorrow */ 749 /* next purge time is tomorrow */
746 purge_time = t + 24 * 60 * 60; 750 purge_time = t + 24 * 60 * 60;
747 751
@@ -750,6 +754,22 @@ static void *background_thread(void *arg)
750 job_post(q_item, 0); 754 job_post(q_item, 0);
751 } 755 }
752 756
757 /* time to poll the RSS? */
758 if (t > rss_time) {
759 /* next RSS poll time */
760 int hours = xs_number_get(xs_dict_get_def(srv_config, "rss_poll_hours", "4"));
761
762 /* don't hammer servers too much */
763 if (hours < 1)
764 hours = 1;
765
766 rss_time = t + 60 * 60 * hours;
767
768 xs *q_item = xs_dict_new();
769 q_item = xs_dict_append(q_item, "type", "rss_poll");
770 job_post(q_item, 0);
771 }
772
753 if (cnt == 0) { 773 if (cnt == 0) {
754 /* sleep 3 seconds */ 774 /* sleep 3 seconds */
755 775