| 16 |
|
|
| 17 |
#include "section_list_loader.h" |
#include "section_list_loader.h" |
| 18 |
#include "article_cache.h" |
#include "article_cache.h" |
| 19 |
|
#include "bbs.h" |
| 20 |
#include "log.h" |
#include "log.h" |
| 21 |
#include "database.h" |
#include "database.h" |
| 22 |
#include "menu.h" |
#include "menu.h" |
| 31 |
#define _POSIX_C_SOURCE 200809L |
#define _POSIX_C_SOURCE 200809L |
| 32 |
#include <string.h> |
#include <string.h> |
| 33 |
|
|
|
#define SECTION_LIST_LOAD_INTERVAL 10 // second |
|
|
|
|
| 34 |
int section_list_loader_pid; |
int section_list_loader_pid; |
| 35 |
int last_article_op_log_mid; |
int last_article_op_log_mid; |
| 36 |
|
|
| 450 |
break; |
break; |
| 451 |
case 'D': // Delete article |
case 'D': // Delete article |
| 452 |
case 'X': // Delete article by Admin |
case 'X': // Delete article by Admin |
| 453 |
p_article->visible = 0; |
if (section_list_set_article_visible(p_section, atoi(row[1]), 0) < 0) |
|
if (p_article->tid == 0) |
|
| 454 |
{ |
{ |
| 455 |
// Set articles in the topic to be invisible |
log_error("section_list_set_article_visible(sid=%d, aid=%d, visible=0) error\n", p_section->sid, atoi(row[1])); |
| 456 |
do |
} |
| 457 |
{ |
if (section_list_calculate_page(p_section, atoi(row[1])) < 0) |
| 458 |
p_article = p_article->p_topic_next; |
{ |
| 459 |
p_article->visible = 0; |
log_error("section_list_calculate_page(aid=%d) error\n", atoi(row[1])); |
|
} while (p_article->tid != 0); |
|
| 460 |
} |
} |
| 461 |
break; |
break; |
| 462 |
case 'S': // Restore article |
case 'S': // Restore article |
| 463 |
p_article->visible = 1; |
if (section_list_set_article_visible(p_section, atoi(row[1]), 1) < 0) |
| 464 |
|
{ |
| 465 |
|
log_error("section_list_set_article_visible(sid=%d, aid=%d, visible=1) error\n", p_section->sid, atoi(row[1])); |
| 466 |
|
} |
| 467 |
|
if (section_list_calculate_page(p_section, atoi(row[1])) < 0) |
| 468 |
|
{ |
| 469 |
|
log_error("section_list_calculate_page(aid=%d) error\n", atoi(row[1])); |
| 470 |
|
} |
| 471 |
break; |
break; |
| 472 |
case 'L': // Lock article |
case 'L': // Lock article |
| 473 |
p_article->lock = 1; |
p_article->lock = 1; |
| 640 |
{ |
{ |
| 641 |
SYS_child_process_count++; |
SYS_child_process_count++; |
| 642 |
section_list_loader_pid = pid; |
section_list_loader_pid = pid; |
| 643 |
log_common("Section list loader process (%d) start\n", pid); |
log_common("Section list loader process (pid = %d) start\n", pid); |
| 644 |
return 0; |
return 0; |
| 645 |
} |
} |
| 646 |
else if (pid < 0) // Error |
else if (pid < 0) // Error |
| 730 |
continue; |
continue; |
| 731 |
} |
} |
| 732 |
|
|
| 733 |
for (i = 0; i < SECTION_LIST_LOAD_INTERVAL && !SYS_server_exit && !SYS_section_list_reload; i++) |
for (i = 0; i < BBS_section_list_load_interval && !SYS_server_exit && !SYS_section_list_reload; i++) |
| 734 |
{ |
{ |
| 735 |
sleep(1); |
sleep(1); |
| 736 |
} |
} |