fix weird name (#140)
This commit is contained in:
parent
9014edb99a
commit
58461232db
|
|
@ -136,7 +136,7 @@ void papi_conn_fail_reset() {
|
|||
}
|
||||
|
||||
#define _NEED_DATA(cnt) \
|
||||
if (unpdbg_likely(*datalen < (cnt))) \
|
||||
if (pdbg_unlikely(*datalen < (cnt))) \
|
||||
return -1
|
||||
#define ALIGN_BYTES psync_alignof(uint64_t)
|
||||
|
||||
|
|
@ -391,14 +391,14 @@ binresult *papi_result(psock_t *sock) {
|
|||
binresult *res;
|
||||
uint32_t ressize;
|
||||
|
||||
if (unpdbg_likely(psock_readall(sock, &ressize, sizeof(uint32_t)) !=
|
||||
if (pdbg_unlikely(psock_readall(sock, &ressize, sizeof(uint32_t)) !=
|
||||
sizeof(uint32_t))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (unsigned char *)malloc(ressize);
|
||||
|
||||
if (unpdbg_likely(psock_readall(sock, data, ressize) != ressize)) {
|
||||
if (pdbg_unlikely(psock_readall(sock, data, ressize) != ressize)) {
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -413,11 +413,11 @@ binresult *papi_result_thread(psock_t *sock) {
|
|||
unsigned char *data;
|
||||
binresult *res;
|
||||
uint32_t ressize;
|
||||
if (unpdbg_likely(psock_readall_thread(
|
||||
if (pdbg_unlikely(psock_readall_thread(
|
||||
sock, &ressize, sizeof(uint32_t)) != sizeof(uint32_t)))
|
||||
return NULL;
|
||||
data = (unsigned char *)malloc(ressize);
|
||||
if (unpdbg_likely(psock_readall_thread(sock, data, ressize) !=
|
||||
if (pdbg_unlikely(psock_readall_thread(sock, data, ressize) !=
|
||||
ressize)) {
|
||||
free(data);
|
||||
return NULL;
|
||||
|
|
@ -495,7 +495,7 @@ unsigned char *papi_prepare(const char *command, size_t cmdlen,
|
|||
plen += params[i].paramnamelen + 2;
|
||||
}
|
||||
}
|
||||
if (unpdbg_likely(plen > 0xffff))
|
||||
if (pdbg_unlikely(plen > 0xffff))
|
||||
return NULL;
|
||||
sdata = data = (unsigned char *)malloc(plen + 2 + additionalalloc);
|
||||
memcpy(data, &plen, 2);
|
||||
|
|
@ -543,12 +543,12 @@ binresult *papi_send(psock_t *sock, const char *command,
|
|||
}
|
||||
|
||||
if (readres & 2) {
|
||||
if (unpdbg_likely(psock_writeall_thread(sock, sdata, plen) != plen)) {
|
||||
if (pdbg_unlikely(psock_writeall_thread(sock, sdata, plen) != plen)) {
|
||||
free(sdata);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (unpdbg_likely(psock_writeall(sock, sdata, plen) != plen)) {
|
||||
if (pdbg_unlikely(psock_writeall(sock, sdata, plen) != plen)) {
|
||||
free(sdata);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,11 +175,11 @@ psync_symmetric_key_t pcrypto_key() {
|
|||
pcrypto_ctr_encdec_t pcrypto_ctr_encdec_create(psync_symmetric_key_t key) {
|
||||
psync_aes256_encoder enc;
|
||||
pcrypto_ctr_encdec_t ret;
|
||||
if (unpdbg_likely(key->keylen < PSYNC_AES256_KEY_SIZE + PSYNC_AES256_BLOCK_SIZE)) {
|
||||
if (pdbg_unlikely(key->keylen < PSYNC_AES256_KEY_SIZE + PSYNC_AES256_BLOCK_SIZE)) {
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
}
|
||||
enc = paes_create_encoder(key);
|
||||
if (unpdbg_likely(enc == PSYNC_INVALID_ENCODER)) {
|
||||
if (pdbg_unlikely(enc == PSYNC_INVALID_ENCODER)) {
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
}
|
||||
ret = psync_new(pcrypto_key_t);
|
||||
|
|
@ -323,7 +323,7 @@ pcrypto_decode_text(pcrypto_textdec_t enc,
|
|||
*aessrc, *aesdst, *outptr, *ret;
|
||||
size_t len;
|
||||
const unsigned char *xorptr;
|
||||
if (unpdbg_likely(datalen % PSYNC_AES256_BLOCK_SIZE || !datalen))
|
||||
if (pdbg_unlikely(datalen % PSYNC_AES256_BLOCK_SIZE || !datalen))
|
||||
return NULL;
|
||||
aessrc = ALIGN_PTR_A256_BS(buff);
|
||||
aesdst = aessrc + PSYNC_AES256_BLOCK_SIZE;
|
||||
|
|
@ -399,11 +399,11 @@ pcrypto_textenc_t
|
|||
pcrypto_textenc_create(psync_symmetric_key_t key) {
|
||||
psync_aes256_encoder enc;
|
||||
pcrypto_textenc_t ret;
|
||||
if (unpdbg_likely(key->keylen <
|
||||
if (pdbg_unlikely(key->keylen <
|
||||
PSYNC_AES256_KEY_SIZE + PSYNC_AES256_BLOCK_SIZE))
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
enc = paes_create_encoder(key);
|
||||
if (unpdbg_likely(enc == PSYNC_INVALID_ENCODER))
|
||||
if (pdbg_unlikely(enc == PSYNC_INVALID_ENCODER))
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
ret = (pcrypto_textenc_t)malloc(
|
||||
offsetof(pcrypto_key_iv_t, iv) + key->keylen -
|
||||
|
|
@ -425,11 +425,11 @@ pcrypto_textdec_t
|
|||
pcrypto_textdec_create(psync_symmetric_key_t key) {
|
||||
psync_aes256_encoder enc;
|
||||
pcrypto_textenc_t ret;
|
||||
if (unpdbg_likely(key->keylen <
|
||||
if (pdbg_unlikely(key->keylen <
|
||||
PSYNC_AES256_KEY_SIZE + PSYNC_AES256_BLOCK_SIZE))
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
enc = paes_create_decoder(key);
|
||||
if (unpdbg_likely(enc == PSYNC_INVALID_ENCODER))
|
||||
if (pdbg_unlikely(enc == PSYNC_INVALID_ENCODER))
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
ret = (pcrypto_textenc_t)malloc(
|
||||
offsetof(pcrypto_key_iv_t, iv) + key->keylen -
|
||||
|
|
@ -452,13 +452,13 @@ pcrypto_sec_encdec_create(psync_symmetric_key_t key) {
|
|||
psync_aes256_encoder enc;
|
||||
psync_aes256_decoder dec;
|
||||
pcrypto_sector_encdec_t ret;
|
||||
if (unpdbg_likely(key->keylen < PSYNC_AES256_KEY_SIZE))
|
||||
if (pdbg_unlikely(key->keylen < PSYNC_AES256_KEY_SIZE))
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
enc = paes_create_encoder(key);
|
||||
if (unpdbg_likely(enc == PSYNC_INVALID_ENCODER))
|
||||
if (pdbg_unlikely(enc == PSYNC_INVALID_ENCODER))
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
dec = paes_create_decoder(key);
|
||||
if (unpdbg_likely(enc == PSYNC_INVALID_ENCODER)) {
|
||||
if (pdbg_unlikely(enc == PSYNC_INVALID_ENCODER)) {
|
||||
paes_free_encoder(enc);
|
||||
return PSYNC_CRYPTO_INVALID_ENCODER;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ static int setup_do_upload(const unsigned char *rsapriv,
|
|||
if (!api)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
res = papi_send2(api, "crypto_setuserkeys", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
|
|
@ -227,7 +227,7 @@ static int download_keys(unsigned char **rsapriv, size_t *rsaprivlen, unsigned c
|
|||
if (!api)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_START_CANT_CONNECT);
|
||||
res = papi_send2(api, "crypto_getuserkeys", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_START_CANT_CONNECT);
|
||||
|
|
@ -311,7 +311,7 @@ static binresult *psync_get_keys_bin_auth(const char *auth) {
|
|||
if (!api)
|
||||
return NULL;
|
||||
res = papi_send2(api, "crypto_getuserkeys", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
} else {
|
||||
psync_apipool_release(api);
|
||||
|
|
@ -471,7 +471,7 @@ int pcryptofolder_get_hint(char **hint) {
|
|||
if (!api)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_HINT_CANT_CONNECT);
|
||||
res = papi_send2(api, "crypto_getuserhint", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_HINT_CANT_CONNECT);
|
||||
|
|
@ -743,7 +743,7 @@ int pcryptofolder_reset() {
|
|||
if (!api)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_RESET_CANT_CONNECT);
|
||||
res = papi_send2(api, "crypto_reset", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_RESET_CANT_CONNECT);
|
||||
|
|
@ -830,7 +830,7 @@ static psync_encrypted_symmetric_key_t download_fldr_enckey(psync_folderid_t fol
|
|||
return (psync_encrypted_symmetric_key_t)errptr(
|
||||
pdbg_return_const(PSYNC_CRYPTO_CANT_CONNECT));
|
||||
res = papi_send2(api, "crypto_getfolderkey", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return (psync_encrypted_symmetric_key_t)errptr(
|
||||
|
|
@ -883,7 +883,7 @@ static psync_encrypted_symmetric_key_t download_file_enckey(psync_fileid_t filei
|
|||
return (psync_encrypted_symmetric_key_t)errptr(
|
||||
pdbg_return_const(PSYNC_CRYPTO_CANT_CONNECT));
|
||||
res = papi_send2(api, "crypto_getfilekey", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return (psync_encrypted_symmetric_key_t)errptr(
|
||||
|
|
@ -999,7 +999,7 @@ static psync_symmetric_key_t get_file_symkey_safe(psync_fileid_t fileid, uint64_
|
|||
return symkey;
|
||||
}
|
||||
enckey = get_file_enckey(fileid, hash, nonetwork);
|
||||
if (unpdbg_likely(is_err(enckey)))
|
||||
if (pdbg_unlikely(is_err(enckey)))
|
||||
return (psync_symmetric_key_t)enckey;
|
||||
if (nonetwork &&
|
||||
enckey ==
|
||||
|
|
@ -1009,7 +1009,7 @@ static psync_symmetric_key_t get_file_symkey_safe(psync_fileid_t fileid, uint64_
|
|||
symkey = prsa_decrypt_symm_key_lock(&crypto_privkey, &enckey);
|
||||
|
||||
free(enckey);
|
||||
if (unpdbg_likely(symkey == PSYNC_INVALID_SYM_KEY))
|
||||
if (pdbg_unlikely(symkey == PSYNC_INVALID_SYM_KEY))
|
||||
return (psync_symmetric_key_t)errptr(
|
||||
pdbg_return_const(PSYNC_CRYPTO_INVALID_KEY));
|
||||
return symkey;
|
||||
|
|
@ -1371,7 +1371,7 @@ static pcrypto_sector_encdec_t get_fileencoder(psync_fileid_t fileid, uint64_t h
|
|||
psync_symmetric_key_t symkey, realkey;
|
||||
sym_key_ver1 *skv1;
|
||||
symkey = get_file_symkey_safe(fileid, hash, nonetwork);
|
||||
if (unpdbg_likely(is_err(symkey)))
|
||||
if (pdbg_unlikely(is_err(symkey)))
|
||||
return (pcrypto_sector_encdec_t)symkey;
|
||||
if (nonetwork && (pcrypto_sector_encdec_t)symkey ==
|
||||
PSYNC_CRYPTO_UNLOADED_SECTOR_ENCODER)
|
||||
|
|
@ -1420,7 +1420,7 @@ static pcrypto_sector_encdec_t get_fileencoder_tmp(psync_fsfileid_t fileid,
|
|||
"SELECT type, fileid, text2, int1 FROM fstask WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, -fileid);
|
||||
row = psync_sql_fetch_row(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
psync_sql_free_result(res);
|
||||
return (pcrypto_sector_encdec_t)errptr(
|
||||
pdbg_return_const(PSYNC_CRYPTO_FILE_NOT_FOUND));
|
||||
|
|
@ -1648,7 +1648,7 @@ int psync_cloud_crypto_send_mkdir(psync_folderid_t folderid, const char *name,
|
|||
if (!api)
|
||||
return set_err(pdbg_return_const(PSYNC_CRYPTO_CANT_CONNECT), err);
|
||||
res = papi_send2(api, "createfolder", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return set_err(pdbg_return_const(PSYNC_CRYPTO_CANT_CONNECT), err);
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ extern "C" {
|
|||
"assertion pdbg_likely(%s) failed", TO_STR(x)) * \
|
||||
0)
|
||||
|
||||
#define unpdbg_likely(x) \
|
||||
#define pdbg_unlikely(x) \
|
||||
(unlikely(x) ? pdbg_printf(__FILE__, __FUNCTION__, __LINE__, D_WARNING, \
|
||||
"assertion unpdbg_likely(%s) failed", TO_STR(x)) \
|
||||
"assertion pdbg_unlikely(%s) failed", TO_STR(x)) \
|
||||
: 0)
|
||||
#define pdbg_return(x) \
|
||||
((x) * pdbg_printf(__FILE__, __FUNCTION__, __LINE__, D_NOTICE, \
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ static int check_user_relocated(uint64_t luserid, psock_t *sock) {
|
|||
binparam params[] = {PAPI_STR("timeformat", "timestamp"),
|
||||
PAPI_STR("auth", psync_my_auth)};
|
||||
res = papi_send2(sock, "getolduserids", params);
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
return 0;
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
if (result) {
|
||||
|
|
@ -395,7 +395,7 @@ static psock_t *get_connected_socket() {
|
|||
|
||||
sock = papi_connect(apiserver, psync_setting_get_bool(_PS(usessl)));
|
||||
|
||||
if (unpdbg_likely(!sock)) {
|
||||
if (pdbg_unlikely(!sock)) {
|
||||
pstatus_set(PSTATUS_TYPE_ONLINE, PSTATUS_ONLINE_OFFLINE);
|
||||
psys_sleep_milliseconds(PSYNC_SLEEP_BEFORE_RECONNECT);
|
||||
continue;
|
||||
|
|
@ -451,7 +451,7 @@ static psock_t *get_connected_socket() {
|
|||
|
||||
free(osversion);
|
||||
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psock_close(sock);
|
||||
pstatus_set(PSTATUS_TYPE_ONLINE, PSTATUS_ONLINE_OFFLINE);
|
||||
psys_sleep_milliseconds(PSYNC_SLEEP_BEFORE_RECONNECT);
|
||||
|
|
@ -576,7 +576,7 @@ static psock_t *get_connected_socket() {
|
|||
sizeof(psync_my_auth));
|
||||
|
||||
if (luserid) {
|
||||
if (unpdbg_likely(luserid != userid)) {
|
||||
if (pdbg_unlikely(luserid != userid)) {
|
||||
if (check_user_relocated(luserid, sock)) {
|
||||
pdbg_logf(D_NOTICE, "setting PSTATUS_AUTH_RELOCATED");
|
||||
pstatus_set(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_RELOCATED);
|
||||
|
|
@ -792,7 +792,7 @@ static psock_t *get_connected_socket() {
|
|||
binparam params[] = {PAPI_STR("timeformat", "timestamp"),
|
||||
PAPI_STR("auth", psync_my_auth)};
|
||||
res = papi_send2(sock, "account_info", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psock_close(sock);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -3008,7 +3008,7 @@ restart:
|
|||
sock->pending = 1;
|
||||
res = papi_result(sock);
|
||||
should_free_res = 1;
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
ptimer_notify_exception();
|
||||
handle_exception(&sock, &ids, 'r');
|
||||
socks[1] = sock->sock;
|
||||
|
|
|
|||
|
|
@ -451,8 +451,8 @@ static int stat_and_create_local(psync_syncid_t syncid, psync_fileid_t fileid,
|
|||
struct stat st;
|
||||
psync_uint_row row;
|
||||
psync_fileid_t localfileid;
|
||||
if (unpdbg_likely(stat(name, &st)) ||
|
||||
unpdbg_likely(pfile_stat_size(&st) != serversize))
|
||||
if (pdbg_unlikely(stat(name, &st)) ||
|
||||
pdbg_unlikely(pfile_stat_size(&st) != serversize))
|
||||
return -1;
|
||||
localfileid = 0;
|
||||
psync_sql_start_transaction();
|
||||
|
|
@ -589,7 +589,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
|
||||
rt = psync_get_remote_file_checksum(dt->dwllist.fileid, serverhashhex,
|
||||
&serversize, &hash);
|
||||
if (unpdbg_likely(rt != PSYNC_NET_OK)) {
|
||||
if (pdbg_unlikely(rt != PSYNC_NET_OK)) {
|
||||
if (rt == PSYNC_NET_TEMPFAIL)
|
||||
return -1;
|
||||
else
|
||||
|
|
@ -653,7 +653,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
PSYNC_HASH_DIGEST_HEXLEN);
|
||||
while ((row = psync_sql_fetch_rowint(sql))) {
|
||||
tmpold = pfolder_lpath_lfile(row[0], NULL);
|
||||
if (unpdbg_likely(!tmpold))
|
||||
if (pdbg_unlikely(!tmpold))
|
||||
continue;
|
||||
psync_sql_free_result(sql);
|
||||
sql = NULL;
|
||||
|
|
@ -693,7 +693,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
return -1;
|
||||
}
|
||||
res = psync_api_run_command("getfilelink", params);
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
return -1;
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
|
|
@ -728,7 +728,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
}
|
||||
|
||||
fd = pfile_open(dt->tmpname, O_WRONLY, O_CREAT | O_TRUNC);
|
||||
if (unpdbg_likely(fd == INVALID_HANDLE_VALUE))
|
||||
if (pdbg_unlikely(fd == INVALID_HANDLE_VALUE))
|
||||
goto err0;
|
||||
|
||||
rt = psync_net_download_ranges(&ranges, dt->dwllist.fileid, hash, serversize,
|
||||
|
|
@ -758,15 +758,15 @@ static int task_download_file(download_task_t *dt) {
|
|||
: (range->len + range->off - 1),
|
||||
cookie)))
|
||||
break;
|
||||
if (unpdbg_likely(!http))
|
||||
if (pdbg_unlikely(!http))
|
||||
goto err2;
|
||||
|
||||
while (!dt->dwllist.stop) {
|
||||
rd = psync_http_readall(http, buff, PSYNC_COPY_BUFFER_SIZE);
|
||||
if (rd == 0)
|
||||
break;
|
||||
if (unpdbg_likely(rd < 0) ||
|
||||
unpdbg_likely(psync_file_writeall_checkoverquota(fd, buff, rd)))
|
||||
if (pdbg_unlikely(rd < 0) ||
|
||||
pdbg_unlikely(psync_file_writeall_checkoverquota(fd, buff, rd)))
|
||||
goto err2;
|
||||
psync_hash_update(&hashctx, buff, rd);
|
||||
pthread_mutex_lock(¤t_downloads_mutex);
|
||||
|
|
@ -789,9 +789,9 @@ static int task_download_file(download_task_t *dt) {
|
|||
(unsigned long)range->len, range->filename,
|
||||
(unsigned long)range->off);
|
||||
ifd = pfile_open(range->filename, O_RDONLY, 0);
|
||||
if (unpdbg_likely(ifd == INVALID_HANDLE_VALUE))
|
||||
if (pdbg_unlikely(ifd == INVALID_HANDLE_VALUE))
|
||||
goto err2;
|
||||
if (unpdbg_likely(pfile_seek(ifd, range->off, SEEK_SET) == -1)) {
|
||||
if (pdbg_unlikely(pfile_seek(ifd, range->off, SEEK_SET) == -1)) {
|
||||
pfile_close(ifd);
|
||||
goto err2;
|
||||
}
|
||||
|
|
@ -802,8 +802,8 @@ static int task_download_file(download_task_t *dt) {
|
|||
else
|
||||
rd = result;
|
||||
rd = pfile_read(ifd, buff, rd);
|
||||
if (unpdbg_likely(rd <= 0) ||
|
||||
unpdbg_likely(psync_file_writeall_checkoverquota(fd, buff, rd)) ||
|
||||
if (pdbg_unlikely(rd <= 0) ||
|
||||
pdbg_unlikely(psync_file_writeall_checkoverquota(fd, buff, rd)) ||
|
||||
unlikely(!pstatus_ok_status_arr(requiredstatuses,
|
||||
ARRAY_SIZE(requiredstatuses)))) {
|
||||
pfile_close(ifd);
|
||||
|
|
@ -833,14 +833,14 @@ static int task_download_file(download_task_t *dt) {
|
|||
}
|
||||
goto err2;
|
||||
}
|
||||
if (unpdbg_likely(pfile_sync(fd)))
|
||||
if (pdbg_unlikely(pfile_sync(fd)))
|
||||
goto err2;
|
||||
free(buff);
|
||||
psync_hash_final(localhashbin, &hashctx);
|
||||
if (unpdbg_likely(pfile_close(fd)))
|
||||
if (pdbg_unlikely(pfile_close(fd)))
|
||||
goto err0;
|
||||
psync_binhex(localhashhex, localhashbin, PSYNC_HASH_DIGEST_LEN);
|
||||
if (unpdbg_likely(
|
||||
if (pdbg_unlikely(
|
||||
memcmp(localhashhex, serverhashhex, PSYNC_HASH_DIGEST_HEXLEN))) {
|
||||
pdbg_logf(D_WARNING, "got wrong file checksum for file %s", dt->filename);
|
||||
if (dt->dwllist.stop == 2) {
|
||||
|
|
@ -959,16 +959,16 @@ static int task_rename_file(psync_syncid_t oldsyncid, psync_syncid_t newsyncid,
|
|||
}
|
||||
}
|
||||
psync_sql_free_result(res);
|
||||
if (unpdbg_likely(!lfileid)) {
|
||||
if (pdbg_unlikely(!lfileid)) {
|
||||
ptask_download(newsyncid, fileid, newlocalfolderid, newname);
|
||||
return 0;
|
||||
}
|
||||
newfolder =
|
||||
pfolder_lpath_lfldr(newlocalfolderid, newsyncid, NULL);
|
||||
if (unpdbg_likely(!newfolder))
|
||||
if (pdbg_unlikely(!newfolder))
|
||||
return 0;
|
||||
oldpath = pfolder_lpath_lfile(lfileid, NULL);
|
||||
if (unpdbg_likely(!oldpath)) {
|
||||
if (pdbg_unlikely(!oldpath)) {
|
||||
free(newfolder);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1192,7 +1192,7 @@ static int task_run_download_file(uint64_t taskid, psync_syncid_t syncid,
|
|||
hastargetchecksum = 0;
|
||||
psync_sql_free_result(res);
|
||||
localpath = pfolder_lpath_lfldr(localfolderid, syncid, NULL);
|
||||
if (unpdbg_likely(!localpath))
|
||||
if (pdbg_unlikely(!localpath))
|
||||
return 0;
|
||||
localname =
|
||||
psync_strcat(localpath, "/", filename, NULL);
|
||||
|
|
@ -1379,7 +1379,7 @@ static int task_del_folder_rec(psync_folderid_t localfolderid,
|
|||
task_wait_no_downloads();
|
||||
psync_stop_localscan();
|
||||
localpath = pfolder_lpath_lfldr(localfolderid, syncid, NULL);
|
||||
if (unpdbg_likely(!localpath)) {
|
||||
if (pdbg_unlikely(!localpath)) {
|
||||
psync_resume_localscan();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ int pfile_truncate(int fd) {
|
|||
|
||||
int64_t pfile_size(int fd) {
|
||||
struct stat st;
|
||||
if (unpdbg_likely(fstat(fd, &st)))
|
||||
if (pdbg_unlikely(fstat(fd, &st)))
|
||||
return -1;
|
||||
else
|
||||
return st.st_size;
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ psync_folderid_t pfolder_id(const char *path) {
|
|||
if (!res) {
|
||||
res = psync_sql_query_rdlock(
|
||||
"SELECT id FROM folder WHERE parentfolderid=? AND name=?");
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_error = PERROR_DATABASE_ERROR;
|
||||
return PSYNC_INVALID_FOLDERID;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ psync_folderid_t pfolder_id(const char *path) {
|
|||
psync_sql_bind_uint(res, 1, cfolderid);
|
||||
psync_sql_bind_lstring(res, 2, path, len);
|
||||
row = psync_sql_fetch_rowint(res);
|
||||
if (unpdbg_likely(!row))
|
||||
if (pdbg_unlikely(!row))
|
||||
goto err;
|
||||
cfolderid = row[0];
|
||||
path += len;
|
||||
|
|
@ -159,7 +159,7 @@ psync_folderid_t pfolder_id_create(const char *path) {
|
|||
if (!res) {
|
||||
res = psync_sql_query_rdlock(
|
||||
"SELECT id FROM folder WHERE parentfolderid=? AND name=?");
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_error = PERROR_DATABASE_ERROR;
|
||||
return PSYNC_INVALID_FOLDERID;
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ static string_list *str_list_decode(psync_folderid_t folderid, string_list *e) {
|
|||
fn = pcryptofolder_flddecode_filename(dec, e->str);
|
||||
pcryptofolder_flddecoder_release(folderid, dec);
|
||||
free(e);
|
||||
if (unpdbg_likely(!fn))
|
||||
if (pdbg_unlikely(!fn))
|
||||
return NULL;
|
||||
e = str_to_list_element(fn, strlen(fn));
|
||||
free(fn);
|
||||
|
|
@ -307,7 +307,7 @@ static int psync_add_path_to_list_decode(psync_list *lst,
|
|||
"SELECT parentfolderid, name, flags FROM folder WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, folderid);
|
||||
row = psync_sql_fetch_row(res);
|
||||
if (unpdbg_likely(!row))
|
||||
if (pdbg_unlikely(!row))
|
||||
break;
|
||||
cfolderid = folderid;
|
||||
flags = psync_get_number(row[2]);
|
||||
|
|
@ -318,7 +318,7 @@ static int psync_add_path_to_list_decode(psync_list *lst,
|
|||
if (e) {
|
||||
if (flags & PSYNC_FOLDER_FLAG_ENCRYPTED) {
|
||||
e = str_list_decode(cfolderid, e);
|
||||
if (unpdbg_likely(!e))
|
||||
if (pdbg_unlikely(!e))
|
||||
goto err;
|
||||
}
|
||||
psync_list_add_head(lst, &e->list);
|
||||
|
|
@ -365,7 +365,7 @@ char *pfolder_path(psync_folderid_t folderid, size_t *retlen) {
|
|||
psync_sql_rdlock();
|
||||
res = psync_add_path_to_list(&folderlist, folderid);
|
||||
psync_sql_rdunlock();
|
||||
if (unpdbg_likely(res)) {
|
||||
if (pdbg_unlikely(res)) {
|
||||
psync_free_string_list(&folderlist);
|
||||
return PSYNC_INVALID_PATH;
|
||||
}
|
||||
|
|
@ -387,7 +387,7 @@ char *pfolder_path_sep(psync_folderid_t folderid, const char *sep,
|
|||
int res;
|
||||
psync_list_init(&folderlist);
|
||||
res = psync_add_path_to_list_decode(&folderlist, folderid);
|
||||
if (unpdbg_likely(res)) {
|
||||
if (pdbg_unlikely(res)) {
|
||||
psync_free_string_list(&folderlist);
|
||||
return PSYNC_INVALID_PATH;
|
||||
}
|
||||
|
|
@ -417,7 +417,7 @@ char *pfolder_file_path(psync_fileid_t fileid, size_t *retlen) {
|
|||
"SELECT parentfolderid, name FROM file WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, fileid);
|
||||
row = psync_sql_fetch_row(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
psync_sql_free_result(res);
|
||||
psync_sql_rdunlock();
|
||||
return PSYNC_INVALID_PATH;
|
||||
|
|
@ -427,7 +427,7 @@ char *pfolder_file_path(psync_fileid_t fileid, size_t *retlen) {
|
|||
e = str_to_list_element(str, len);
|
||||
psync_list_add_head(&folderlist, &e->list);
|
||||
psync_sql_free_result(res);
|
||||
if (unpdbg_likely(psync_add_path_to_list(&folderlist, folderid))) {
|
||||
if (pdbg_unlikely(psync_add_path_to_list(&folderlist, folderid))) {
|
||||
psync_sql_rdunlock();
|
||||
psync_free_string_list(&folderlist);
|
||||
return PSYNC_INVALID_PATH;
|
||||
|
|
@ -490,7 +490,7 @@ char *pfolder_lpath_lfldr(psync_folderid_t localfolderid,
|
|||
res = psync_add_local_path_to_list_by_localfolderid(&folderlist,
|
||||
localfolderid, syncid);
|
||||
psync_sql_rdunlock();
|
||||
if (unpdbg_likely(res)) {
|
||||
if (pdbg_unlikely(res)) {
|
||||
psync_free_string_list(&folderlist);
|
||||
return PSYNC_INVALID_PATH;
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ char *pfolder_lpath_lfile(psync_fileid_t localfileid,
|
|||
res = psync_sql_query_nolock(
|
||||
"SELECT localparentfolderid, syncid, name FROM localfile WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, localfileid);
|
||||
if (unpdbg_likely(!(row = psync_sql_fetch_row(res)))) {
|
||||
if (pdbg_unlikely(!(row = psync_sql_fetch_row(res)))) {
|
||||
psync_sql_free_result(res);
|
||||
psync_sql_rdunlock();
|
||||
psync_free_string_list(&folderlist);
|
||||
|
|
@ -531,7 +531,7 @@ char *pfolder_lpath_lfile(psync_fileid_t localfileid,
|
|||
rs = psync_add_local_path_to_list_by_localfolderid(&folderlist, localfolderid,
|
||||
syncid);
|
||||
psync_sql_rdunlock();
|
||||
if (unpdbg_likely(rs)) {
|
||||
if (pdbg_unlikely(rs)) {
|
||||
psync_free_string_list(&folderlist);
|
||||
return PSYNC_INVALID_PATH;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ static int psync_fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
|||
psync_sql_rdlock();
|
||||
CHECK_LOGIN_RDLOCKED();
|
||||
folderid = psync_fsfolderid_by_path(path, &flags);
|
||||
if (unpdbg_likely(folderid == PSYNC_INVALID_FSFOLDERID)) {
|
||||
if (pdbg_unlikely(folderid == PSYNC_INVALID_FSFOLDERID)) {
|
||||
psync_sql_rdunlock();
|
||||
if (psync_fsfolder_crypto_error())
|
||||
return pdbg_return(
|
||||
|
|
@ -904,7 +904,7 @@ static int psync_fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
|||
while ((row = psync_sql_fetch_row(res))) {
|
||||
name = psync_get_lstring(row[5], &namelen);
|
||||
#if defined(FS_MAX_ACCEPTABLE_FILENAME_LEN)
|
||||
if (unpdbg_likely(namelen > FS_MAX_ACCEPTABLE_FILENAME_LEN))
|
||||
if (pdbg_unlikely(namelen > FS_MAX_ACCEPTABLE_FILENAME_LEN))
|
||||
continue;
|
||||
#endif
|
||||
if (!name || !name[0])
|
||||
|
|
@ -922,7 +922,7 @@ static int psync_fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
|||
while ((row = psync_sql_fetch_row(res))) {
|
||||
name = psync_get_lstring(row[0], &namelen);
|
||||
#if defined(FS_MAX_ACCEPTABLE_FILENAME_LEN)
|
||||
if (unpdbg_likely(namelen > FS_MAX_ACCEPTABLE_FILENAME_LEN))
|
||||
if (pdbg_unlikely(namelen > FS_MAX_ACCEPTABLE_FILENAME_LEN))
|
||||
continue;
|
||||
#endif
|
||||
if (!name || !name[0])
|
||||
|
|
@ -937,7 +937,7 @@ static int psync_fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
|||
if (folder) {
|
||||
ptree_for_each(trel, folder->mkdirs) {
|
||||
#if defined(FS_MAX_ACCEPTABLE_FILENAME_LEN)
|
||||
if (unpdbg_likely(
|
||||
if (pdbg_unlikely(
|
||||
strlen(
|
||||
ptree_element(trel, psync_fstask_mkdir_t, tree)->name) >
|
||||
FS_MAX_ACCEPTABLE_FILENAME_LEN))
|
||||
|
|
@ -954,7 +954,7 @@ static int psync_fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
|||
}
|
||||
ptree_for_each(trel, folder->creats) {
|
||||
#if defined(FS_MAX_ACCEPTABLE_FILENAME_LEN)
|
||||
if (unpdbg_likely(
|
||||
if (pdbg_unlikely(
|
||||
strlen(
|
||||
ptree_element(trel, psync_fstask_creat_t, tree)->name) >
|
||||
FS_MAX_ACCEPTABLE_FILENAME_LEN))
|
||||
|
|
@ -1080,7 +1080,7 @@ int64_t psync_fs_load_interval_tree(int fd, uint64_t size,
|
|||
rrd = pfile_pread(fd, records, rd * sizeof(psync_fs_index_record),
|
||||
i * sizeof(psync_fs_index_record) +
|
||||
sizeof(psync_fs_index_header));
|
||||
if (unpdbg_likely(rrd != rd * sizeof(psync_fs_index_record)))
|
||||
if (pdbg_unlikely(rrd != rd * sizeof(psync_fs_index_record)))
|
||||
return -1;
|
||||
for (j = 0; j < rd; j++)
|
||||
psync_interval_tree_add(tree, records[j].offset,
|
||||
|
|
@ -1108,7 +1108,7 @@ static int load_interval_tree(psync_openfile_t *of) {
|
|||
psync_fs_index_header hdr;
|
||||
int64_t ifs;
|
||||
ifs = pfile_size(of->indexfile);
|
||||
if (unpdbg_likely(ifs == -1))
|
||||
if (pdbg_unlikely(ifs == -1))
|
||||
return -1;
|
||||
if (ifs < sizeof(psync_fs_index_header)) {
|
||||
pdbg_assertw(ifs == 0);
|
||||
|
|
@ -1153,7 +1153,7 @@ static int open_write_files(psync_openfile_t *of, int trunc) {
|
|||
return -EIO;
|
||||
}
|
||||
fs = pfile_size(of->datafile);
|
||||
if (unpdbg_likely(fs == -1))
|
||||
if (pdbg_unlikely(fs == -1))
|
||||
return -EIO;
|
||||
if (of->encrypted)
|
||||
of->currentsize = pfscrypto_plain_size(fs);
|
||||
|
|
@ -1300,7 +1300,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
(unsigned long)hash);
|
||||
}
|
||||
psync_sql_free_result(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
ret = -ENOENT;
|
||||
goto ex0;
|
||||
}
|
||||
|
|
@ -1318,7 +1318,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
hash = row[4];
|
||||
}
|
||||
psync_sql_free_result(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
ret = -ENOENT;
|
||||
goto ex0;
|
||||
}
|
||||
|
|
@ -1326,7 +1326,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
fileid = cr->fileid;
|
||||
if (fpath->flags & PSYNC_FOLDER_FLAG_ENCRYPTED) {
|
||||
encoder = pcryptofolder_filencoder_get(fileid, hash, 1);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encoder))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encoder))) {
|
||||
ret = -psync_fs_crypto_err_to_errno(psync_crypto_to_error(encoder));
|
||||
goto ex0;
|
||||
}
|
||||
|
|
@ -1344,7 +1344,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
ret = open_write_files(of, fi->flags & O_TRUNC);
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
fi->fh = openfile_to_fh(of);
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
psync_fs_dec_of_refcnt(of);
|
||||
return ret;
|
||||
} else
|
||||
|
|
@ -1380,7 +1380,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
}
|
||||
if (fpath->flags & PSYNC_FOLDER_FLAG_ENCRYPTED) {
|
||||
encoder = pcryptofolder_filencoder_get(fileid, hash, 1);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encoder))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encoder))) {
|
||||
ret = -psync_fs_crypto_err_to_errno(psync_crypto_to_error(encoder));
|
||||
goto ex0;
|
||||
}
|
||||
|
|
@ -1397,7 +1397,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
ret = open_write_files(of, fi->flags & O_TRUNC);
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
fi->fh = openfile_to_fh(of);
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
psync_fs_dec_of_refcnt(of);
|
||||
return ret;
|
||||
} else
|
||||
|
|
@ -1448,13 +1448,13 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
if (fpath->flags & PSYNC_FOLDER_FLAG_ENCRYPTED) {
|
||||
if (row) {
|
||||
encoder = pcryptofolder_filencoder_get(fileid, hash, 0);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encoder))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encoder))) {
|
||||
ret = -psync_fs_crypto_err_to_errno(psync_crypto_to_error(encoder));
|
||||
goto ex0;
|
||||
}
|
||||
encsymkey = pcryptofolder_filencoder_key_get(fileid, hash,
|
||||
&encsymkeylen);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encsymkey))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encsymkey))) {
|
||||
pcryptofolder_filencoder_release(fileid, hash, encoder);
|
||||
ret = -psync_fs_crypto_err_to_errno(psync_crypto_to_error(encsymkey));
|
||||
goto ex0;
|
||||
|
|
@ -1463,13 +1463,13 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
psync_symmetric_key_t symkey;
|
||||
encsymkey = pcryptofolder_filencoder_key_newplain(
|
||||
0, &encsymkeylen, &symkey);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encsymkey))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encsymkey))) {
|
||||
ret = -psync_fs_crypto_err_to_errno(psync_crypto_to_error(encsymkey));
|
||||
goto ex0;
|
||||
}
|
||||
encoder = pcrypto_sec_encdec_create(symkey);
|
||||
psymkey_free(symkey);
|
||||
if (unpdbg_likely(encoder == PSYNC_CRYPTO_INVALID_ENCODER)) {
|
||||
if (pdbg_unlikely(encoder == PSYNC_CRYPTO_INVALID_ENCODER)) {
|
||||
free(encsymkey);
|
||||
ret = -ENOMEM;
|
||||
goto ex0;
|
||||
|
|
@ -1483,7 +1483,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
cr =
|
||||
psync_fstask_add_creat(folder, fpath->name, 0, encsymkey, encsymkeylen);
|
||||
free(encsymkey);
|
||||
if (unpdbg_likely(!cr)) {
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
ret = -EIO;
|
||||
goto ex0;
|
||||
}
|
||||
|
|
@ -1496,7 +1496,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
of->modified = 1;
|
||||
ret = open_write_files(of, 1);
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
psync_fs_del_creat(fpath, of);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1506,7 +1506,7 @@ static int psync_fs_open(const char *path, struct fuse_file_info *fi) {
|
|||
} else if (row) {
|
||||
if (fpath->flags & PSYNC_FOLDER_FLAG_ENCRYPTED) {
|
||||
encoder = pcryptofolder_filencoder_get(fileid, hash, 1);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encoder))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encoder))) {
|
||||
ret = -psync_fs_crypto_err_to_errno(psync_crypto_to_error(encoder));
|
||||
goto ex0;
|
||||
}
|
||||
|
|
@ -1632,7 +1632,7 @@ static int psync_fs_creat(const char *path, mode_t mode,
|
|||
}
|
||||
encsymkey = pcryptofolder_filencoder_key_newplain(
|
||||
0, &encsymkeylen, &symkey);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encsymkey))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encsymkey))) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
psync_sql_unlock();
|
||||
free(fpath);
|
||||
|
|
@ -1640,7 +1640,7 @@ static int psync_fs_creat(const char *path, mode_t mode,
|
|||
}
|
||||
encoder = pcrypto_sec_encdec_create(symkey);
|
||||
psymkey_free(symkey);
|
||||
if (unpdbg_likely(encoder == PSYNC_CRYPTO_INVALID_ENCODER)) {
|
||||
if (pdbg_unlikely(encoder == PSYNC_CRYPTO_INVALID_ENCODER)) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
psync_sql_unlock();
|
||||
free(fpath);
|
||||
|
|
@ -1655,7 +1655,7 @@ static int psync_fs_creat(const char *path, mode_t mode,
|
|||
cr = psync_fstask_add_creat(folder, fpath->name, 0, encsymkey, encsymkeylen);
|
||||
if (encsymkey)
|
||||
free(encsymkey);
|
||||
if (unpdbg_likely(!cr)) {
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
psync_sql_unlock();
|
||||
free(fpath);
|
||||
|
|
@ -1670,7 +1670,7 @@ static int psync_fs_creat(const char *path, mode_t mode,
|
|||
of->modified = 1;
|
||||
ret = open_write_files(of, 1);
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
psync_fs_del_creat(fpath, of);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1879,7 +1879,7 @@ static int psync_fs_flush(const char *path, struct fuse_file_info *fi) {
|
|||
writeid = of->writeid;
|
||||
if (of->encrypted) {
|
||||
ret = pfscrypto_flush(of);
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1941,18 +1941,18 @@ static int psync_fs_fsync(const char *path, int datasync,
|
|||
}
|
||||
if (of->encrypted) {
|
||||
ret = pfscrypto_flush(of);
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (unpdbg_likely(pfile_sync(of->datafile)) ||
|
||||
unpdbg_likely(!of->newfile && pfile_sync(of->indexfile))) {
|
||||
if (pdbg_unlikely(pfile_sync(of->datafile)) ||
|
||||
pdbg_unlikely(!of->newfile && pfile_sync(of->indexfile))) {
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
return -EIO;
|
||||
}
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
if (unpdbg_likely(psync_sql_sync()))
|
||||
if (pdbg_unlikely(psync_sql_sync()))
|
||||
return -EIO;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1961,7 +1961,7 @@ static int psync_fs_fsyncdir(const char *path, int datasync,
|
|||
struct fuse_file_info *fi) {
|
||||
psync_fs_set_thread_name();
|
||||
pdbg_logf(D_NOTICE, "fsyncdir %s", path);
|
||||
if (unpdbg_likely(psync_sql_sync()))
|
||||
if (pdbg_unlikely(psync_sql_sync()))
|
||||
return -EIO;
|
||||
else
|
||||
return 0;
|
||||
|
|
@ -2083,7 +2083,7 @@ static int psync_fs_modfile_check_size_ok(psync_openfile_t *of, uint64_t size) {
|
|||
ioff = of->indexoff++;
|
||||
rec.offset = of->currentsize;
|
||||
rec.length = size - of->currentsize;
|
||||
if (unpdbg_likely(pfile_pwrite(of->indexfile, &rec, sizeof(rec),
|
||||
if (pdbg_unlikely(pfile_pwrite(of->indexfile, &rec, sizeof(rec),
|
||||
sizeof(rec) * ioff +
|
||||
sizeof(psync_fs_index_header)) !=
|
||||
sizeof(rec)))
|
||||
|
|
@ -2140,7 +2140,7 @@ psync_fs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
size = pfscrypto_crypto_size(of->initialsize);
|
||||
encsymkey = pcryptofolder_filencoder_key_get(of->fileid, of->hash,
|
||||
&encsymkeylen);
|
||||
if (unpdbg_likely(psync_crypto_is_error(encsymkey))) {
|
||||
if (pdbg_unlikely(psync_crypto_is_error(encsymkey))) {
|
||||
psync_sql_unlock();
|
||||
return -psync_fs_crypto_err_to_errno(psync_crypto_to_error(encsymkey));
|
||||
}
|
||||
|
|
@ -2158,7 +2158,7 @@ psync_fs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
of->currentname);
|
||||
cr = psync_fstask_add_creat(of->currentfolder, of->currentname, of->fileid,
|
||||
encsymkey, encsymkeylen);
|
||||
if (unpdbg_likely(!cr)) {
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
psync_sql_unlock();
|
||||
ppagecache_unlock_pages();
|
||||
free(encsymkey);
|
||||
|
|
@ -2170,7 +2170,7 @@ psync_fs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
of->newfile = 1;
|
||||
of->modified = 1;
|
||||
ret = open_write_files(of, 0);
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
ppagecache_unlock_pages();
|
||||
free(encsymkey);
|
||||
return ret;
|
||||
|
|
@ -2181,7 +2181,7 @@ psync_fs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
ret = ppagecache_copy_to_file_locked(
|
||||
of, of->hash, size);
|
||||
ppagecache_unlock_pages();
|
||||
if (unpdbg_likely(ret)) {
|
||||
if (pdbg_unlikely(ret)) {
|
||||
free(encsymkey);
|
||||
return -EIO;
|
||||
}
|
||||
|
|
@ -2193,14 +2193,14 @@ psync_fs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
of->fileid, of->hash, encsymkey,
|
||||
encsymkeylen);
|
||||
free(encsymkey);
|
||||
if (unpdbg_likely(!cr)) {
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
psync_sql_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
psync_fs_update_openfile_fileid_locked(of, cr->fileid);
|
||||
psync_sql_unlock();
|
||||
ret = open_write_files(of, 0);
|
||||
if (unpdbg_likely(ret) ||
|
||||
if (pdbg_unlikely(ret) ||
|
||||
pfile_seek(of->datafile, size, SEEK_SET) == -1 ||
|
||||
pfile_truncate(of->datafile)) {
|
||||
if (!ret)
|
||||
|
|
@ -2238,7 +2238,7 @@ psync_fs_reopen_static_file_for_writing(psync_openfile_t *of) {
|
|||
pdbg_logf(D_NOTICE, "reopening static file %s for writing size %lu, taskid %lu",
|
||||
of->currentname, (unsigned long)of->currentsize, (unsigned long)taskid);
|
||||
cr = psync_fstask_add_creat(of->currentfolder, of->currentname, 0, NULL, 0);
|
||||
if (unpdbg_likely(!cr)) {
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
psync_sql_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
|
|
@ -2262,7 +2262,7 @@ psync_fs_reopen_static_file_for_writing(psync_openfile_t *of) {
|
|||
of->modified = 1;
|
||||
of->staticfile = 0;
|
||||
ret = open_write_files(of, 1);
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return ret;
|
||||
if (pfile_pwrite(of->datafile, of->staticdata, of->currentsize, 0) !=
|
||||
of->currentsize)
|
||||
|
|
@ -2424,15 +2424,15 @@ static int psync_fs_write_modified(psync_openfile_t *of, const char *buf,
|
|||
psync_fs_index_record rec;
|
||||
uint64_t ioff;
|
||||
ssize_t bw;
|
||||
if (unpdbg_likely(psync_fs_modfile_check_size_ok(of, offset)))
|
||||
if (pdbg_unlikely(psync_fs_modfile_check_size_ok(of, offset)))
|
||||
return -EIO;
|
||||
ioff = of->indexoff++;
|
||||
bw = pfile_pwrite(of->datafile, buf, size, offset);
|
||||
if (unpdbg_likely(bw == -1))
|
||||
if (pdbg_unlikely(bw == -1))
|
||||
return -EIO;
|
||||
rec.offset = offset;
|
||||
rec.length = bw;
|
||||
if (unpdbg_likely(pfile_pwrite(of->indexfile, &rec, sizeof(rec),
|
||||
if (pdbg_unlikely(pfile_pwrite(of->indexfile, &rec, sizeof(rec),
|
||||
sizeof(rec) * ioff +
|
||||
sizeof(psync_fs_index_header)) !=
|
||||
sizeof(rec)))
|
||||
|
|
@ -2462,7 +2462,7 @@ static int psync_fs_write(const char *path, const char *buf, size_t size,
|
|||
of = fh_to_openfile(fi->fh);
|
||||
psync_fs_lock_file(of);
|
||||
ret = psync_fs_check_write_space(of, size, offset);
|
||||
if (unpdbg_likely(ret <= 0))
|
||||
if (pdbg_unlikely(ret <= 0))
|
||||
return ret;
|
||||
psync_fs_inc_writeid_locked(of);
|
||||
retry:
|
||||
|
|
@ -2472,7 +2472,7 @@ retry:
|
|||
else
|
||||
ret = psync_fs_write_newfile(of, buf, size, offset);
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
if (unpdbg_likely(ret == -1))
|
||||
if (pdbg_unlikely(ret == -1))
|
||||
return -EIO;
|
||||
else
|
||||
return ret;
|
||||
|
|
@ -3540,7 +3540,7 @@ static void psync_usr1_handler(int sig) {
|
|||
static void psync_set_signal(int sig, void (*handler)(int)) {
|
||||
struct sigaction sa;
|
||||
|
||||
if (unpdbg_likely(sigaction(sig, NULL, &sa)))
|
||||
if (pdbg_unlikely(sigaction(sig, NULL, &sa)))
|
||||
return;
|
||||
|
||||
if (sa.sa_handler == SIG_DFL) {
|
||||
|
|
@ -3684,11 +3684,11 @@ static int psync_fs_do_start() {
|
|||
mp = psync_fuse_get_mountpoint();
|
||||
|
||||
psync_fuse_channel = fuse_mount(mp, &args);
|
||||
if (unpdbg_likely(!psync_fuse_channel))
|
||||
if (pdbg_unlikely(!psync_fuse_channel))
|
||||
goto err0;
|
||||
psync_fuse = fuse_new(psync_fuse_channel, &args, &psync_oper,
|
||||
sizeof(psync_oper), NULL);
|
||||
if (unpdbg_likely(!psync_fuse))
|
||||
if (pdbg_unlikely(!psync_fuse))
|
||||
goto err1;
|
||||
psync_current_mountpoint = mp;
|
||||
started = 1;
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ static int psync_fs_crypto_read_newfile_full_sector_from_log(
|
|||
(unsigned)hdr.length, (int)rd);
|
||||
return -EIO;
|
||||
}
|
||||
if (unpdbg_likely(pcrypto_decode_sec(
|
||||
if (pdbg_unlikely(pcrypto_decode_sec(
|
||||
of->encoder, buff, rd, (unsigned char *)buf, se->auth, se->sectorid)))
|
||||
return -EIO;
|
||||
else
|
||||
|
|
@ -301,7 +301,7 @@ psync_fs_crypto_do_local_tree_check(psync_openfile_t *of,
|
|||
// pdbg_logf(D_NOTICE, "reading first sector from offset %lu, size %u", (unsigned
|
||||
// long)off, (unsigned)ssize);
|
||||
rd = pfile_pread(of->datafile, buff, ssize, off);
|
||||
if (unpdbg_likely(rd != ssize))
|
||||
if (pdbg_unlikely(rd != ssize))
|
||||
return -1;
|
||||
pcrypto_sign_sec(of->encoder, buff, ssize, auth);
|
||||
level = 0;
|
||||
|
|
@ -319,7 +319,7 @@ psync_fs_crypto_do_local_tree_check(psync_openfile_t *of,
|
|||
ssize = PSYNC_CRYPTO_SECTOR_SIZE;
|
||||
}
|
||||
rd = pfile_pread(of->datafile, buff, ssize, off);
|
||||
if (unpdbg_likely(rd != ssize))
|
||||
if (pdbg_unlikely(rd != ssize))
|
||||
return -1;
|
||||
if (unlikely(memcmp(buff + authoff, auth, sizeof(auth)))) {
|
||||
pdbg_logf(D_WARNING,
|
||||
|
|
@ -396,7 +396,7 @@ static int psync_fs_crypto_read_newfile_full_sector_from_datafile(
|
|||
uint32_t ssize;
|
||||
// pdbg_logf(D_NOTICE, "reading sector %u", sectorid);
|
||||
fs = pfile_size(of->datafile);
|
||||
if (unpdbg_likely(fs == -1))
|
||||
if (pdbg_unlikely(fs == -1))
|
||||
return -EIO;
|
||||
psync_fs_crypto_offsets_by_cryptosize(fs, &offsets);
|
||||
if ((uint64_t)sectorid * PSYNC_CRYPTO_SECTOR_SIZE >= offsets.plainsize)
|
||||
|
|
@ -409,7 +409,7 @@ static int psync_fs_crypto_read_newfile_full_sector_from_datafile(
|
|||
off = psync_fs_crypto_data_offset_by_sectorid(sectorid);
|
||||
// pdbg_logf(D_NOTICE, "data offset=%lu", off);
|
||||
rd = pfile_pread(of->datafile, buff, ssize, off);
|
||||
if (unpdbg_likely(rd != ssize))
|
||||
if (pdbg_unlikely(rd != ssize))
|
||||
return -EIO;
|
||||
if (sectorid / PSYNC_CRYPTO_HASH_TREE_SECTORS ==
|
||||
get_last_sectorid_by_size(offsets.plainsize) /
|
||||
|
|
@ -421,9 +421,9 @@ static int psync_fs_crypto_read_newfile_full_sector_from_datafile(
|
|||
off += (sectorid % PSYNC_CRYPTO_HASH_TREE_SECTORS) * PSYNC_CRYPTO_AUTH_SIZE;
|
||||
// pdbg_logf(D_NOTICE, "auth offset=%lu", off);
|
||||
rd = pfile_pread(of->datafile, auth, sizeof(auth), off);
|
||||
if (unpdbg_likely(rd != sizeof(auth)))
|
||||
if (pdbg_unlikely(rd != sizeof(auth)))
|
||||
return -EIO;
|
||||
if (unpdbg_likely(pcrypto_decode_sec(
|
||||
if (pdbg_unlikely(pcrypto_decode_sec(
|
||||
of->encoder, buff, ssize, (unsigned char *)buf, auth, sectorid)))
|
||||
return -EIO;
|
||||
#if defined(PSYNC_DO_LOCAL_FULL_TREE_CHECK)
|
||||
|
|
@ -489,7 +489,7 @@ int pfscrypto_read_new(psync_openfile_t *of, char *buf,
|
|||
PSYNC_CRYPTO_MAX_SECTORID))
|
||||
return psync_fs_unlock_ret(of, -EINVAL);
|
||||
ret = psync_fs_crypto_wait_extender_after_locked(of, offset + size);
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return psync_fs_unlock_ret(of, ret);
|
||||
if (unlikely(!size || of->currentsize <= offset))
|
||||
return psync_fs_unlock_ret(of, 0);
|
||||
|
|
@ -645,7 +645,7 @@ static int psync_fs_crypto_switch_sectors(psync_openfile_t *of,
|
|||
}
|
||||
if (newsectorid != PSYNC_CRYPTO_INVALID_SECTORID) {
|
||||
filesize = pfile_size(of->datafile);
|
||||
if (unpdbg_likely(filesize == -1))
|
||||
if (pdbg_unlikely(filesize == -1))
|
||||
return -EIO;
|
||||
if (filesize > PSYNC_CRYPTO_AUTH_SIZE) {
|
||||
psync_fs_crypto_offsets_by_cryptosize(filesize, &ooffsets);
|
||||
|
|
@ -842,11 +842,11 @@ static int psync_fs_crypto_process_log(int lfd, int dfd,
|
|||
}
|
||||
size = mr->filesize;
|
||||
off = PSYNC_CRYPTO_SECTOR_SIZE;
|
||||
if (unpdbg_likely(pfile_seek(dfd, size, SEEK_SET) != size ||
|
||||
if (pdbg_unlikely(pfile_seek(dfd, size, SEEK_SET) != size ||
|
||||
pfile_truncate(dfd)))
|
||||
return -1;
|
||||
if (ifd != INVALID_HANDLE_VALUE &&
|
||||
unpdbg_likely(
|
||||
pdbg_unlikely(
|
||||
pfile_seek(ifd, sizeof(psync_fs_index_header), SEEK_SET) !=
|
||||
sizeof(psync_fs_index_header) ||
|
||||
pfile_truncate(ifd)))
|
||||
|
|
@ -855,7 +855,7 @@ static int psync_fs_crypto_process_log(int lfd, int dfd,
|
|||
recid = 0;
|
||||
ioff = 0;
|
||||
while ((rd = pfile_pread(lfd, &hdr, sizeof(hdr), off)) != 0) {
|
||||
if (unpdbg_likely(rd != sizeof(hdr)))
|
||||
if (pdbg_unlikely(rd != sizeof(hdr)))
|
||||
return -1;
|
||||
off += sizeof(hdr);
|
||||
if (hdr.type == PSYNC_CRYPTO_LOG_DATA) {
|
||||
|
|
@ -917,7 +917,7 @@ static int psync_fs_crypto_process_log(int lfd, int dfd,
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
if (unpdbg_likely(pfile_seek(dfd, size, SEEK_SET) != size ||
|
||||
if (pdbg_unlikely(pfile_seek(dfd, size, SEEK_SET) != size ||
|
||||
pfile_truncate(dfd)))
|
||||
return -1;
|
||||
return 0;
|
||||
|
|
@ -946,7 +946,7 @@ static int psync_fs_crypto_mark_log_finalized(psync_openfile_t *of,
|
|||
int64_t lsize;
|
||||
ssize_t wrt;
|
||||
lsize = pfile_size(of->logfile);
|
||||
if (unpdbg_likely(lsize == -1))
|
||||
if (pdbg_unlikely(lsize == -1))
|
||||
return -EIO;
|
||||
pdbg_assert(lsize == of->loghashctx.length + PSYNC_CRYPTO_SECTOR_SIZE);
|
||||
mr.status = PSYNC_LOG_STATUS_FINALIZED;
|
||||
|
|
@ -957,7 +957,7 @@ static int psync_fs_crypto_mark_log_finalized(psync_openfile_t *of,
|
|||
mr.crc = pcrc32c_compute(PSYNC_CRC_INITIAL, &mr,
|
||||
offsetof(psync_crypto_master_record, crc));
|
||||
wrt = pfile_pwrite(of->logfile, &mr, sizeof(mr), 0);
|
||||
if (unpdbg_likely(wrt != sizeof(mr)))
|
||||
if (pdbg_unlikely(wrt != sizeof(mr)))
|
||||
return -EIO;
|
||||
else
|
||||
return 0;
|
||||
|
|
@ -968,33 +968,33 @@ static int psync_fs_crypto_log_flush_and_process(psync_openfile_t *of,
|
|||
int dowaits, int locked) {
|
||||
int fd;
|
||||
fd = pfile_open(filename, O_RDWR, 0);
|
||||
if (unpdbg_likely(fd == INVALID_HANDLE_VALUE))
|
||||
if (pdbg_unlikely(fd == INVALID_HANDLE_VALUE))
|
||||
return -EIO;
|
||||
if (dowaits && !locked)
|
||||
wait_before_flush(of, 2000);
|
||||
pdbg_logf(D_NOTICE, "flushing log data %s", filename);
|
||||
if (unpdbg_likely(pfile_sync(fd)))
|
||||
if (pdbg_unlikely(pfile_sync(fd)))
|
||||
goto err_eio;
|
||||
pdbg_logf(D_NOTICE, "flushed log data %s", filename);
|
||||
/* flushing directory does not seem to work on either Windows on Mac, disable
|
||||
for now, maybe look at SQLite code to see if they flush if
|
||||
(unpdbg_likely(psync_fs_flush_cache_dir())) goto err_eio;
|
||||
(pdbg_unlikely(psync_fs_flush_cache_dir())) goto err_eio;
|
||||
*/
|
||||
|
||||
// pdbg_assert(NULL=="break here to test log replay");
|
||||
if (unpdbg_likely(
|
||||
if (pdbg_unlikely(
|
||||
psync_fs_crypto_process_log(fd, of->datafile, of->indexfile, 0)))
|
||||
goto err_eio;
|
||||
pfile_close(fd);
|
||||
if (dowaits && !locked)
|
||||
wait_before_flush(of, 2000);
|
||||
pdbg_logf(D_NOTICE, "flushing data of %s", of->currentname);
|
||||
if (unpdbg_likely(pfile_sync(of->datafile)))
|
||||
if (pdbg_unlikely(pfile_sync(of->datafile)))
|
||||
return -EIO;
|
||||
pdbg_logf(D_NOTICE, "flushed data of %s", of->currentname);
|
||||
if (!of->newfile) {
|
||||
pdbg_logf(D_NOTICE, "flushing index of %s", of->currentname);
|
||||
if (unpdbg_likely(pfile_sync(of->indexfile)))
|
||||
if (pdbg_unlikely(pfile_sync(of->indexfile)))
|
||||
return -EIO;
|
||||
pdbg_logf(D_NOTICE, "flushed index of %s", of->currentname);
|
||||
}
|
||||
|
|
@ -1066,25 +1066,25 @@ static int psync_fs_crypto_do_finalize_log(psync_openfile_t *of, int fullsync) {
|
|||
(unsigned long)of->currentsize);
|
||||
pfscrypto_offset_by_size(of->currentsize, &offsets);
|
||||
ret = psync_fs_write_auth_tree_to_log(of, &offsets);
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return ret;
|
||||
pdbg_logf(D_NOTICE, "wrote checksums to log of %s", of->currentname);
|
||||
if (!of->newfile) {
|
||||
pdbg_logf(D_NOTICE, "writing interval tree to log of %s", of->currentname);
|
||||
ret = psync_fs_write_interval_tree_to_log(of);
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return ret;
|
||||
pdbg_logf(D_NOTICE, "wrote interval tree to log of %s", of->currentname);
|
||||
}
|
||||
ret = psync_fs_crypto_mark_log_finalized(
|
||||
of, offsets.masterauthoff +
|
||||
(offsets.needmasterauth ? PSYNC_CRYPTO_AUTH_SIZE : 0));
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return ret;
|
||||
pfile_schedulesync(of->logfile);
|
||||
ret = pfile_close(of->logfile);
|
||||
of->logfile = INVALID_HANDLE_VALUE;
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return -EIO;
|
||||
pdbg_logf(D_NOTICE, "finalized log of %s", of->currentname);
|
||||
cachepath = psync_setting_get_string(_PS(fscachepath));
|
||||
|
|
@ -1095,11 +1095,11 @@ static int psync_fs_crypto_do_finalize_log(psync_openfile_t *of, int fullsync) {
|
|||
olog = psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'f';
|
||||
flog = psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
if (unpdbg_likely(pfile_rename_overwrite(olog, flog)) ||
|
||||
unpdbg_likely((of->logfile = pfile_open(olog, O_RDWR,
|
||||
if (pdbg_unlikely(pfile_rename_overwrite(olog, flog)) ||
|
||||
pdbg_unlikely((of->logfile = pfile_open(olog, O_RDWR,
|
||||
O_CREAT | O_TRUNC)) ==
|
||||
INVALID_HANDLE_VALUE) ||
|
||||
unpdbg_likely(pfscrypto_init_log(of))) {
|
||||
pdbg_unlikely(pfscrypto_init_log(of))) {
|
||||
free(olog);
|
||||
free(flog);
|
||||
return -EIO;
|
||||
|
|
@ -1287,7 +1287,7 @@ static int pfscrypto_write_new_nu(psync_openfile_t *of,
|
|||
return 0;
|
||||
if (checkextender) {
|
||||
ret = psync_fs_crypto_wait_extender_after_locked(of, offset + size);
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return ret;
|
||||
}
|
||||
if (unlikely(of->currentsize < offset)) {
|
||||
|
|
@ -1440,7 +1440,7 @@ int pfscrypto_read_mod(psync_openfile_t *of, char *buf,
|
|||
rd = size;
|
||||
rfr = psync_fs_crypto_read_newfile_partial_sector(of, buf, sectorid, rd,
|
||||
offmod);
|
||||
if (unpdbg_likely(rfr != rd))
|
||||
if (pdbg_unlikely(rfr != rd))
|
||||
psync_fs_unlock_ret(of, rfr);
|
||||
} else {
|
||||
bufoff =
|
||||
|
|
@ -1455,7 +1455,7 @@ int pfscrypto_read_mod(psync_openfile_t *of, char *buf,
|
|||
else
|
||||
rfr = psync_fs_crypto_read_newfile_partial_sector(of, bufoff, sectorid,
|
||||
rd, 0);
|
||||
if (unpdbg_likely(rfr != rd))
|
||||
if (pdbg_unlikely(rfr != rd))
|
||||
psync_fs_unlock_ret(of, rfr);
|
||||
}
|
||||
}
|
||||
|
|
@ -1516,7 +1516,7 @@ int pfscrypto_write_mod_nu(psync_openfile_t *of,
|
|||
return -EINVAL;
|
||||
if (checkextender) {
|
||||
ret = psync_fs_crypto_wait_extender_after_locked(of, offset + size);
|
||||
if (unpdbg_likely(ret))
|
||||
if (pdbg_unlikely(ret))
|
||||
return ret;
|
||||
}
|
||||
if (unlikely(!size))
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ int psync_fstask_mkdir(psync_fsfolderid_t folderid, const char *name,
|
|||
} else
|
||||
depend = 0;
|
||||
depend += psync_fstask_depend_on_name(taskid, folderid, name, len);
|
||||
if (unpdbg_likely(psync_sql_commit_transaction())) {
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction())) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
return -EIO;
|
||||
}
|
||||
|
|
@ -650,7 +650,7 @@ int psync_fstask_rmdir(psync_fsfolderid_t folderid, uint32_t parentflags,
|
|||
}
|
||||
psync_sql_free_result(res);
|
||||
psync_fstask_depend_on_name(taskid, folderid, name, len);
|
||||
if (unpdbg_likely(psync_sql_commit_transaction())) {
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction())) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
return -EIO;
|
||||
}
|
||||
|
|
@ -699,7 +699,7 @@ psync_fstask_creat_t *psync_fstask_add_creat(psync_fstask_folder_t *folder,
|
|||
if (folder->folderid < 0)
|
||||
psync_fstask_depend(taskid, -folder->folderid);
|
||||
psync_fstask_depend_on_name(taskid, folder->folderid, name, len);
|
||||
if (unpdbg_likely(psync_sql_commit_transaction()))
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction()))
|
||||
return NULL;
|
||||
len++;
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
|
|
@ -774,7 +774,7 @@ psync_fstask_add_modified_file(psync_fstask_folder_t *folder, const char *name,
|
|||
free(task);
|
||||
folder->taskscnt--;
|
||||
}
|
||||
if (unpdbg_likely(psync_sql_commit_transaction()))
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction()))
|
||||
return NULL;
|
||||
len++;
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
|
|
@ -820,7 +820,7 @@ int psync_fstask_set_mtime(psync_fileid_t fileid, uint64_t oldtm,
|
|||
psync_sql_bind_int(res, 3, oldtm);
|
||||
psync_sql_bind_int(res, 4, newtm);
|
||||
psync_sql_run_free(res);
|
||||
if (unpdbg_likely(psync_sql_commit_transaction()))
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction()))
|
||||
return -EIO;
|
||||
psync_fsupload_wake();
|
||||
return 0;
|
||||
|
|
@ -1068,7 +1068,7 @@ int psync_fstask_unlink(psync_fsfolderid_t folderid, const char *name) {
|
|||
if (fileid < 0 && -fileid != depend)
|
||||
psync_fstask_depend(taskid, -fileid);
|
||||
psync_fstask_depend_on_name(taskid, folderid, name, len);
|
||||
if (unpdbg_likely(psync_sql_commit_transaction())) {
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction())) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
return -EIO;
|
||||
}
|
||||
|
|
@ -1163,7 +1163,7 @@ int psync_fstask_rename_file(psync_fsfileid_t fileid,
|
|||
psync_fstask_depend_on_name(ttaskid, to_folderid, new_name, nnlen);
|
||||
if (cr)
|
||||
psync_fstask_depend(ttaskid, cr->taskid);
|
||||
if (unpdbg_likely(psync_sql_commit_transaction())) {
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction())) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
return -EIO;
|
||||
}
|
||||
|
|
@ -1387,7 +1387,7 @@ int psync_fstask_rename_folder(psync_fsfolderid_t folderid,
|
|||
if (mk)
|
||||
psync_fstask_depend(ttaskid, mk->taskid);
|
||||
|
||||
if (unpdbg_likely(psync_sql_commit_transaction())) {
|
||||
if (pdbg_unlikely(psync_sql_commit_transaction())) {
|
||||
psync_fstask_release_folder_tasks_locked(folder);
|
||||
return -EIO;
|
||||
}
|
||||
|
|
@ -1490,7 +1490,7 @@ void psync_fstask_folder_created(psync_folderid_t parentfolderid,
|
|||
res = psync_sql_query("SELECT sfolderid FROM fstask WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, taskid);
|
||||
row = psync_sql_fetch_rowint(res);
|
||||
if (unpdbg_likely(!row))
|
||||
if (pdbg_unlikely(!row))
|
||||
psync_sql_free_result(res);
|
||||
else {
|
||||
sfolderid = row[0];
|
||||
|
|
@ -1552,7 +1552,7 @@ static void psync_fstask_look_for_creat_in_db(psync_folderid_t parentfolderid,
|
|||
res = psync_sql_query("SELECT sfolderid FROM fstask WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, taskid);
|
||||
row = psync_sql_fetch_rowint(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
psync_sql_free_result(res);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,13 +270,13 @@ static int psync_send_task_creat_upload_small(psock_t *api,
|
|||
#endif
|
||||
data = papi_prepare_alloc("uploadfile", params, size, size, &len);
|
||||
}
|
||||
if (unpdbg_likely(pfile_read(fd, data + len, size) != size) ||
|
||||
unpdbg_likely(psync_fs_get_file_writeid(task->id) != task->int1)) {
|
||||
if (pdbg_unlikely(pfile_read(fd, data + len, size) != size) ||
|
||||
pdbg_unlikely(psync_fs_get_file_writeid(task->id) != task->int1)) {
|
||||
free(data);
|
||||
return -1;
|
||||
}
|
||||
size += len;
|
||||
if (unpdbg_likely(psync_socket_writeall_upload(api, data, size) != size)) {
|
||||
if (pdbg_unlikely(psync_socket_writeall_upload(api, data, size) != size)) {
|
||||
free(data);
|
||||
return -1;
|
||||
} else {
|
||||
|
|
@ -291,7 +291,7 @@ static int large_upload_creat_send_write(psock_t *api,
|
|||
binparam params[] = {PAPI_STR("auth", psync_my_auth),
|
||||
PAPI_NUM("uploadoffset", offset),
|
||||
PAPI_NUM("uploadid", uploadid)};
|
||||
if (unpdbg_likely(!papi_send(api, "upload_write", strlen("upload_write"),
|
||||
if (pdbg_unlikely(!papi_send(api, "upload_write", strlen("upload_write"),
|
||||
params, ARRAY_SIZE(params), length, 0)))
|
||||
return -1;
|
||||
else
|
||||
|
|
@ -333,7 +333,7 @@ static int large_upload_check_checksum(psock_t *api, uint64_t uploadid,
|
|||
binresult *res;
|
||||
uint64_t result;
|
||||
res = papi_send2(api, "upload_info", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -567,7 +567,7 @@ static int large_upload_save(psock_t *api, uint64_t uploadid,
|
|||
#endif
|
||||
res = papi_send2(api, "upload_save", params);
|
||||
}
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -787,11 +787,11 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
psync_sql_run_free(sql);
|
||||
}
|
||||
fd = pfile_open(filename, O_RDONLY, 0);
|
||||
if (unpdbg_likely(fd == INVALID_HANDLE_VALUE))
|
||||
if (pdbg_unlikely(fd == INVALID_HANDLE_VALUE))
|
||||
goto ret0;
|
||||
if (usize) {
|
||||
pdbg_logf(D_NOTICE, "resuming from offset %lu", (unsigned long)usize);
|
||||
if (unpdbg_likely(pfile_seek(fd, usize, SEEK_SET) == -1))
|
||||
if (pdbg_unlikely(pfile_seek(fd, usize, SEEK_SET) == -1))
|
||||
goto ret01;
|
||||
}
|
||||
if (large_upload_creat_send_write(api, uploadid, usize, fsize - usize))
|
||||
|
|
@ -812,10 +812,10 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
else
|
||||
rd = fsize - usize;
|
||||
rrd = pfile_read(fd, buff, rd);
|
||||
if (unpdbg_likely(rrd <= 0))
|
||||
if (pdbg_unlikely(rrd <= 0))
|
||||
goto err2;
|
||||
usize += rrd;
|
||||
if (unpdbg_likely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
if (pdbg_unlikely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
goto err2;
|
||||
asize += rrd;
|
||||
pupload_bytes_add(rrd);
|
||||
|
|
@ -823,7 +823,7 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
free(buff);
|
||||
pfile_close(fd);
|
||||
res = papi_result(api);
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
goto err0;
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
free(res);
|
||||
|
|
@ -896,7 +896,7 @@ static int upload_modify_send_copy_from(psock_t *api,
|
|||
pdbg_logf(D_NOTICE, "copying %lu bytes from fileid %lu hash %lu at offset %lu",
|
||||
(unsigned long)length, (unsigned long)fileid, (unsigned long)hash,
|
||||
(unsigned long)offset);
|
||||
if (unpdbg_likely(!papi_send_no_res(api, "upload_writefromfile", params)))
|
||||
if (pdbg_unlikely(!papi_send_no_res(api, "upload_writefromfile", params)))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
else {
|
||||
*upl += length;
|
||||
|
|
@ -918,8 +918,8 @@ static int upload_modify_send_local(psock_t *api,
|
|||
ssize_t rrd;
|
||||
pdbg_logf(D_NOTICE, "uploading %lu byte from local file at offset %lu",
|
||||
(unsigned long)length, (unsigned long)offset);
|
||||
if (unpdbg_likely(pfile_seek(fd, offset, SEEK_SET) == -1) ||
|
||||
unpdbg_likely(!papi_send(api, "upload_write", strlen("upload_write"),
|
||||
if (pdbg_unlikely(pfile_seek(fd, offset, SEEK_SET) == -1) ||
|
||||
pdbg_unlikely(!papi_send(api, "upload_write", strlen("upload_write"),
|
||||
params, ARRAY_SIZE(params), length, 0)))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
bw = 0;
|
||||
|
|
@ -936,14 +936,14 @@ static int upload_modify_send_local(psock_t *api,
|
|||
else
|
||||
rd = length - bw;
|
||||
rrd = pfile_read(fd, buff, rd);
|
||||
if (unpdbg_likely(rrd <= 0)) {
|
||||
if (pdbg_unlikely(rrd <= 0)) {
|
||||
if (rrd == 0)
|
||||
goto errp;
|
||||
else
|
||||
goto err0;
|
||||
}
|
||||
bw += rrd;
|
||||
if (unpdbg_likely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
if (pdbg_unlikely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
goto err0;
|
||||
*upl += rrd;
|
||||
pupload_bytes_add(rrd);
|
||||
|
|
@ -1005,7 +1005,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
return -1;
|
||||
}
|
||||
tree = NULL;
|
||||
if (unpdbg_likely((fsize = pfile_size(fd)) == -1 ||
|
||||
if (pdbg_unlikely((fsize = pfile_size(fd)) == -1 ||
|
||||
psync_fs_load_interval_tree(fd, fsize, &tree) == -1)) {
|
||||
psync_interval_tree_free(tree);
|
||||
pfile_close(fd);
|
||||
|
|
@ -1013,12 +1013,12 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
}
|
||||
pfile_close(fd);
|
||||
api = psync_apipool_get();
|
||||
if (unpdbg_likely(!api))
|
||||
if (pdbg_unlikely(!api))
|
||||
goto err1;
|
||||
if (unpdbg_likely(clean_uploads_for_task(api, taskid)))
|
||||
if (pdbg_unlikely(clean_uploads_for_task(api, taskid)))
|
||||
goto err2;
|
||||
res = papi_send2(api, "upload_create", aparams);
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
goto err2;
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
|
|
@ -1052,7 +1052,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
return -1;
|
||||
}
|
||||
fsize = pfile_size(fd);
|
||||
if (unpdbg_likely(fsize == -1))
|
||||
if (pdbg_unlikely(fsize == -1))
|
||||
goto err3;
|
||||
pdbg_logf(D_NOTICE, "file size=%lu", (unsigned long)fsize);
|
||||
coff = 0;
|
||||
|
|
@ -1065,7 +1065,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
? PSYNC_SOCK_READ_TIMEOUT * 1000
|
||||
: 0) != SOCKET_ERROR)) {
|
||||
if ((ret = upload_modify_read_req(api))) {
|
||||
if (unpdbg_likely(ret == PSYNC_NET_PERMFAIL))
|
||||
if (pdbg_unlikely(ret == PSYNC_NET_PERMFAIL))
|
||||
perm_fail_upload_task(taskid);
|
||||
goto err3;
|
||||
} else
|
||||
|
|
@ -1098,7 +1098,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
coff += len;
|
||||
}
|
||||
if (ret) {
|
||||
if (unpdbg_likely(ret == PSYNC_NET_PERMFAIL))
|
||||
if (pdbg_unlikely(ret == PSYNC_NET_PERMFAIL))
|
||||
perm_fail_upload_task(taskid);
|
||||
goto err3;
|
||||
}
|
||||
|
|
@ -1110,7 +1110,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
pfile_close(fd);
|
||||
while (reqs--)
|
||||
if ((ret = upload_modify_read_req(api))) {
|
||||
if (unpdbg_likely(ret == PSYNC_NET_PERMFAIL))
|
||||
if (pdbg_unlikely(ret == PSYNC_NET_PERMFAIL))
|
||||
perm_fail_upload_task(taskid);
|
||||
goto err2;
|
||||
}
|
||||
|
|
@ -1306,8 +1306,8 @@ static int psync_send_task_creat(psock_t *api, fsupload_task_t *task) {
|
|||
"/", fileidhex, NULL);
|
||||
fd = pfile_open(filename, O_RDONLY, 0);
|
||||
free(filename);
|
||||
if (unpdbg_likely(fd == INVALID_HANDLE_VALUE) ||
|
||||
unpdbg_likely(fstat(fd, &st))) {
|
||||
if (pdbg_unlikely(fd == INVALID_HANDLE_VALUE) ||
|
||||
pdbg_unlikely(fstat(fd, &st))) {
|
||||
if (fd != INVALID_HANDLE_VALUE)
|
||||
pfile_close(fd);
|
||||
perm_fail_upload_task(task->id);
|
||||
|
|
@ -1747,7 +1747,7 @@ static int psync_cancel_task_modify(fsupload_task_t *task) {
|
|||
static int psync_cancel_task_unlink(fsupload_task_t *task) {
|
||||
psync_sql_res *res;
|
||||
// psync_uint_row row;
|
||||
if (unpdbg_likely((psync_fsfileid_t)task->fileid > 0)) {
|
||||
if (pdbg_unlikely((psync_fsfileid_t)task->fileid > 0)) {
|
||||
res = psync_sql_prep_statement("UPDATE fstask SET status=0 WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, task->id);
|
||||
upload_wakes++;
|
||||
|
|
@ -1974,7 +1974,7 @@ static void psync_fsupload_run_tasks(psync_list *tasks) {
|
|||
continue;
|
||||
}
|
||||
while (papi_result_async(api, &reader) == ASYNC_RES_READY) {
|
||||
if (unpdbg_likely(!reader.result))
|
||||
if (pdbg_unlikely(!reader.result))
|
||||
goto err0;
|
||||
while (rtask->needprocessing) {
|
||||
rtask = psync_list_element(rtask->list.next, fsupload_task_t, list);
|
||||
|
|
@ -1987,7 +1987,7 @@ static void psync_fsupload_run_tasks(psync_list *tasks) {
|
|||
while (rtask != task) {
|
||||
if (!rtask->needprocessing) {
|
||||
rtask->res = papi_result(api);
|
||||
if (unpdbg_likely(!rtask->res))
|
||||
if (pdbg_unlikely(!rtask->res))
|
||||
goto err0;
|
||||
}
|
||||
rtask = psync_list_element(rtask->list.next, fsupload_task_t, list);
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ int psync_slprintf(char *str, size_t size, const char *format, ...) {
|
|||
va_start(ap, format);
|
||||
ret = vsnprintf(str, size, format, ap);
|
||||
va_end(ap);
|
||||
if (unpdbg_likely(ret >= size))
|
||||
if (pdbg_unlikely(ret >= size))
|
||||
str[size - 1] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,13 +152,13 @@ static void add_syncid(psync_syncid_t syncid) {
|
|||
}
|
||||
dir->syncid = syncid;
|
||||
dir->inotifyfd = inotify_init();
|
||||
if (unpdbg_likely(dir->inotifyfd == -1))
|
||||
if (pdbg_unlikely(dir->inotifyfd == -1))
|
||||
goto err;
|
||||
memset(dir->watches, 0, sizeof(dir->watches));
|
||||
add_dir_scan(dir, dir->path);
|
||||
e.events = EPOLLIN;
|
||||
e.data.ptr = dir;
|
||||
if (unpdbg_likely(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, dir->inotifyfd, &e)))
|
||||
if (pdbg_unlikely(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, dir->inotifyfd, &e)))
|
||||
goto err2;
|
||||
psync_list_add_tail(&dirs, &dir->list);
|
||||
return;
|
||||
|
|
@ -279,16 +279,16 @@ static void psync_localnotify_thread() {
|
|||
int psync_localnotify_init() {
|
||||
struct epoll_event e;
|
||||
int pfd[2];
|
||||
if (unpdbg_likely(pipe(pfd)))
|
||||
if (pdbg_unlikely(pipe(pfd)))
|
||||
goto err0;
|
||||
pipe_read = pfd[0];
|
||||
pipe_write = pfd[1];
|
||||
epoll_fd = epoll_create(1);
|
||||
if (unpdbg_likely(epoll_fd == -1))
|
||||
if (pdbg_unlikely(epoll_fd == -1))
|
||||
goto err1;
|
||||
e.events = EPOLLIN;
|
||||
e.data.ptr = NULL;
|
||||
if (unpdbg_likely(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, pipe_read, &e)))
|
||||
if (pdbg_unlikely(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, pipe_read, &e)))
|
||||
goto err2;
|
||||
prun_thread("localnotify", psync_localnotify_thread);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ scanner_scan_folder(const char *localpath, psync_folderid_t folderid,
|
|||
char *subpath;
|
||||
int cmp;
|
||||
// pdbg_logf(D_NOTICE, "scanning folder %s deviceid: %llu", localpath, deviceid);
|
||||
if (unpdbg_likely(scanner_local_folder_to_list(localpath, &disklist))) {
|
||||
if (pdbg_unlikely(scanner_local_folder_to_list(localpath, &disklist))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ static void scan_upload_file(sync_folderlist *fl) {
|
|||
psync_sql_bind_uint(res, 6, fl->mtimenat);
|
||||
psync_sql_bind_string(res, 7, fl->name);
|
||||
psync_sql_run_free(res);
|
||||
if (unpdbg_likely(!psync_sql_affected_rows()))
|
||||
if (pdbg_unlikely(!psync_sql_affected_rows()))
|
||||
return;
|
||||
localfileid = psync_sql_insertid();
|
||||
ptask_upload_q(fl->syncid, localfileid, fl->name);
|
||||
|
|
@ -793,7 +793,7 @@ static void scan_create_folder(sync_folderlist *fl) {
|
|||
psync_sql_bind_uint(res, 2, localfolderid);
|
||||
psync_sql_bind_uint(res, 3, fl->synctype);
|
||||
psync_sql_run_free(res);
|
||||
if (unpdbg_likely(!psync_sql_affected_rows()))
|
||||
if (pdbg_unlikely(!psync_sql_affected_rows()))
|
||||
return;
|
||||
ptask_rdir_mk(fl->syncid, localfolderid, fl->name);
|
||||
return;
|
||||
|
|
@ -931,7 +931,7 @@ retry:
|
|||
return;
|
||||
}
|
||||
psync_sql_free_result(res);
|
||||
if (unpdbg_likely(!folderid)) {
|
||||
if (pdbg_unlikely(!folderid)) {
|
||||
/* folder is not yet created, folderid is not 0 but NULL actually */
|
||||
if (tries >= 50) {
|
||||
res = psync_sql_query("DELETE FROM task WHERE type=" NTO_STR(
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ static void psync_ret_api(void *ptr) {
|
|||
}
|
||||
|
||||
static int api_sock_is_broken(psock_t *ret) {
|
||||
if (unpdbg_likely(psock_is_broken(ret->sock) ||
|
||||
if (pdbg_unlikely(psock_is_broken(ret->sock) ||
|
||||
psock_is_ssl(ret) !=
|
||||
psync_setting_get_bool(_PS(usessl)))) {
|
||||
pdbg_logf(D_NOTICE, "got broken socket from cache");
|
||||
|
|
@ -194,7 +194,7 @@ psock_t *psync_apipool_get() {
|
|||
return ret;
|
||||
}
|
||||
ret = psync_get_api();
|
||||
if (unpdbg_likely(!ret))
|
||||
if (pdbg_unlikely(!ret))
|
||||
ptimer_notify_exception();
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ void psync_apipool_prepare() {
|
|||
else {
|
||||
psock_t *ret;
|
||||
ret = psync_get_api();
|
||||
if (unpdbg_likely(!ret))
|
||||
if (pdbg_unlikely(!ret))
|
||||
ptimer_notify_exception();
|
||||
else {
|
||||
pdbg_logf(D_NOTICE, "prepared api connection");
|
||||
|
|
@ -482,7 +482,7 @@ int psync_get_local_file_checksum(const char *restrict filename,
|
|||
return PSYNC_NET_PERMFAIL;
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
retry:
|
||||
if (unpdbg_likely(fstat(fd, &st)))
|
||||
if (pdbg_unlikely(fstat(fd, &st)))
|
||||
goto err1;
|
||||
psync_hash_init(&hctx);
|
||||
rsz = pfile_stat_size(&st);
|
||||
|
|
@ -510,7 +510,7 @@ retry:
|
|||
if (++cnt % 16 == 0)
|
||||
psys_sleep_milliseconds(5);
|
||||
}
|
||||
if (unpdbg_likely(fstat(fd, &st2)))
|
||||
if (pdbg_unlikely(fstat(fd, &st2)))
|
||||
goto err1;
|
||||
if (unlikely(file_changed(&st, &st2))) {
|
||||
pdbg_logf(D_NOTICE, "file %s changed while calculating checksum, restarting",
|
||||
|
|
@ -550,7 +550,7 @@ int psync_get_local_file_checksum_part(const char *restrict filename,
|
|||
fd = pfile_open(filename, O_RDONLY, 0);
|
||||
if (fd == INVALID_HANDLE_VALUE)
|
||||
return PSYNC_NET_PERMFAIL;
|
||||
if (unpdbg_likely(fstat(fd, &st)))
|
||||
if (pdbg_unlikely(fstat(fd, &st)))
|
||||
goto err1;
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
psync_hash_init(&hctx);
|
||||
|
|
@ -628,12 +628,12 @@ int psync_copy_local_file_if_checksum_matches(const char *source,
|
|||
unsigned char hashbin[PSYNC_HASH_DIGEST_LEN];
|
||||
char hashhex[PSYNC_HASH_DIGEST_HEXLEN];
|
||||
sfd = pfile_open(source, O_RDONLY, 0);
|
||||
if (unpdbg_likely(sfd == INVALID_HANDLE_VALUE))
|
||||
if (pdbg_unlikely(sfd == INVALID_HANDLE_VALUE))
|
||||
goto err0;
|
||||
if (unpdbg_likely(pfile_size(sfd) != fsize))
|
||||
if (pdbg_unlikely(pfile_size(sfd) != fsize))
|
||||
goto err1;
|
||||
dfd = pfile_open(destination, O_WRONLY, O_CREAT | O_TRUNC);
|
||||
if (unpdbg_likely(dfd == INVALID_HANDLE_VALUE))
|
||||
if (pdbg_unlikely(dfd == INVALID_HANDLE_VALUE))
|
||||
goto err1;
|
||||
psync_hash_init(&hctx);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
|
|
@ -643,9 +643,9 @@ int psync_copy_local_file_if_checksum_matches(const char *source,
|
|||
else
|
||||
rrd = fsize;
|
||||
rd = pfile_read(sfd, buff, rrd);
|
||||
if (unpdbg_likely(rd <= 0))
|
||||
if (pdbg_unlikely(rd <= 0))
|
||||
goto err2;
|
||||
if (unpdbg_likely(psync_file_writeall_checkoverquota(dfd, buff, rd)))
|
||||
if (pdbg_unlikely(psync_file_writeall_checkoverquota(dfd, buff, rd)))
|
||||
goto err2;
|
||||
sched_yield();
|
||||
psync_hash_update(&hctx, buff, rd);
|
||||
|
|
@ -653,11 +653,11 @@ int psync_copy_local_file_if_checksum_matches(const char *source,
|
|||
}
|
||||
psync_hash_final(hashbin, &hctx);
|
||||
psync_binhex(hashhex, hashbin, PSYNC_HASH_DIGEST_LEN);
|
||||
if (unpdbg_likely(memcmp(hexsum, hashhex, PSYNC_HASH_DIGEST_HEXLEN)) ||
|
||||
unpdbg_likely(pfile_sync(dfd)))
|
||||
if (pdbg_unlikely(memcmp(hexsum, hashhex, PSYNC_HASH_DIGEST_HEXLEN)) ||
|
||||
pdbg_unlikely(pfile_sync(dfd)))
|
||||
goto err2;
|
||||
free(buff);
|
||||
if (unpdbg_likely(pfile_close(dfd)))
|
||||
if (pdbg_unlikely(pfile_close(dfd)))
|
||||
goto err1;
|
||||
pfile_close(sfd);
|
||||
return PSYNC_NET_OK;
|
||||
|
|
@ -1286,7 +1286,7 @@ psync_http_socket *psync_http_connect_multihost(const binresult *hosts,
|
|||
cachekey[sizeof(cachekey) - 1] = 0;
|
||||
sock = (psock_t *)pcache_get(cachekey);
|
||||
if (sock) {
|
||||
if (unpdbg_likely(psock_is_broken(sock->sock))) {
|
||||
if (pdbg_unlikely(psock_is_broken(sock->sock))) {
|
||||
psock_close_bad(sock);
|
||||
sock = NULL;
|
||||
} else {
|
||||
|
|
@ -1357,7 +1357,7 @@ psync_http_connect_multihost_from_cache(const binresult *hosts,
|
|||
cachekey[sizeof(cachekey) - 1] = 0;
|
||||
sock = (psock_t *)pcache_get(cachekey);
|
||||
if (sock) {
|
||||
if (unpdbg_likely(psock_is_broken(sock->sock))) {
|
||||
if (pdbg_unlikely(psock_is_broken(sock->sock))) {
|
||||
psock_close_bad(sock);
|
||||
sock = NULL;
|
||||
} else {
|
||||
|
|
@ -1445,20 +1445,20 @@ int psync_http_next_request(psync_http_socket *sock) {
|
|||
ptr++;
|
||||
while (*ptr && isspace(*ptr))
|
||||
ptr++;
|
||||
if (unpdbg_likely(!isdigit(*ptr))) {
|
||||
if (pdbg_unlikely(!isdigit(*ptr))) {
|
||||
pdbg_logf(D_NOTICE, "got %s", sock->readbuff);
|
||||
goto err0;
|
||||
}
|
||||
rl = atoi(ptr);
|
||||
if (unpdbg_likely(rl / 10 != 20)) {
|
||||
if (unpdbg_likely(rl == 0))
|
||||
if (pdbg_unlikely(rl / 10 != 20)) {
|
||||
if (pdbg_unlikely(rl == 0))
|
||||
return -1;
|
||||
else
|
||||
return rl;
|
||||
}
|
||||
while (*ptr && *ptr != '\012')
|
||||
ptr++;
|
||||
if (unpdbg_likely(!*ptr))
|
||||
if (pdbg_unlikely(!*ptr))
|
||||
goto err0;
|
||||
ptr++;
|
||||
end = sock->readbuff + rb;
|
||||
|
|
@ -1497,11 +1497,11 @@ cont:
|
|||
*ptr = tolower(ch);
|
||||
lch = ch;
|
||||
}
|
||||
if (unpdbg_likely(rb == PSYNC_HTTP_RESP_BUFFER))
|
||||
if (pdbg_unlikely(rb == PSYNC_HTTP_RESP_BUFFER))
|
||||
goto err0;
|
||||
rl = psock_read(sock->sock, sock->readbuff + rb,
|
||||
PSYNC_HTTP_RESP_BUFFER - rb);
|
||||
if (unpdbg_likely(rl <= 0))
|
||||
if (pdbg_unlikely(rl <= 0))
|
||||
goto err0;
|
||||
rb += rl;
|
||||
end = sock->readbuff + rb;
|
||||
|
|
@ -1611,7 +1611,7 @@ static int psync_net_get_checksums(psock_t *api, psync_fileid_t fileid,
|
|||
else
|
||||
psync_apipool_release_bad(api);
|
||||
}
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
ptimer_notify_exception();
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
}
|
||||
|
|
@ -1631,9 +1631,9 @@ static int psync_net_get_checksums(psock_t *api, psync_fileid_t fileid,
|
|||
cookie)))
|
||||
break;
|
||||
free(res);
|
||||
if (unpdbg_likely(!http))
|
||||
if (pdbg_unlikely(!http))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
if (unpdbg_likely(psync_http_readall(http, &hdr, sizeof(hdr)) != sizeof(hdr)))
|
||||
if (pdbg_unlikely(psync_http_readall(http, &hdr, sizeof(hdr)) != sizeof(hdr)))
|
||||
goto err0;
|
||||
i = (hdr.filesize + (uint64_t)hdr.blocksize - 1) / (uint64_t)hdr.blocksize;
|
||||
if ((sizeof(psync_block_checksum) + sizeof(uint32_t)) * i >=
|
||||
|
|
@ -1653,7 +1653,7 @@ static int psync_net_get_checksums(psock_t *api, psync_fileid_t fileid,
|
|||
cs->next =
|
||||
(uint32_t *)(((char *)cs) + offsetof(psync_file_checksums, blocks) +
|
||||
sizeof(psync_block_checksum) * i);
|
||||
if (unpdbg_likely(psync_http_readall(http, cs->blocks,
|
||||
if (pdbg_unlikely(psync_http_readall(http, cs->blocks,
|
||||
sizeof(psync_block_checksum) * i) !=
|
||||
sizeof(psync_block_checksum) * i))
|
||||
goto err1;
|
||||
|
|
@ -1681,7 +1681,7 @@ static int psync_net_get_upload_checksums(psock_t *api,
|
|||
uint32_t i;
|
||||
*checksums = NULL;
|
||||
res = papi_send2(api, "upload_blockchecksums", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
ptimer_notify_exception();
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
}
|
||||
|
|
@ -1693,7 +1693,7 @@ static int psync_net_get_upload_checksums(psock_t *api,
|
|||
return psync_handle_api_result(result);
|
||||
}
|
||||
free(res);
|
||||
if (unpdbg_likely(psync_socket_readall_download(api, &hdr, sizeof(hdr)) !=
|
||||
if (pdbg_unlikely(psync_socket_readall_download(api, &hdr, sizeof(hdr)) !=
|
||||
sizeof(hdr)))
|
||||
goto err0;
|
||||
i = (hdr.filesize + hdr.blocksize - 1) / hdr.blocksize;
|
||||
|
|
@ -1717,7 +1717,7 @@ static int psync_net_get_upload_checksums(psock_t *api,
|
|||
cs->next =
|
||||
(uint32_t *)(((char *)cs) + offsetof(psync_file_checksums, blocks) +
|
||||
sizeof(psync_block_checksum) * i);
|
||||
if (unpdbg_likely(psync_socket_readall_download(
|
||||
if (pdbg_unlikely(psync_socket_readall_download(
|
||||
api, cs->blocks, sizeof(psync_block_checksum) * i) !=
|
||||
sizeof(psync_block_checksum) * i))
|
||||
goto err1;
|
||||
|
|
@ -1818,7 +1818,7 @@ static void psync_net_hash_remove(psync_file_checksum_hash *restrict hash,
|
|||
o = adler % hash->elementcnt;
|
||||
while (1) {
|
||||
idx = hash->elements[o];
|
||||
if (unpdbg_likely(!idx))
|
||||
if (pdbg_unlikely(!idx))
|
||||
return;
|
||||
else if (checksums->blocks[idx - 1].adler == adler &&
|
||||
!memcmp(checksums->blocks[idx - 1].mbedtls_sha1, mbedtls_sha1,
|
||||
|
|
@ -2083,11 +2083,11 @@ int psync_net_download_ranges(psync_list *ranges, psync_fileid_t fileid,
|
|||
if (!filecnt)
|
||||
goto fulldownload;
|
||||
rt = psync_net_get_checksums(NULL, fileid, filehash, &checksums);
|
||||
if (unpdbg_likely(rt == PSYNC_NET_PERMFAIL))
|
||||
if (pdbg_unlikely(rt == PSYNC_NET_PERMFAIL))
|
||||
goto fulldownload;
|
||||
else if (unpdbg_likely(rt == PSYNC_NET_TEMPFAIL))
|
||||
else if (pdbg_unlikely(rt == PSYNC_NET_TEMPFAIL))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
if (unpdbg_likely(checksums->filesize != filesize)) {
|
||||
if (pdbg_unlikely(checksums->filesize != filesize)) {
|
||||
free(checksums);
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
}
|
||||
|
|
@ -2155,7 +2155,7 @@ static int check_range_for_blocks(psync_file_checksums *checksums,
|
|||
int32_t skipbytes;
|
||||
psync_sha1_ctx ctx;
|
||||
unsigned char sha1bin[PSYNC_SHA1_DIGEST_LEN];
|
||||
if (unpdbg_likely(pfile_seek(fd, off, SEEK_SET) == -1))
|
||||
if (pdbg_unlikely(pfile_seek(fd, off, SEEK_SET) == -1))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
pdbg_logf(D_NOTICE, "scanning in range starting %lu, length %lu, blocksize %u",
|
||||
(unsigned long)off, (unsigned long)len, (unsigned)checksums->blocksize);
|
||||
|
|
@ -2334,9 +2334,9 @@ int psync_net_scan_file_for_blocks(psock_t *api, psync_list *rlist,
|
|||
pdbg_logf(D_NOTICE, "scanning fileid %lu hash %lu for blocks",
|
||||
(unsigned long)fileid, (unsigned long)filehash);
|
||||
rt = psync_net_get_checksums(api, fileid, filehash, &checksums);
|
||||
if (unpdbg_likely(rt == PSYNC_NET_PERMFAIL))
|
||||
if (pdbg_unlikely(rt == PSYNC_NET_PERMFAIL))
|
||||
return PSYNC_NET_OK;
|
||||
else if (unpdbg_likely(rt == PSYNC_NET_TEMPFAIL))
|
||||
else if (pdbg_unlikely(rt == PSYNC_NET_TEMPFAIL))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
hash = psync_net_create_hash(checksums);
|
||||
psync_list_for_each_safe(l, lb, rlist) {
|
||||
|
|
@ -2375,9 +2375,9 @@ int psync_net_scan_upload_for_blocks(psock_t *api, psync_list *rlist,
|
|||
int rt;
|
||||
pdbg_logf(D_NOTICE, "scanning uploadid %lu for blocks", (unsigned long)uploadid);
|
||||
rt = psync_net_get_upload_checksums(api, uploadid, &checksums);
|
||||
if (unpdbg_likely(rt == PSYNC_NET_PERMFAIL))
|
||||
if (pdbg_unlikely(rt == PSYNC_NET_PERMFAIL))
|
||||
return PSYNC_NET_OK;
|
||||
else if (unpdbg_likely(rt == PSYNC_NET_TEMPFAIL))
|
||||
else if (pdbg_unlikely(rt == PSYNC_NET_TEMPFAIL))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
hash = psync_net_create_hash(checksums);
|
||||
psync_list_for_each_safe(l, lb, rlist) {
|
||||
|
|
@ -2437,7 +2437,7 @@ static int download_file_revisions(psync_fileid_t fileid) {
|
|||
if (unlikely(!api))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
res = papi_send2(api, "listrevisions", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
ptimer_notify_exception();
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
|
|
@ -2566,7 +2566,7 @@ int psync_get_upload_checksum(psync_uploadid_t uploadid, unsigned char *uhash,
|
|||
if (unlikely(!api))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
res = papi_send2(api, "upload_info", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
ptimer_notify_exception();
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ static void psync_notifications_download_thumb(const binresult *thumb,
|
|||
rd = -1;
|
||||
path = papi_find_result2(thumb, "path", PARAM_STR)->str;
|
||||
filename = strrchr(path, '/');
|
||||
if (unpdbg_likely(!filename++))
|
||||
if (pdbg_unlikely(!filename++))
|
||||
return;
|
||||
filepath = psync_strcat(thumbpath, "/", filename, NULL);
|
||||
if (!stat(filepath, &st)) {
|
||||
|
|
@ -87,19 +87,19 @@ static void psync_notifications_download_thumb(const binresult *thumb,
|
|||
}
|
||||
tmpfilepath = psync_strcat(filepath, ".part", NULL);
|
||||
pdbg_logf(D_NOTICE, "downloading thumbnail %s", filename);
|
||||
if (unpdbg_likely((fd = pfile_open(tmpfilepath, O_WRONLY,
|
||||
if (pdbg_unlikely((fd = pfile_open(tmpfilepath, O_WRONLY,
|
||||
O_CREAT | O_TRUNC)) ==
|
||||
INVALID_HANDLE_VALUE))
|
||||
goto err1;
|
||||
sock = psync_http_connect_multihost(
|
||||
papi_find_result2(thumb, "hosts", PARAM_ARRAY), &host);
|
||||
if (unpdbg_likely(!sock))
|
||||
if (pdbg_unlikely(!sock))
|
||||
goto err2;
|
||||
psync_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
papi_find_result2(thumb, "dwltag", PARAM_STR)->str);
|
||||
if (unpdbg_likely(psync_http_request(sock, host, path, 0, 0, cookie)))
|
||||
if (pdbg_unlikely(psync_http_request(sock, host, path, 0, 0, cookie)))
|
||||
goto err3;
|
||||
if (unpdbg_likely(psync_http_next_request(sock)))
|
||||
if (pdbg_unlikely(psync_http_next_request(sock)))
|
||||
goto err3;
|
||||
buff = (char *)malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
while (1) {
|
||||
|
|
|
|||
|
|
@ -303,10 +303,10 @@ static int check_token(char *token, uint32_t tlen, unsigned char *key,
|
|||
binresult *res;
|
||||
uint64_t result;
|
||||
api = psync_apipool_get();
|
||||
if (unpdbg_likely(!api))
|
||||
if (pdbg_unlikely(!api))
|
||||
return 0;
|
||||
res = papi_send2(api, "checkfileownershiptoken", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -334,10 +334,10 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
sock = *((int *)ptr);
|
||||
free(ptr);
|
||||
pdbg_logf(D_NOTICE, "got tcp connection");
|
||||
if (unpdbg_likely(socket_read_all(sock, &packet, sizeof(packet))))
|
||||
if (pdbg_unlikely(socket_read_all(sock, &packet, sizeof(packet))))
|
||||
goto err0;
|
||||
if (unpdbg_likely(packet.keylen > PSYNC_P2P_RSA_SIZE) ||
|
||||
unpdbg_likely(packet.tokenlen >
|
||||
if (pdbg_unlikely(packet.keylen > PSYNC_P2P_RSA_SIZE) ||
|
||||
pdbg_unlikely(packet.tokenlen >
|
||||
512)) /* lets allow 8 times larger keys than we use */
|
||||
goto err0;
|
||||
localfileid = has_file(packet.hashstart, packet.genhash,
|
||||
|
|
@ -347,14 +347,14 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
goto err0;
|
||||
}
|
||||
binpubrsa = pssl_alloc_binary_rsa(packet.keylen);
|
||||
if (unpdbg_likely(
|
||||
if (pdbg_unlikely(
|
||||
socket_read_all(sock, binpubrsa->data, binpubrsa->datalen))) {
|
||||
free(binpubrsa);
|
||||
goto err0;
|
||||
}
|
||||
token = psync_new_cnt(char, packet.tokenlen);
|
||||
if (unpdbg_likely(socket_read_all(sock, token, packet.tokenlen)) ||
|
||||
unpdbg_likely(!check_token(token, packet.tokenlen, binpubrsa->data,
|
||||
if (pdbg_unlikely(socket_read_all(sock, token, packet.tokenlen)) ||
|
||||
pdbg_unlikely(!check_token(token, packet.tokenlen, binpubrsa->data,
|
||||
packet.keylen, hashhex))) {
|
||||
free(binpubrsa);
|
||||
free(token);
|
||||
|
|
@ -363,10 +363,10 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
free(token);
|
||||
pubrsa = prsa_binary_to_public(binpubrsa);
|
||||
free(binpubrsa);
|
||||
if (unpdbg_likely(pubrsa == PSYNC_INVALID_RSA))
|
||||
if (pdbg_unlikely(pubrsa == PSYNC_INVALID_RSA))
|
||||
goto err0;
|
||||
localpath = pfolder_lpath_lfile(localfileid, NULL);
|
||||
if (unpdbg_likely(!localpath))
|
||||
if (pdbg_unlikely(!localpath))
|
||||
goto err0;
|
||||
fd = pfile_open(localpath, O_RDONLY, 0);
|
||||
pdbg_logf(D_NOTICE, "sending file %s to peer", localpath);
|
||||
|
|
@ -382,9 +382,9 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
psymkey_free(aeskey);
|
||||
keylen = encaeskey->datalen;
|
||||
enctype = P2P_ENCTYPE_RSA_AES;
|
||||
if (unpdbg_likely(encaeskey == PSYNC_INVALID_ENC_SYM_KEY) ||
|
||||
unpdbg_likely(encoder == PSYNC_CRYPTO_INVALID_ENCODER) ||
|
||||
unpdbg_likely(
|
||||
if (pdbg_unlikely(encaeskey == PSYNC_INVALID_ENC_SYM_KEY) ||
|
||||
pdbg_unlikely(encoder == PSYNC_CRYPTO_INVALID_ENCODER) ||
|
||||
pdbg_unlikely(
|
||||
socket_write_all(sock, &keylen, sizeof(keylen)) ||
|
||||
socket_write_all(sock, &enctype, sizeof(enctype)) ||
|
||||
socket_write_all(sock, encaeskey->data, encaeskey->datalen))) {
|
||||
|
|
@ -402,10 +402,10 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
rd = packet.filesize - off;
|
||||
else
|
||||
rd = sizeof(buff);
|
||||
if (unpdbg_likely(pfile_read(fd, buff, rd) != rd))
|
||||
if (pdbg_unlikely(pfile_read(fd, buff, rd) != rd))
|
||||
break;
|
||||
pcrypto_ctr_encdec_decode(encoder, buff, rd, off);
|
||||
if (unpdbg_likely(socket_write_all(sock, buff, rd)))
|
||||
if (pdbg_unlikely(socket_write_all(sock, buff, rd)))
|
||||
break;
|
||||
off += rd;
|
||||
}
|
||||
|
|
@ -427,16 +427,16 @@ static void psync_p2p_thread() {
|
|||
pstatus_wait_statuses_arr(requiredstatuses, ARRAY_SIZE(requiredstatuses));
|
||||
tcpsock = INVALID_SOCKET;
|
||||
/* udpsock=psock_create(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (unpdbg_likely(udpsock==INVALID_SOCKET)){*/
|
||||
if (pdbg_unlikely(udpsock==INVALID_SOCKET)){*/
|
||||
udpsock = psock_create(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (unpdbg_likely(udpsock == INVALID_SOCKET))
|
||||
if (pdbg_unlikely(udpsock == INVALID_SOCKET))
|
||||
goto ex;
|
||||
setsockopt(udpsock, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
|
||||
memset(&addr4, 0, sizeof(addr4));
|
||||
addr4.sin_family = AF_INET;
|
||||
addr4.sin_port = htons(PSYNC_P2P_PORT);
|
||||
addr4.sin_addr.s_addr = INADDR_ANY;
|
||||
if (unpdbg_likely(bind(udpsock, (struct sockaddr *)&addr4, sizeof(addr4)) ==
|
||||
if (pdbg_unlikely(bind(udpsock, (struct sockaddr *)&addr4, sizeof(addr4)) ==
|
||||
SOCKET_ERROR))
|
||||
goto ex;
|
||||
/* }
|
||||
|
|
@ -445,24 +445,24 @@ static void psync_p2p_thread() {
|
|||
sizeof(on)); memset(&addr, 0, sizeof(addr)); addr.sin6_family=AF_INET6;
|
||||
addr.sin6_port =htons(PSYNC_P2P_PORT);
|
||||
addr.sin6_addr =in6addr_any;
|
||||
if (unpdbg_likely(bind(udpsock, (struct sockaddr *)&addr,
|
||||
if (pdbg_unlikely(bind(udpsock, (struct sockaddr *)&addr,
|
||||
sizeof(addr))==SOCKET_ERROR)) goto ex;
|
||||
}
|
||||
tcpsock=psock_create(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (unpdbg_likely(tcpsock==INVALID_SOCKET)){*/
|
||||
if (pdbg_unlikely(tcpsock==INVALID_SOCKET)){*/
|
||||
tcpsock = psock_create(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (unpdbg_likely(tcpsock == INVALID_SOCKET))
|
||||
if (pdbg_unlikely(tcpsock == INVALID_SOCKET))
|
||||
goto ex;
|
||||
setsockopt(tcpsock, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
|
||||
memset(&addr4, 0, sizeof(addr4));
|
||||
addr4.sin_family = AF_INET;
|
||||
addr4.sin_port = htons(0);
|
||||
addr4.sin_addr.s_addr = INADDR_ANY;
|
||||
if (unpdbg_likely(bind(tcpsock, (struct sockaddr *)&addr4, sizeof(addr4)) ==
|
||||
if (pdbg_unlikely(bind(tcpsock, (struct sockaddr *)&addr4, sizeof(addr4)) ==
|
||||
SOCKET_ERROR))
|
||||
goto ex;
|
||||
sl = sizeof(addr4);
|
||||
if (unpdbg_likely(getsockname(tcpsock, (struct sockaddr *)&addr4, &sl) ==
|
||||
if (pdbg_unlikely(getsockname(tcpsock, (struct sockaddr *)&addr4, &sl) ==
|
||||
SOCKET_ERROR))
|
||||
goto ex;
|
||||
tcpport = ntohs(addr4.sin_port);
|
||||
|
|
@ -472,12 +472,12 @@ static void psync_p2p_thread() {
|
|||
sizeof(on)); memset(&addr, 0, sizeof(addr)); addr.sin6_family=AF_INET6;
|
||||
addr.sin6_port =htons(0);
|
||||
addr.sin6_addr =in6addr_any;
|
||||
if (unpdbg_likely(bind(tcpsock, (struct sockaddr *)&addr,
|
||||
if (pdbg_unlikely(bind(tcpsock, (struct sockaddr *)&addr,
|
||||
sizeof(addr))==SOCKET_ERROR)) goto ex; sl=sizeof(addr); if
|
||||
(unpdbg_likely(getsockname(tcpsock, (struct sockaddr *)&addr,
|
||||
(pdbg_unlikely(getsockname(tcpsock, (struct sockaddr *)&addr,
|
||||
&sl)==SOCKET_ERROR)) goto ex; tcpport=ntohs(addr.sin6_port);
|
||||
}*/
|
||||
if (unpdbg_likely(listen(tcpsock, 2)))
|
||||
if (pdbg_unlikely(listen(tcpsock, 2)))
|
||||
goto ex;
|
||||
socks[0] = udpsock;
|
||||
socks[1] = tcpsock;
|
||||
|
|
@ -495,7 +495,7 @@ static void psync_p2p_thread() {
|
|||
}
|
||||
pstatus_wait_statuses_arr(requiredstatuses, ARRAY_SIZE(requiredstatuses));
|
||||
sret = psock_select_in(socks, 2, -1);
|
||||
if (unpdbg_likely(sret == -1)) {
|
||||
if (pdbg_unlikely(sret == -1)) {
|
||||
psys_sleep_milliseconds(1);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -510,7 +510,7 @@ static void psync_p2p_thread() {
|
|||
} else if (sret == 1) {
|
||||
inconn = psync_new(int);
|
||||
*inconn = accept(tcpsock, NULL, NULL);
|
||||
if (unpdbg_likely(*inconn == INVALID_SOCKET))
|
||||
if (pdbg_unlikely(*inconn == INVALID_SOCKET))
|
||||
free(inconn);
|
||||
else
|
||||
prun_thread1("p2p tcp", psync_p2p_tcphandler, inconn);
|
||||
|
|
@ -536,7 +536,7 @@ static void psync_p2p_wake() {
|
|||
struct sockaddr_in addr;
|
||||
packet_type_t pack;
|
||||
sock = psock_create(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (unpdbg_likely(sock == INVALID_SOCKET))
|
||||
if (pdbg_unlikely(sock == INVALID_SOCKET))
|
||||
return;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
|
|
@ -576,7 +576,7 @@ static int psync_p2p_check_rsa() {
|
|||
pdbg_logf(D_NOTICE, "generating %ubit RSA key", PSYNC_P2P_RSA_SIZE);
|
||||
rsa = pssl_gen_rsa(PSYNC_P2P_RSA_SIZE);
|
||||
pdbg_logf(D_NOTICE, "key generated");
|
||||
if (unpdbg_likely(rsa == PSYNC_INVALID_RSA))
|
||||
if (pdbg_unlikely(rsa == PSYNC_INVALID_RSA))
|
||||
goto rete;
|
||||
rsapriv = prsa_get_private(rsa);
|
||||
rsapub = prsa_get_public(rsa);
|
||||
|
|
@ -626,15 +626,15 @@ static int psync_p2p_get_download_token(psync_fileid_t fileid,
|
|||
*token = NULL; /* especially for gcc */
|
||||
*tlen = 0;
|
||||
api = psync_apipool_get();
|
||||
if (unpdbg_likely(!api))
|
||||
if (pdbg_unlikely(!api))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
res = papi_send2(api, "getfileownershiptoken", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
}
|
||||
psync_apipool_release(api);
|
||||
if (unpdbg_likely(papi_find_result2(res, "result", PARAM_NUM)->num != 0)) {
|
||||
if (pdbg_unlikely(papi_find_result2(res, "result", PARAM_NUM)->num != 0)) {
|
||||
free(res);
|
||||
return PSYNC_NET_PERMFAIL;
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ static int psync_p2p_download(int sock, psync_fileid_t fileid,
|
|||
unsigned char buff[4096];
|
||||
unsigned char hashbin[PSYNC_HASH_DIGEST_LEN],
|
||||
hashhex[PSYNC_HASH_DIGEST_HEXLEN];
|
||||
if (unpdbg_likely(socket_read_all(sock, &keylen, sizeof(keylen)) ||
|
||||
if (pdbg_unlikely(socket_read_all(sock, &keylen, sizeof(keylen)) ||
|
||||
socket_read_all(sock, &enctype, sizeof(enctype))))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
if (enctype != P2P_ENCTYPE_RSA_AES) {
|
||||
|
|
@ -673,10 +673,10 @@ static int psync_p2p_download(int sock, psync_fileid_t fileid,
|
|||
return PSYNC_NET_PERMFAIL;
|
||||
}
|
||||
ekey = psymkey_alloc_encrypted(keylen);
|
||||
if (unpdbg_likely(socket_read_all(sock, ekey->data, keylen)) ||
|
||||
unpdbg_likely((key = prsa_decrypt_symm_key_lock(
|
||||
if (pdbg_unlikely(socket_read_all(sock, ekey->data, keylen)) ||
|
||||
pdbg_unlikely((key = prsa_decrypt_symm_key_lock(
|
||||
&privkey, &ekey)) == PSYNC_INVALID_SYM_KEY)) {
|
||||
// unpdbg_likely((key=psymkey_decrypt(&psync_rsa_private,
|
||||
// pdbg_unlikely((key=psymkey_decrypt(&psync_rsa_private,
|
||||
// &ekey))==PSYNC_INVALID_SYM_KEY)){
|
||||
free(ekey);
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
|
|
@ -699,10 +699,10 @@ static int psync_p2p_download(int sock, psync_fileid_t fileid,
|
|||
rd = sizeof(buff);
|
||||
else
|
||||
rd = fsize - off;
|
||||
if (unpdbg_likely(socket_read_all(sock, buff, rd)))
|
||||
if (pdbg_unlikely(socket_read_all(sock, buff, rd)))
|
||||
goto err0;
|
||||
pcrypto_ctr_encdec_decode(decoder, buff, rd, off);
|
||||
if (unpdbg_likely(pfile_write(fd, buff, rd) != rd))
|
||||
if (pdbg_unlikely(pfile_write(fd, buff, rd) != rd))
|
||||
goto err0;
|
||||
psync_hash_update(&hashctx, buff, rd);
|
||||
off += rd;
|
||||
|
|
@ -775,7 +775,7 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
}
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
|
||||
setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (const char *)&on, sizeof(on));
|
||||
if (unpdbg_likely(bind(sock, (struct sockaddr *)&il->interfaces[i].address,
|
||||
if (pdbg_unlikely(bind(sock, (struct sockaddr *)&il->interfaces[i].address,
|
||||
il->interfaces[i].addrsize) == SOCKET_ERROR)) {
|
||||
close(sock);
|
||||
continue;
|
||||
|
|
@ -796,12 +796,12 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
} else
|
||||
close(sock);
|
||||
}
|
||||
if (unpdbg_likely(!msock))
|
||||
if (pdbg_unlikely(!msock))
|
||||
goto err_perm;
|
||||
tv.tv_sec = PSYNC_P2P_INITIAL_TIMEOUT / 1000;
|
||||
tv.tv_usec = (PSYNC_P2P_INITIAL_TIMEOUT % 1000) * 1000;
|
||||
sret = select(msock, &rfds, NULL, NULL, &tv);
|
||||
if (sret == 0 || unpdbg_likely(sret == SOCKET_ERROR))
|
||||
if (sret == 0 || pdbg_unlikely(sret == SOCKET_ERROR))
|
||||
goto err_perm;
|
||||
bresp = P2P_RESP_NOPE;
|
||||
for (i = 0; i < il->interfacecnt; i++)
|
||||
|
|
@ -809,8 +809,8 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
slen = sizeof(addr);
|
||||
sret = recvfrom(sockets[i], (char *)&resp, sizeof(resp), 0,
|
||||
(struct sockaddr *)&addr, &slen);
|
||||
if (unpdbg_likely(sret == SOCKET_ERROR) ||
|
||||
unpdbg_likely(sret < sizeof(resp)))
|
||||
if (pdbg_unlikely(sret == SOCKET_ERROR) ||
|
||||
pdbg_unlikely(sret < sizeof(resp)))
|
||||
continue;
|
||||
if (!memcmp(pct1.rand, resp.rand, sizeof(resp.rand))) {
|
||||
pdbg_logf(
|
||||
|
|
@ -823,7 +823,7 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
sizeof(resp.rand));
|
||||
psync_hash(hashsource, PSYNC_HASH_BLOCK_SIZE, hashbin);
|
||||
psync_binhex(hashhex, hashbin, PSYNC_HASH_DIGEST_LEN);
|
||||
if (unpdbg_likely(memcmp(hashhex, resp.genhash, PSYNC_HASH_DIGEST_HEXLEN)))
|
||||
if (pdbg_unlikely(memcmp(hashhex, resp.genhash, PSYNC_HASH_DIGEST_HEXLEN)))
|
||||
continue;
|
||||
if (resp.type == P2P_RESP_HAVEIT) {
|
||||
pdbg_logf(D_NOTICE, "got P2P_RESP_HAVEIT");
|
||||
|
|
@ -851,7 +851,7 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
sret =
|
||||
psync_p2p_get_download_token(fileid, filehashhex, fsize, &token, &tlen);
|
||||
pdbg_logf(D_NOTICE, "got token");
|
||||
if (unpdbg_likely(sret != PSYNC_NET_OK)) {
|
||||
if (pdbg_unlikely(sret != PSYNC_NET_OK)) {
|
||||
if (sret == PSYNC_NET_TEMPFAIL)
|
||||
goto err_temp2;
|
||||
else
|
||||
|
|
@ -867,7 +867,7 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
pdbg_logf(D_ERROR, "unknown address family %u", (unsigned)addr.sin6_family);
|
||||
goto err_perm2;
|
||||
}
|
||||
if (unpdbg_likely(sock == INVALID_SOCKET))
|
||||
if (pdbg_unlikely(sock == INVALID_SOCKET))
|
||||
goto err_perm3;
|
||||
if (unlikely(connect(sock, (struct sockaddr *)&addr, slen) == SOCKET_ERROR)) {
|
||||
pdbg_logf(D_WARNING, "could not connect to %s port %u", get_addr(&addr),
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ static int psync_pagecache_read_range_from_api(psync_request_t *request,
|
|||
first_page_id = range->offset / PSYNC_FS_PAGE_SIZE;
|
||||
len = range->length / PSYNC_FS_PAGE_SIZE;
|
||||
res = papi_result_thread(api);
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
return -2;
|
||||
dlen = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
if (unlikely(dlen)) {
|
||||
|
|
@ -371,7 +371,7 @@ static int psync_pagecache_read_range_from_api(psync_request_t *request,
|
|||
page = psync_pagecache_get_free_page(0);
|
||||
rb = psync_socket_readall_download_thread(
|
||||
api, page->page, dlen < PSYNC_FS_PAGE_SIZE ? dlen : PSYNC_FS_PAGE_SIZE);
|
||||
if (unpdbg_likely(rb <= 0)) {
|
||||
if (pdbg_unlikely(rb <= 0)) {
|
||||
psync_pagecache_return_free_page(page);
|
||||
ptimer_notify_exception();
|
||||
return i == 0 ? -2 : -1;
|
||||
|
|
@ -557,7 +557,7 @@ static int get_urls(psync_request_t *request, psync_urls_t *urls) {
|
|||
tries = 0;
|
||||
while (tries++ <= 5) {
|
||||
api = psync_apipool_get();
|
||||
if (unpdbg_likely(!api))
|
||||
if (pdbg_unlikely(!api))
|
||||
continue;
|
||||
psock_set_write_buffered(api);
|
||||
if (unlikely(papi_send_no_res(api, "getfilelink", params) != PTR_OK))
|
||||
|
|
@ -577,7 +577,7 @@ static int get_urls(psync_request_t *request, psync_urls_t *urls) {
|
|||
}
|
||||
mark_api_shared(api);
|
||||
ret = papi_result_thread(api);
|
||||
if (unpdbg_likely(!ret)) {
|
||||
if (pdbg_unlikely(!ret)) {
|
||||
mark_shared_api_bad(api);
|
||||
goto err1;
|
||||
}
|
||||
|
|
@ -600,7 +600,7 @@ static int get_urls(psync_request_t *request, psync_urls_t *urls) {
|
|||
if (request->needkey) {
|
||||
pcrypto_sector_encdec_t enc;
|
||||
ret = papi_result_thread(api);
|
||||
if (unpdbg_likely(!ret))
|
||||
if (pdbg_unlikely(!ret))
|
||||
goto err3;
|
||||
result = papi_find_result2(ret, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result != 0)) {
|
||||
|
|
@ -610,7 +610,7 @@ static int get_urls(psync_request_t *request, psync_urls_t *urls) {
|
|||
}
|
||||
enc = pcryptofolder_filencoder_from_binresult(request->fileid,
|
||||
ret);
|
||||
if (unpdbg_likely(psync_crypto_is_error(enc)))
|
||||
if (pdbg_unlikely(psync_crypto_is_error(enc)))
|
||||
goto err4;
|
||||
pdbg_logf(D_NOTICE, "got key for fileid %lu", (unsigned long)request->fileid);
|
||||
free(ret);
|
||||
|
|
@ -1221,12 +1221,12 @@ static int check_disk_full() {
|
|||
psync_sql_res *res;
|
||||
db_cache_max_page = psync_sql_cellint("SELECT MAX(id) FROM pagecache", 0);
|
||||
filesize = pfile_size(readcache);
|
||||
if (unpdbg_likely(filesize == -1))
|
||||
if (pdbg_unlikely(filesize == -1))
|
||||
return 0;
|
||||
freespace =
|
||||
ppath_free_space(psync_setting_get_string(_PS(fscachepath)));
|
||||
minlocal = psync_setting_get_uint(_PS(minlocalfreespace));
|
||||
if (unpdbg_likely(freespace == -1))
|
||||
if (pdbg_unlikely(freespace == -1))
|
||||
return 0;
|
||||
if (db_cache_max_page * PSYNC_FS_PAGE_SIZE > filesize)
|
||||
addspc = cache_pages_in_hash * PSYNC_FS_PAGE_SIZE;
|
||||
|
|
@ -1987,7 +1987,7 @@ static int psync_pagecache_read_range_from_sock(psync_request_t *request,
|
|||
for (i = 0; i < len; i++) {
|
||||
page = psync_pagecache_get_free_page(0);
|
||||
rb = psync_http_request_readall(sock, page->page, PSYNC_FS_PAGE_SIZE);
|
||||
if (unpdbg_likely(rb <= 0)) {
|
||||
if (pdbg_unlikely(rb <= 0)) {
|
||||
psync_pagecache_return_free_page(page);
|
||||
ptimer_notify_exception();
|
||||
return -1;
|
||||
|
|
@ -2210,7 +2210,7 @@ retry:
|
|||
}
|
||||
if (!sock)
|
||||
sock = psync_http_connect_multihost(hosts, &host);
|
||||
if (unpdbg_likely(!sock))
|
||||
if (pdbg_unlikely(!sock))
|
||||
goto err0;
|
||||
// pdbg_logf(D_NOTICE, "connected to %s", host);
|
||||
path = papi_find_result2(urls->urls, "path", PARAM_STR)->str;
|
||||
|
|
@ -3311,7 +3311,7 @@ static void psync_pagecache_modify_to_cache(uint64_t taskid, uint64_t hash,
|
|||
return;
|
||||
}
|
||||
tree = NULL;
|
||||
if (unpdbg_likely((fs = pfile_size(fd)) == -1 ||
|
||||
if (pdbg_unlikely((fs = pfile_size(fd)) == -1 ||
|
||||
psync_fs_load_interval_tree(fd, fs, &tree) == -1))
|
||||
goto err2;
|
||||
pfile_close(fd);
|
||||
|
|
@ -3322,7 +3322,7 @@ static void psync_pagecache_modify_to_cache(uint64_t taskid, uint64_t hash,
|
|||
goto err1;
|
||||
}
|
||||
fs = pfile_size(fd);
|
||||
if (unpdbg_likely(fs == -1))
|
||||
if (pdbg_unlikely(fs == -1))
|
||||
goto err2;
|
||||
pdbg_logf(D_NOTICE,
|
||||
"adding blocks of file %s to cache for hash %lu (%ld), old hash %lu "
|
||||
|
|
@ -3445,7 +3445,7 @@ static void psync_pagecache_modify_to_cache(uint64_t taskid, uint64_t hash,
|
|||
if (!interval || interval->from >= off + PSYNC_FS_PAGE_SIZE)
|
||||
break;
|
||||
}
|
||||
if (unpdbg_likely(ret == -1)) {
|
||||
if (pdbg_unlikely(ret == -1)) {
|
||||
psync_pagecache_return_free_page(page);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -3616,7 +3616,7 @@ int ppagecache_copy_to_file_locked(
|
|||
if (pfile_pwrite(of->datafile, buff, rb, i * PSYNC_FS_PAGE_SIZE) != rb)
|
||||
return -1;
|
||||
}
|
||||
if (unpdbg_likely(pfile_sync(of->datafile)))
|
||||
if (pdbg_unlikely(pfile_sync(of->datafile)))
|
||||
return -1;
|
||||
else {
|
||||
pdbg_logf(D_NOTICE, "copied %lu bytes to data file of %s from cache",
|
||||
|
|
@ -3693,7 +3693,7 @@ static int psync_pagecache_free_page_from_read_cache() {
|
|||
psync_sql_bind_uint(res, 1, sizeinpages);
|
||||
psync_sql_run_free(res);
|
||||
db_cache_max_page = sizeinpages;
|
||||
} else if (unpdbg_likely(db_cache_max_page < sizeinpages))
|
||||
} else if (pdbg_unlikely(db_cache_max_page < sizeinpages))
|
||||
sizeinpages = db_cache_max_page;
|
||||
page = psync_pagecache_get_free_page_if_available();
|
||||
if (unlikely(!page)) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ char *ppath_default_db() {
|
|||
|
||||
int64_t ppath_free_space(const char *path) {
|
||||
struct statvfs buf;
|
||||
if (unpdbg_likely(statvfs(path, &buf)))
|
||||
if (pdbg_unlikely(statvfs(path, &buf)))
|
||||
return -1;
|
||||
else
|
||||
return (int64_t)buf.f_bavail * (int64_t)buf.f_frsize;
|
||||
|
|
@ -56,14 +56,14 @@ char *ppath_home() {
|
|||
struct stat st;
|
||||
const char *dir;
|
||||
dir = getenv("HOME");
|
||||
if (unpdbg_likely(!dir) || unpdbg_likely(stat(dir, &st)) ||
|
||||
unpdbg_likely(!pfile_stat_mode_ok(&st, 7))) {
|
||||
if (pdbg_unlikely(!dir) || pdbg_unlikely(stat(dir, &st)) ||
|
||||
pdbg_unlikely(!pfile_stat_mode_ok(&st, 7))) {
|
||||
struct passwd pwd;
|
||||
struct passwd *result;
|
||||
char buff[4096];
|
||||
if (unpdbg_likely(getpwuid_r(getuid(), &pwd, buff, sizeof(buff), &result)) ||
|
||||
unpdbg_likely(stat(result->pw_dir, &st)) ||
|
||||
unpdbg_likely(!pfile_stat_mode_ok(&st, 7)))
|
||||
if (pdbg_unlikely(getpwuid_r(getuid(), &pwd, buff, sizeof(buff), &result)) ||
|
||||
pdbg_unlikely(stat(result->pw_dir, &st)) ||
|
||||
pdbg_unlikely(!pfile_stat_mode_ok(&st, 7)))
|
||||
return NULL;
|
||||
dir = result->pw_dir;
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ int ppath_ls_fast(const char *path, ppath_ls_fast_cb callback, void *ptr) {
|
|||
struct dirent *de;
|
||||
|
||||
dh = opendir(path);
|
||||
if (unpdbg_likely(!dh)) {
|
||||
if (pdbg_unlikely(!dh)) {
|
||||
psync_error = PERROR_LOCAL_FOLDER_NOT_FOUND;
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ int ppath_ls_fast(const char *path, ppath_ls_fast_cb callback, void *ptr) {
|
|||
} else if (de->d_type == DT_UNKNOWN) {
|
||||
// Fall back to lstat for unknown file types
|
||||
psync_strlcpy(cpath + pl, de->d_name, NAME_MAX + 1);
|
||||
if (!unpdbg_likely(lstat(cpath, &st))) {
|
||||
if (!pdbg_unlikely(lstat(cpath, &st))) {
|
||||
pst.isfolder = S_ISDIR(st.st_mode);
|
||||
callback(ptr, &pst);
|
||||
}
|
||||
|
|
@ -172,12 +172,12 @@ char *ppath_pcloud() {
|
|||
|
||||
path = psync_strcat(homedir, "/", PSYNC_DEFAULT_POSIX_DIR, NULL);
|
||||
free(homedir);
|
||||
if (unpdbg_likely(!path)) {
|
||||
if (pdbg_unlikely(!path)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (stat(path, &st) &&
|
||||
unpdbg_likely(mkdir(path, PSYNC_DEFAULT_POSIX_FOLDER_MODE))) {
|
||||
pdbg_unlikely(mkdir(path, PSYNC_DEFAULT_POSIX_FOLDER_MODE))) {
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ void pqevent_queue_sync_event_id(psync_eventtype_t eventid, psync_syncid_t synci
|
|||
remotepath = pfolder_path(remoteid, NULL);
|
||||
else
|
||||
remotepath = pfolder_file_path(remoteid, NULL);
|
||||
if (unpdbg_likely(!remotepath))
|
||||
if (pdbg_unlikely(!remotepath))
|
||||
return;
|
||||
pqevent_queue_sync_event_path(eventid, syncid, localpath, remoteid, remotepath);
|
||||
free(remotepath);
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ psock_t *psock_connect(const char *host, int unsigned port, int ssl) {
|
|||
psync_slprintf(sport, sizeof(sport), "%d", port);
|
||||
|
||||
sock = connect_socket(host, sport);
|
||||
if (unpdbg_likely(sock == INVALID_SOCKET)) {
|
||||
if (pdbg_unlikely(sock == INVALID_SOCKET)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ psock_t *psock_connect(const char *host, int unsigned port, int ssl) {
|
|||
}
|
||||
ssl = pssl_connect_finish(sslc, host);
|
||||
}
|
||||
if (unpdbg_likely(ssl != PSYNC_SSL_SUCCESS)) {
|
||||
if (pdbg_unlikely(ssl != PSYNC_SSL_SUCCESS)) {
|
||||
close(sock);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1094,7 +1094,7 @@ psock_ifaces_t *psock_list_adapters() {
|
|||
struct ifaddrs *addrs, *addr;
|
||||
sa_family_t family;
|
||||
size_t sz;
|
||||
if (unpdbg_likely(getifaddrs(&addrs)))
|
||||
if (pdbg_unlikely(getifaddrs(&addrs)))
|
||||
goto empty;
|
||||
cnt = 0;
|
||||
addr = addrs;
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ static void psync_sync_newsyncedfolder(psync_syncid_t syncid) {
|
|||
"WHERE id=? AND flags=0");
|
||||
psync_sql_bind_uint(res, 1, syncid);
|
||||
row = psync_sql_fetch_row(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
psync_sql_free_result(res);
|
||||
psync_sql_rollback_transaction();
|
||||
return;
|
||||
|
|
@ -436,9 +436,9 @@ re:
|
|||
mbedtls_md = 7;
|
||||
else
|
||||
mbedtls_md = 5;
|
||||
if (unpdbg_likely(stat(localpath, &st)) ||
|
||||
unpdbg_likely(!pfile_stat_isfolder(&st)) ||
|
||||
unpdbg_likely(!pfile_stat_mode_ok(&st, mbedtls_md))) {
|
||||
if (pdbg_unlikely(stat(localpath, &st)) ||
|
||||
pdbg_unlikely(!pfile_stat_isfolder(&st)) ||
|
||||
pdbg_unlikely(!pfile_stat_mode_ok(&st, mbedtls_md))) {
|
||||
pdbg_logf(D_WARNING,
|
||||
"ignoring delayed sync id %" PRIu64 " for local path %s", id,
|
||||
localpath);
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ int psync_init() {
|
|||
|
||||
if (!psync_database) {
|
||||
psync_database = ppath_default_db();
|
||||
if (unpdbg_likely(!psync_database)) {
|
||||
if (pdbg_unlikely(!psync_database)) {
|
||||
if (IS_DEBUG)
|
||||
pthread_mutex_unlock(&psync_libstate_mutex);
|
||||
return_error(PERROR_NO_HOMEDIR);
|
||||
|
|
@ -188,7 +188,7 @@ int psync_init() {
|
|||
}
|
||||
psync_sql_statement("UPDATE task SET inprogress=0 WHERE inprogress=1");
|
||||
ptimer_init();
|
||||
if (unpdbg_likely(pssl_init())) {
|
||||
if (pdbg_unlikely(pssl_init())) {
|
||||
if (IS_DEBUG)
|
||||
pthread_mutex_unlock(&psync_libstate_mutex);
|
||||
return_error(PERROR_SSL_INIT_FAILED);
|
||||
|
|
@ -669,17 +669,17 @@ psync_syncid_t psync_add_sync_by_folderid(const char *localpath,
|
|||
|
||||
pdbg_logf(D_NOTICE, "Add sync by folder id localpath: [%s]", localpath);
|
||||
|
||||
if (unpdbg_likely(synctype < PSYNC_SYNCTYPE_MIN ||
|
||||
if (pdbg_unlikely(synctype < PSYNC_SYNCTYPE_MIN ||
|
||||
synctype > PSYNC_SYNCTYPE_MAX))
|
||||
return_isyncid(PERROR_INVALID_SYNCTYPE);
|
||||
if (unpdbg_likely(stat(localpath, &st)) ||
|
||||
unpdbg_likely(!pfile_stat_isfolder(&st)))
|
||||
if (pdbg_unlikely(stat(localpath, &st)) ||
|
||||
pdbg_unlikely(!pfile_stat_isfolder(&st)))
|
||||
return_isyncid(PERROR_LOCAL_FOLDER_NOT_FOUND);
|
||||
if (synctype & PSYNC_DOWNLOAD_ONLY)
|
||||
mbedtls_md = 7;
|
||||
else
|
||||
mbedtls_md = 5;
|
||||
if (unpdbg_likely(!pfile_stat_mode_ok(&st, mbedtls_md)))
|
||||
if (pdbg_unlikely(!pfile_stat_mode_ok(&st, mbedtls_md)))
|
||||
return_isyncid(PERROR_LOCAL_FOLDER_ACC_DENIED);
|
||||
syncmp = psync_fs_getmountpoint();
|
||||
if (syncmp) {
|
||||
|
|
@ -693,7 +693,7 @@ psync_syncid_t psync_add_sync_by_folderid(const char *localpath,
|
|||
free(syncmp);
|
||||
}
|
||||
res = psync_sql_query("SELECT localpath FROM syncfolder");
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
return_isyncid(PERROR_DATABASE_ERROR);
|
||||
while ((srow = psync_sql_fetch_rowstr(res)))
|
||||
if (psyncer_str_has_prefix(srow[0], localpath)) {
|
||||
|
|
@ -706,11 +706,11 @@ psync_syncid_t psync_add_sync_by_folderid(const char *localpath,
|
|||
psync_sql_free_result(res);
|
||||
if (folderid) {
|
||||
res = psync_sql_query("SELECT permissions FROM folder WHERE id=?");
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
return_isyncid(PERROR_DATABASE_ERROR);
|
||||
psync_sql_bind_uint(res, 1, folderid);
|
||||
row = psync_sql_fetch_rowint(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
psync_sql_free_result(res);
|
||||
return_isyncid(PERROR_REMOTE_FOLDER_NOT_FOUND);
|
||||
}
|
||||
|
|
@ -718,7 +718,7 @@ psync_syncid_t psync_add_sync_by_folderid(const char *localpath,
|
|||
psync_sql_free_result(res);
|
||||
} else
|
||||
perms = PSYNC_PERM_ALL;
|
||||
if (unpdbg_likely((synctype & PSYNC_DOWNLOAD_ONLY &&
|
||||
if (pdbg_unlikely((synctype & PSYNC_DOWNLOAD_ONLY &&
|
||||
(perms & PSYNC_PERM_READ) != PSYNC_PERM_READ) ||
|
||||
(synctype & PSYNC_UPLOAD_ONLY &&
|
||||
(perms & PSYNC_PERM_WRITE) != PSYNC_PERM_WRITE)))
|
||||
|
|
@ -726,7 +726,7 @@ psync_syncid_t psync_add_sync_by_folderid(const char *localpath,
|
|||
res = psync_sql_prep_statement(
|
||||
"INSERT OR IGNORE INTO syncfolder (folderid, localpath, synctype, flags, "
|
||||
"inode, deviceid) VALUES (?, ?, ?, 0, ?, ?)");
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
return_isyncid(PERROR_DATABASE_ERROR);
|
||||
psync_sql_bind_uint(res, 1, folderid);
|
||||
psync_sql_bind_string(res, 2, localpath);
|
||||
|
|
@ -753,17 +753,17 @@ int psync_add_sync_by_path_delayed(const char *localpath,
|
|||
psync_sql_res *res;
|
||||
struct stat st;
|
||||
int unsigned mbedtls_md;
|
||||
if (unpdbg_likely(synctype < PSYNC_SYNCTYPE_MIN ||
|
||||
if (pdbg_unlikely(synctype < PSYNC_SYNCTYPE_MIN ||
|
||||
synctype > PSYNC_SYNCTYPE_MAX))
|
||||
return_error(PERROR_INVALID_SYNCTYPE);
|
||||
if (unpdbg_likely(stat(localpath, &st)) ||
|
||||
unpdbg_likely(!pfile_stat_isfolder(&st)))
|
||||
if (pdbg_unlikely(stat(localpath, &st)) ||
|
||||
pdbg_unlikely(!pfile_stat_isfolder(&st)))
|
||||
return_error(PERROR_LOCAL_FOLDER_NOT_FOUND);
|
||||
if (synctype & PSYNC_DOWNLOAD_ONLY)
|
||||
mbedtls_md = 7;
|
||||
else
|
||||
mbedtls_md = 5;
|
||||
if (unpdbg_likely(!pfile_stat_mode_ok(&st, mbedtls_md)))
|
||||
if (pdbg_unlikely(!pfile_stat_mode_ok(&st, mbedtls_md)))
|
||||
return_error(PERROR_LOCAL_FOLDER_ACC_DENIED);
|
||||
res = psync_sql_prep_statement("INSERT INTO syncfolderdelayed (localpath, "
|
||||
"remotepath, synctype) VALUES (?, ?, ?)");
|
||||
|
|
@ -786,7 +786,7 @@ int psync_change_synctype(psync_syncid_t syncid, psync_synctype_t synctype) {
|
|||
struct stat st;
|
||||
int unsigned mbedtls_md;
|
||||
psync_synctype_t oldsynctype;
|
||||
if (unpdbg_likely(synctype < PSYNC_SYNCTYPE_MIN ||
|
||||
if (pdbg_unlikely(synctype < PSYNC_SYNCTYPE_MIN ||
|
||||
synctype > PSYNC_SYNCTYPE_MAX))
|
||||
return_isyncid(PERROR_INVALID_SYNCTYPE);
|
||||
psync_sql_start_transaction();
|
||||
|
|
@ -794,7 +794,7 @@ int psync_change_synctype(psync_syncid_t syncid, psync_synctype_t synctype) {
|
|||
"SELECT folderid, localpath, synctype FROM syncfolder WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, syncid);
|
||||
row = psync_sql_fetch_row(res);
|
||||
if (unpdbg_likely(!row)) {
|
||||
if (pdbg_unlikely(!row)) {
|
||||
psync_sql_free_result(res);
|
||||
psync_sql_rollback_transaction();
|
||||
return_error(PERROR_INVALID_SYNCID);
|
||||
|
|
@ -806,8 +806,8 @@ int psync_change_synctype(psync_syncid_t syncid, psync_synctype_t synctype) {
|
|||
psync_sql_rollback_transaction();
|
||||
return 0;
|
||||
}
|
||||
if (unpdbg_likely(stat(psync_get_string(row[1]), &st)) ||
|
||||
unpdbg_likely(!pfile_stat_isfolder(&st))) {
|
||||
if (pdbg_unlikely(stat(psync_get_string(row[1]), &st)) ||
|
||||
pdbg_unlikely(!pfile_stat_isfolder(&st))) {
|
||||
psync_sql_free_result(res);
|
||||
psync_sql_rollback_transaction();
|
||||
return_isyncid(PERROR_LOCAL_FOLDER_NOT_FOUND);
|
||||
|
|
@ -817,17 +817,17 @@ int psync_change_synctype(psync_syncid_t syncid, psync_synctype_t synctype) {
|
|||
mbedtls_md = 7;
|
||||
else
|
||||
mbedtls_md = 5;
|
||||
if (unpdbg_likely(!pfile_stat_mode_ok(&st, mbedtls_md))) {
|
||||
if (pdbg_unlikely(!pfile_stat_mode_ok(&st, mbedtls_md))) {
|
||||
psync_sql_rollback_transaction();
|
||||
return_isyncid(PERROR_LOCAL_FOLDER_ACC_DENIED);
|
||||
}
|
||||
if (folderid) {
|
||||
res = psync_sql_query("SELECT permissions FROM folder WHERE id=?");
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
return_isyncid(PERROR_DATABASE_ERROR);
|
||||
psync_sql_bind_uint(res, 1, folderid);
|
||||
urow = psync_sql_fetch_rowint(res);
|
||||
if (unpdbg_likely(!urow)) {
|
||||
if (pdbg_unlikely(!urow)) {
|
||||
psync_sql_free_result(res);
|
||||
psync_sql_rollback_transaction();
|
||||
return_isyncid(PERROR_REMOTE_FOLDER_NOT_FOUND);
|
||||
|
|
@ -836,7 +836,7 @@ int psync_change_synctype(psync_syncid_t syncid, psync_synctype_t synctype) {
|
|||
psync_sql_free_result(res);
|
||||
} else
|
||||
perms = PSYNC_PERM_ALL;
|
||||
if (unpdbg_likely((synctype & PSYNC_DOWNLOAD_ONLY &&
|
||||
if (pdbg_unlikely((synctype & PSYNC_DOWNLOAD_ONLY &&
|
||||
(perms & PSYNC_PERM_READ) != PSYNC_PERM_READ) ||
|
||||
(synctype & PSYNC_UPLOAD_ONLY &&
|
||||
(perms & PSYNC_PERM_WRITE) != PSYNC_PERM_WRITE))) {
|
||||
|
|
@ -1098,14 +1098,14 @@ int psync_register(const char *email, const char *password, int termsaccepted,
|
|||
return -1;
|
||||
}
|
||||
sock = papi_connect(binapi, psync_setting_get_bool(_PS(usessl)));
|
||||
if (unpdbg_likely(!sock)) {
|
||||
if (pdbg_unlikely(!sock)) {
|
||||
if (err)
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
return -1;
|
||||
}
|
||||
res = papi_send2(sock, "register", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psock_close(sock);
|
||||
if (err)
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
|
|
@ -1669,10 +1669,10 @@ static char *psync_filename_from_res(const binresult *res) {
|
|||
char *nmd, *path, *ret;
|
||||
const char *nmarr[2];
|
||||
nm = strrchr(papi_find_result2(res, "path", PARAM_STR)->str, '/');
|
||||
if (unpdbg_likely(!nm))
|
||||
if (pdbg_unlikely(!nm))
|
||||
return NULL;
|
||||
path = ppath_private_tmp();
|
||||
if (unpdbg_likely(!path))
|
||||
if (pdbg_unlikely(!path))
|
||||
return NULL;
|
||||
nmd = psync_url_decode(nm + 1);
|
||||
nmarr[0] = path;
|
||||
|
|
@ -1963,7 +1963,7 @@ int psync_crypto_change_crypto_pass(const char *oldpass, const char *newpass,
|
|||
if (!api)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
res = papi_send2(api, "crypto_changeuserprivate", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
|
|
@ -2010,7 +2010,7 @@ int psync_crypto_change_crypto_pass_unlocked(const char *newpass,
|
|||
if (!api)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
res = papi_send2(api, "crypto_changeuserprivate", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
if (++tries > 5)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
|
|
@ -2042,7 +2042,7 @@ int psync_crypto_crypto_send_change_user_private() {
|
|||
if (!api)
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
res = papi_send2(api, "crypto_sendchangeuserprivate", params);
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psync_apipool_release_bad(api);
|
||||
return pdbg_return_const(PSYNC_CRYPTO_SETUP_CANT_CONNECT);
|
||||
} else {
|
||||
|
|
@ -2288,7 +2288,7 @@ int psync_get_promo(char **url, uint64_t *width, uint64_t *height) {
|
|||
|
||||
res = psync_api_run_command("getpromourl", params);
|
||||
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -2403,7 +2403,7 @@ int psync_is_folder_syncable(char *localPath, char **errMsg) {
|
|||
|
||||
sql = psync_sql_query("SELECT localpath FROM syncfolder");
|
||||
|
||||
if (unpdbg_likely(!sql)) {
|
||||
if (pdbg_unlikely(!sql)) {
|
||||
return_isyncid(PERROR_DATABASE_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void psys_init() {
|
|||
psync_gid = getgid();
|
||||
psync_gids_cnt = getgroups(0, NULL);
|
||||
psync_gids = psync_new_cnt(gid_t, psync_gids_cnt);
|
||||
if (unpdbg_likely(getgroups(psync_gids_cnt, psync_gids) != psync_gids_cnt))
|
||||
if (pdbg_unlikely(getgroups(psync_gids_cnt, psync_gids) != psync_gids_cnt))
|
||||
psync_gids_cnt = 0;
|
||||
pdbg_logf(D_NOTICE, "detected page size %ld", sysconf(_SC_PAGESIZE));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ static void timer_thread() {
|
|||
timer_process_timers(&timers);
|
||||
if (unlikely(psync_current_time - lt >= 25))
|
||||
timer_sleep_detected(lt);
|
||||
else if (unpdbg_likely(psync_current_time == lt)) {
|
||||
else if (pdbg_unlikely(psync_current_time == lt)) {
|
||||
if (!psync_do_run)
|
||||
break;
|
||||
psys_sleep_milliseconds(1000);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ int ptools_create_backend_event(const char *binapi, const char *category,
|
|||
|
||||
sock = papi_connect(binapi, psync_setting_get_bool(0));
|
||||
|
||||
if (unpdbg_likely(!sock)) {
|
||||
if (pdbg_unlikely(!sock)) {
|
||||
if (err) {
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ int ptools_create_backend_event(const char *binapi, const char *category,
|
|||
free(keyParams);
|
||||
free(paramsLocal);
|
||||
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psock_close(sock);
|
||||
|
||||
if (err) {
|
||||
|
|
@ -295,7 +295,7 @@ int ptools_backend_call(const char *binapi, const char *wsPath,
|
|||
|
||||
sock = papi_connect(binapi, psync_setting_get_bool(0));
|
||||
|
||||
if (unpdbg_likely(!sock)) {
|
||||
if (pdbg_unlikely(!sock)) {
|
||||
if (err) {
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ int ptools_backend_call(const char *binapi, const char *wsPath,
|
|||
|
||||
free(localParams);
|
||||
|
||||
if (unpdbg_likely(!res)) {
|
||||
if (pdbg_unlikely(!res)) {
|
||||
psock_close(sock);
|
||||
|
||||
if (err) {
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ static int task_renamefile(uint64_t taskid, psync_syncid_t syncid,
|
|||
else
|
||||
folderid = 0;
|
||||
psync_sql_free_result(res);
|
||||
if (unpdbg_likely(!fileid) || unpdbg_likely(!folderid))
|
||||
if (pdbg_unlikely(!fileid) || pdbg_unlikely(!folderid))
|
||||
return 0;
|
||||
else
|
||||
return task_renameremotefile(fileid, folderid, newname);
|
||||
|
|
@ -464,7 +464,7 @@ static int task_renamefolder(uint64_t taskid, psync_syncid_t syncid,
|
|||
else
|
||||
parentfolderid = 0;
|
||||
psync_sql_free_result(res);
|
||||
if (unpdbg_likely(!folderid) || unpdbg_likely(!parentfolderid))
|
||||
if (pdbg_unlikely(!folderid) || pdbg_unlikely(!parentfolderid))
|
||||
return 0;
|
||||
else
|
||||
return task_renameremotefolder(folderid, parentfolderid, newname);
|
||||
|
|
@ -501,7 +501,7 @@ static void set_local_file_conflicted(psync_fileid_t localfileid,
|
|||
psync_sql_bind_uint(res, 2, taskid);
|
||||
psync_sql_run_free(res);
|
||||
newpath = pfolder_lpath_lfile(localfileid, NULL);
|
||||
if (unpdbg_likely(pfile_rename_overwrite(localpath, newpath)))
|
||||
if (pdbg_unlikely(pfile_rename_overwrite(localpath, newpath)))
|
||||
psync_sql_rollback_transaction();
|
||||
else
|
||||
psync_sql_commit_transaction();
|
||||
|
|
@ -691,7 +691,7 @@ static int upload_file(const char *localpath, const unsigned char *hashhex,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api))
|
||||
goto err0;
|
||||
if (unpdbg_likely(!papi_send(api, "uploadfile", strlen("uploadfile"),
|
||||
if (pdbg_unlikely(!papi_send(api, "uploadfile", strlen("uploadfile"),
|
||||
params, ARRAY_SIZE(params), fsize, 0)))
|
||||
goto err1;
|
||||
bw = 0;
|
||||
|
|
@ -707,9 +707,9 @@ static int upload_file(const char *localpath, const unsigned char *hashhex,
|
|||
else
|
||||
rd = fsize - bw;
|
||||
rrd = pfile_read(fd, buff, rd);
|
||||
if (unpdbg_likely(rrd <= 0))
|
||||
if (pdbg_unlikely(rrd <= 0))
|
||||
goto err2;
|
||||
if (unpdbg_likely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
if (pdbg_unlikely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
goto err2;
|
||||
bw += rrd;
|
||||
if (bw == fsize && pfile_read(fd, buff, 1) != 0) {
|
||||
|
|
@ -803,8 +803,8 @@ static int upload_range(psock_t *api, psync_upload_range_list_t *r,
|
|||
uint64_t bw;
|
||||
size_t rd;
|
||||
ssize_t rrd;
|
||||
if (unpdbg_likely(pfile_seek(fd, r->off, SEEK_SET) == -1) ||
|
||||
unpdbg_likely(!papi_send(api, "upload_write", strlen("upload_write"),
|
||||
if (pdbg_unlikely(pfile_seek(fd, r->off, SEEK_SET) == -1) ||
|
||||
pdbg_unlikely(!papi_send(api, "upload_write", strlen("upload_write"),
|
||||
params, ARRAY_SIZE(params), r->len, 0)))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
bw = 0;
|
||||
|
|
@ -821,10 +821,10 @@ static int upload_range(psock_t *api, psync_upload_range_list_t *r,
|
|||
else
|
||||
rd = r->len - bw;
|
||||
rrd = pfile_read(fd, buff, rd);
|
||||
if (unpdbg_likely(rrd <= 0))
|
||||
if (pdbg_unlikely(rrd <= 0))
|
||||
goto err0;
|
||||
bw += rrd;
|
||||
if (unpdbg_likely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
if (pdbg_unlikely(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
goto err0;
|
||||
upload->uploaded += rrd;
|
||||
add_bytes_uploaded(rrd);
|
||||
|
|
@ -846,7 +846,7 @@ static int upload_from_file(psock_t *api, psync_upload_range_list_t *r,
|
|||
PAPI_NUM("hash", r->file.hash),
|
||||
PAPI_NUM("offset", r->off),
|
||||
PAPI_NUM("count", r->len)};
|
||||
if (unpdbg_likely(!papi_send_no_res(api, "upload_writefromfile", params)))
|
||||
if (pdbg_unlikely(!papi_send_no_res(api, "upload_writefromfile", params)))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
else {
|
||||
upload->uploaded += r->len;
|
||||
|
|
@ -865,7 +865,7 @@ static int upload_from_upload(psock_t *api, psync_upload_range_list_t *r,
|
|||
PAPI_NUM("readuploadid", r->uploadid),
|
||||
PAPI_NUM("offset", r->off),
|
||||
PAPI_NUM("count", r->len)};
|
||||
if (unpdbg_likely(!papi_send_no_res(api, "upload_writefromupload", params)))
|
||||
if (pdbg_unlikely(!papi_send_no_res(api, "upload_writefromupload", params)))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
else {
|
||||
upload->uploaded += r->len;
|
||||
|
|
@ -878,7 +878,7 @@ static int upload_get_checksum(psock_t *api, psync_uploadid_t uploadid,
|
|||
uint32_t id) {
|
||||
binparam params[] = {PAPI_STR("auth", psync_my_auth),
|
||||
PAPI_NUM("uploadid", uploadid), PAPI_NUM("id", id)};
|
||||
if (unpdbg_likely(!papi_send_no_res(api, "upload_info", params)))
|
||||
if (pdbg_unlikely(!papi_send_no_res(api, "upload_info", params)))
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
else
|
||||
return PSYNC_NET_OK;
|
||||
|
|
@ -1147,7 +1147,7 @@ static int upload_big_file(const char *localpath, const unsigned char *hashhex,
|
|||
? PSYNC_SOCK_READ_TIMEOUT * 1000
|
||||
: 0) != SOCKET_ERROR)) {
|
||||
res = papi_result(api);
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
goto err1;
|
||||
respwait--;
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
|
|
@ -1155,11 +1155,11 @@ static int upload_big_file(const char *localpath, const unsigned char *hashhex,
|
|||
id = papi_find_result2(res, "id", PARAM_NUM)->num;
|
||||
free(res);
|
||||
psync_process_api_error(result);
|
||||
if (unpdbg_likely(!id))
|
||||
if (pdbg_unlikely(!id))
|
||||
goto err1;
|
||||
while (respwait) {
|
||||
res = papi_result(api);
|
||||
if (unpdbg_likely(!res))
|
||||
if (pdbg_unlikely(!res))
|
||||
goto err1;
|
||||
respwait--;
|
||||
free(res);
|
||||
|
|
@ -1234,7 +1234,7 @@ static int upload_big_file(const char *localpath, const unsigned char *hashhex,
|
|||
pdbg_logf(D_BUG, "Invalid range type %u", (unsigned)le->type);
|
||||
goto err1;
|
||||
}
|
||||
if (unpdbg_likely(ret != PSYNC_NET_OK)) {
|
||||
if (pdbg_unlikely(ret != PSYNC_NET_OK)) {
|
||||
if (ret == PSYNC_NET_TEMPFAIL)
|
||||
goto err1;
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue