Skip to content

Commit 87b654f

Browse files
committed
fixes
1 parent f69a4fb commit 87b654f

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

pcompat.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -617,22 +617,22 @@ static void psync_get_random_seed_from_db(psync_lhash_ctx *hctx){
617617
psync_lhash_update(hctx, &tm, sizeof(&tm));
618618
res=psync_sql_query_rdlock("SELECT * FROM setting ORDER BY RANDOM()");
619619
psync_get_random_seed_from_query(hctx, res);
620-
res=psync_sql_query_rdlock("SELECT * FROM filerevision ORDER BY RANDOM() LIMIT 50");
620+
res=psync_sql_query_rdlock("SELECT * FROM resolver ORDER BY RANDOM() LIMIT 50");
621+
psync_get_random_seed_from_query(hctx, res);
622+
/* res=psync_sql_query_rdlock("SELECT * FROM filerevision ORDER BY RANDOM() LIMIT 50");
621623
psync_get_random_seed_from_query(hctx, res);
622624
res=psync_sql_query_rdlock("SELECT * FROM file ORDER BY RANDOM() LIMIT 50");
623625
psync_get_random_seed_from_query(hctx, res);
624626
res=psync_sql_query_rdlock("SELECT * FROM localfile ORDER BY RANDOM() LIMIT 50");
625627
psync_get_random_seed_from_query(hctx, res);
626-
res=psync_sql_query_rdlock("SELECT * FROM resolver ORDER BY RANDOM() LIMIT 50");
627-
psync_get_random_seed_from_query(hctx, res);
628628
res=psync_sql_query_rdlock("SELECT * FROM folder ORDER BY RANDOM() LIMIT 25");
629629
psync_get_random_seed_from_query(hctx, res);
630630
res=psync_sql_query_rdlock("SELECT * FROM localfolder ORDER BY RANDOM() LIMIT 25");
631631
psync_get_random_seed_from_query(hctx, res);
632632
res=psync_sql_query_rdlock("SELECT * FROM hashchecksum ORDER BY RANDOM() LIMIT 25");
633633
psync_get_random_seed_from_query(hctx, res);
634634
res=psync_sql_query_rdlock("SELECT * FROM pagecache WHERE type=1 AND rowid>(ABS(RANDOM())%(SELECT MAX(rowid)+1 FROM pagecache)) ORDER BY rowid LIMIT 50");
635-
psync_get_random_seed_from_query(hctx, res);
635+
psync_get_random_seed_from_query(hctx, res); */
636636
psync_sql_statement("REPLACE INTO setting (id, value) VALUES ('random', RANDOM())");
637637
psync_nanotime(&tm);
638638
psync_lhash_update(hctx, &tm, sizeof(&tm));
@@ -665,12 +665,12 @@ static void psync_store_seed_in_db(const unsigned char *seed){
665665
unsigned char hashbin[PSYNC_LHASH_DIGEST_LEN];
666666
char hashhex[PSYNC_LHASH_DIGEST_HEXLEN], nm[16];
667667
memcpy(hashbin, seed, PSYNC_LHASH_DIGEST_LEN);
668-
psync_rehash_cnt(hashbin, 5000);
668+
psync_rehash_cnt(hashbin, 2000);
669669
psync_binhex(hashhex, hashbin, PSYNC_LHASH_DIGEST_LEN);
670670
res=psync_sql_prep_statement("REPLACE INTO setting (id, value) VALUES ('randomhash', ?)");
671671
psync_sql_bind_lstring(res, 1, hashhex, PSYNC_LHASH_DIGEST_HEXLEN);
672672
psync_sql_run_free(res);
673-
psync_rehash_cnt(hashbin, 5000);
673+
psync_rehash_cnt(hashbin, 2000);
674674
psync_binhex(hashhex, hashbin, PSYNC_LHASH_DIGEST_LEN);
675675
memcpy(nm, "randomhash", 10);
676676
nm[10]=hashhex[0];
@@ -691,7 +691,7 @@ void psync_get_random_seed(unsigned char *seed, const void *addent, size_t aelen
691691
psync_uint_t i, j;
692692
int64_t i64;
693693
pthread_t threadid;
694-
unsigned char lsc[100][PSYNC_LHASH_DIGEST_LEN];
694+
unsigned char lsc[64][PSYNC_LHASH_DIGEST_LEN];
695695
#if defined(P_OS_POSIX)
696696
debug(D_NOTICE, "in");
697697
struct utsname un;
@@ -802,7 +802,6 @@ void psync_get_random_seed(unsigned char *seed, const void *addent, size_t aelen
802802
if (home){
803803
i64=psync_get_free_space_by_path(home);
804804
psync_lhash_update(&hctx, &i64, sizeof(i64));
805-
psync_lhash_update(&hctx, &home, sizeof(home));
806805
psync_lhash_update(&hctx, home, strlen(home));
807806
if (likely_log(!psync_stat(home, &st)))
808807
psync_lhash_update(&hctx, &st, sizeof(st));
@@ -821,7 +820,7 @@ void psync_get_random_seed(unsigned char *seed, const void *addent, size_t aelen
821820
for (j=0; j<PSYNC_LHASH_DIGEST_LEN; j++)
822821
lsc[i][j]^=(unsigned char)i;
823822
}
824-
for (j=fast?98:0; j<100; j++){
823+
for (j=fast?3:0; j<5; j++){
825824
for (i=0; i<100; i++){
826825
psync_lhash_update(&hctx, &i, sizeof(i));
827826
psync_lhash_update(&hctx, &j, sizeof(j));

pfstasks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,8 @@ int psync_fstask_unlink(psync_fsfolderid_t folderid, const char *name){
864864
psync_tree_del(&folder->creats, &cr->tree);
865865
psync_free(cr);
866866
folder->taskscnt--;
867+
if (folder->folderid>=0)
868+
psync_path_status_drive_folder_changed(folder->folderid);
867869
}
868870
revoffileid=get_file_at_old_location(fileid);
869871
psync_sql_start_transaction();
@@ -977,6 +979,8 @@ int psync_fstask_rename_file(psync_fsfileid_t fileid, psync_fsfolderid_t parentf
977979
psync_tree_del(&folder->creats, &cr->tree);
978980
psync_free(cr);
979981
folder->taskscnt--;
982+
if (folder->folderid>=0)
983+
psync_path_status_drive_folder_changed(folder->folderid);
980984
}
981985
psync_fs_rename_openfile_locked(fileid, to_folderid, new_name);
982986
nlen++;

ppagecache.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,11 +3312,12 @@ void psync_pagecache_init(){
33123312
}
33133313
db_cache_in_pages=psync_setting_get_uint(_PS(fscachesize))/PSYNC_FS_PAGE_SIZE;
33143314
db_cache_max_page=psync_sql_cellint("SELECT MAX(id) FROM pagecache", 0);
3315-
if (db_cache_max_page<db_cache_in_pages){
3315+
free_db_pages=psync_sql_cellint("SELECT COUNT(*) FROM pagecache WHERE type="NTO_STR(PAGE_TYPE_FREE), 0);
3316+
if (db_cache_max_page<db_cache_in_pages && free_db_pages<CACHE_PAGES*2){
33163317
i=0;
33173318
psync_sql_start_transaction();
33183319
res=psync_sql_prep_statement("INSERT INTO pagecache (type) VALUES ("NTO_STR(PAGE_TYPE_FREE)")");
3319-
while (db_cache_max_page+i<db_cache_in_pages && i<CACHE_PAGES*4){
3320+
while (db_cache_max_page+i<db_cache_in_pages && i<CACHE_PAGES*2){
33203321
psync_sql_run(res);
33213322
i++;
33223323
}
@@ -3329,9 +3330,10 @@ void psync_pagecache_init(){
33293330
}
33303331
readcache=psync_file_open(cache_file, P_O_RDWR, P_O_CREAT);
33313332
psync_free(cache_file);
3333+
if (likely_log(psync_file_seek(readcache, db_cache_max_page*PSYNC_FS_PAGE_SIZE, P_SEEK_SET)!=-1))
3334+
assertw(psync_file_truncate(readcache)==0);
33323335
if (db_cache_max_page>db_cache_in_pages)
33333336
psync_pagecache_resize_cache();
3334-
free_db_pages=psync_sql_cellint("SELECT COUNT(*) FROM pagecache WHERE type="NTO_STR(PAGE_TYPE_FREE), 0);
33353337
pthread_mutex_lock(&flush_cache_mutex);
33363338
check_disk_full();
33373339
pthread_mutex_unlock(&flush_cache_mutex);

0 commit comments

Comments
 (0)