| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
|
#define _GNU_SOURCE |
|
|
|
|
|
#include "section_list.h" |
|
| 17 |
#include "log.h" |
#include "log.h" |
| 18 |
|
#include "section_list.h" |
| 19 |
#include "trie_dict.h" |
#include "trie_dict.h" |
| 20 |
|
#include <errno.h> |
| 21 |
|
#include <signal.h> |
| 22 |
#include <stdio.h> |
#include <stdio.h> |
| 23 |
|
#include <stdlib.h> |
| 24 |
#include <string.h> |
#include <string.h> |
|
#include <signal.h> |
|
| 25 |
#include <unistd.h> |
#include <unistd.h> |
| 26 |
#include <stdlib.h> |
#include <sys/ipc.h> |
|
#include <errno.h> |
|
| 27 |
#include <sys/param.h> |
#include <sys/param.h> |
| 28 |
#include <sys/sem.h> |
#include <sys/sem.h> |
| 29 |
#include <sys/shm.h> |
#include <sys/shm.h> |
|
#include <sys/ipc.h> |
|
| 30 |
|
|
| 31 |
#ifdef _SEM_SEMUN_UNDEFINED |
#ifdef _SEM_SEMUN_UNDEFINED |
| 32 |
union semun |
union semun |
| 42 |
#define SECTION_TRY_LOCK_WAIT_TIME 1 // second |
#define SECTION_TRY_LOCK_WAIT_TIME 1 // second |
| 43 |
#define SECTION_TRY_LOCK_TIMES 10 |
#define SECTION_TRY_LOCK_TIMES 10 |
| 44 |
|
|
| 45 |
#define ARTICLE_BLOCK_PER_SHM 400 // sizeof(ARTICLE_BLOCK) * ARTICLE_BLOCK_PER_SHM is the size of each shm segment to allocate |
#define ARTICLE_BLOCK_PER_SHM 1000 // sizeof(ARTICLE_BLOCK) * ARTICLE_BLOCK_PER_SHM is the size of each shm segment to allocate |
| 46 |
#define ARTICLE_BLOCK_SHM_COUNT_LIMIT 200 // limited by length (8-bit) of proj_id in ftok(path, proj_id) |
#define ARTICLE_BLOCK_SHM_COUNT_LIMIT 80 // limited by length (8-bit) of proj_id in ftok(path, proj_id) |
| 47 |
#define ARTICLE_BLOCK_PER_POOL (ARTICLE_BLOCK_PER_SHM * ARTICLE_BLOCK_SHM_COUNT_LIMIT) |
#define ARTICLE_BLOCK_PER_POOL (ARTICLE_BLOCK_PER_SHM * ARTICLE_BLOCK_SHM_COUNT_LIMIT) |
| 48 |
|
|
| 49 |
#define CALCULATE_PAGE_THRESHOLD 100 // Adjust to tune performance of move topic |
#define CALCULATE_PAGE_THRESHOLD 100 // Adjust to tune performance of moving topic between sections |
| 50 |
|
|
| 51 |
#define SID_STR_LEN 5 // 32-bit + NULL |
#define SID_STR_LEN 5 // 32-bit + NULL |
| 52 |
|
|
| 608 |
p_sid_str[i] = '\0'; |
p_sid_str[i] = '\0'; |
| 609 |
} |
} |
| 610 |
|
|
| 611 |
SECTION_LIST *section_list_create(int32_t sid, const char *sname, const char *stitle, const char *master_name) |
SECTION_LIST *section_list_create(int32_t sid, const char *sname, const char *stitle, const char *master_list) |
| 612 |
{ |
{ |
| 613 |
SECTION_LIST *p_section; |
SECTION_LIST *p_section; |
| 614 |
char sid_str[SID_STR_LEN]; |
char sid_str[SID_STR_LEN]; |
| 637 |
strncpy(p_section->stitle, stitle, sizeof(p_section->stitle) - 1); |
strncpy(p_section->stitle, stitle, sizeof(p_section->stitle) - 1); |
| 638 |
p_section->stitle[sizeof(p_section->stitle) - 1] = '\0'; |
p_section->stitle[sizeof(p_section->stitle) - 1] = '\0'; |
| 639 |
|
|
| 640 |
strncpy(p_section->master_list, master_name, sizeof(p_section->master_list) - 1); |
strncpy(p_section->master_list, master_list, sizeof(p_section->master_list) - 1); |
| 641 |
p_section->master_list[sizeof(p_section->master_list) - 1] = '\0'; |
p_section->master_list[sizeof(p_section->master_list) - 1] = '\0'; |
| 642 |
|
|
| 643 |
if (trie_dict_set(p_section_list_pool->p_trie_dict_section_by_name, sname, p_section_list_pool->section_count) != 1) |
if (trie_dict_set(p_section_list_pool->p_trie_dict_section_by_name, sname, p_section_list_pool->section_count) != 1) |