Beispiel #1
0
void *thread_synchronizer(void *attr){
    int ret;
    /* Инициализируем кэш */
    ret = Cache_init(DEFAULT_CACHE_PATH"server_cache.sqlite3", &server_pool.cache);
    if(ret == LC_CODE_BADF_ERR)
        syslog(LOG_ERR, "Sync: произошла ошибка создания / открытия файла.");
    if(ret == LC_CODE_TABLE_ERR)
        syslog(LOG_ERR, "Sync: невозможно создать стандартную таблицу");
    /* Инициализируем хэш */
    Hash_init(&server_pool.hash, -1);
    ret = sync_cache_and_db(&server_pool.cache);
    if(ret != 0){
        syslog(LOG_ERR, "Sync with db failed.");
    }
    ret = sync_cache_and_hash(&server_pool.cache, &server_pool.hash);
    /* TODO Wait conditions cycle here... */
    pthread_exit(NULL);
}
Beispiel #2
0
/*Intialize the pre-set header content and lock for the cache_list*/
void proxy_init(){
    int i;
    int lengthSet[5] = {86,73,32,19,25};

    /* Initial locks to be 1 */
    Sem_init(&mutex,0,1);
    Sem_init(&w,0,1);

    /* Initial Cache space */

    Cache_init();

    /* Initial pre-set header */
    headerSet = (char**)malloc(5*sizeof(char*));
    for(i = 0 ; i < 5 ;i++){
        headerSet[i] = (char*)malloc(lengthSet[i]*sizeof(char));
    }
    strcpy(headerSet[0],"User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120305 Firefox/10.0.3\r\n");
    strcpy(headerSet[1],"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n");
    strcpy(headerSet[2],"Accept-Encoding: gzip, deflate\r\n");
    strcpy(headerSet[3],"Connection: close\r\n");
    strcpy(headerSet[4],"Proxy-Connection: close\r\n");
}
Beispiel #3
0
INIT() {
  Cache_init((Object)&__Cache);

  return 0;
};