Migrate remaining 34 files to pmem_malloc/pmem_free
This commit is contained in:
parent
70dbe0104c
commit
7d10cf8d6c
|
|
@ -1,4 +1,5 @@
|
|||
// debug/psql_debug.c - debug-build strong overrides for psql lock/query functions.
|
||||
#include "../pmem.h"
|
||||
// Compiled only when BUILD=debug. Strong symbols here override the weak stubs in psql.c.
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
|
@ -98,7 +99,7 @@ static void record_wrunlock() {
|
|||
static void record_rdlock(const char *file, unsigned line,
|
||||
struct timespec *tm) {
|
||||
rd_lock_data *lock;
|
||||
lock = malloc(sizeof(rd_lock_data));
|
||||
lock = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(rd_lock_data));
|
||||
lock->file = file;
|
||||
lock->thread = psync_thread_name;
|
||||
lock->line = line;
|
||||
|
|
@ -282,7 +283,7 @@ void psql_rdunlock() {
|
|||
pdbg_logf(D_BUG,
|
||||
"held database read lock for %lu milliseconds taken at %s:%u", msec,
|
||||
lock->file, lock->line);
|
||||
free(lock);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, lock);
|
||||
} else
|
||||
plocks_unlock(&dblock);
|
||||
}
|
||||
|
|
@ -300,7 +301,7 @@ int psql_tryupgradeLock() {
|
|||
pdbg_assert(lockctr == 1);
|
||||
lockstart = rdlockstart;
|
||||
record_wrlock(lock->file, lock->line);
|
||||
free(lock);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, lock);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -369,7 +370,7 @@ psync_sql_res *psql_do_query_nocache(const char *sql, const char *file,
|
|||
return NULL;
|
||||
}
|
||||
cnt = sqlite3_column_count(stmt);
|
||||
res = (psync_sql_res *)malloc(sizeof(psync_sql_res) +
|
||||
res = (psync_sql_res *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_sql_res) +
|
||||
cnt * sizeof(psync_variant));
|
||||
res->stmt = stmt;
|
||||
res->sql = sql;
|
||||
|
|
@ -408,7 +409,7 @@ psync_sql_res *psql_do_query_rdlock_nocache(const char *sql,
|
|||
return NULL;
|
||||
}
|
||||
cnt = sqlite3_column_count(stmt);
|
||||
res = (psync_sql_res *)malloc(sizeof(psync_sql_res) +
|
||||
res = (psync_sql_res *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_sql_res) +
|
||||
cnt * sizeof(psync_variant));
|
||||
res->stmt = stmt;
|
||||
res->sql = sql;
|
||||
|
|
@ -454,7 +455,7 @@ psync_sql_res *psql_do_query_nolock_nocache(const char *sql, const char *file,
|
|||
return NULL;
|
||||
}
|
||||
cnt = sqlite3_column_count(stmt);
|
||||
res = (psync_sql_res *)malloc(sizeof(psync_sql_res) +
|
||||
res = (psync_sql_res *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_sql_res) +
|
||||
cnt * sizeof(psync_variant));
|
||||
res->stmt = stmt;
|
||||
res->sql = sql;
|
||||
|
|
@ -500,7 +501,7 @@ psync_sql_res *psql_do_prepare_nocache(const char *sql, const char *file,
|
|||
sql, sqlite3_errmsg(psync_db), file, line);
|
||||
return NULL;
|
||||
}
|
||||
res = malloc(sizeof(psync_sql_res));
|
||||
res = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_sql_res));
|
||||
res->stmt = stmt;
|
||||
res->sql = sql;
|
||||
res->column_count = 0;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "pcache.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plist.h"
|
||||
#include "psys.h"
|
||||
#include "ptimer.h"
|
||||
|
|
@ -80,8 +81,8 @@ static void cache_timer(psync_timer_t timer, void *ptr) {
|
|||
pthread_mutex_lock(&cachelocks[hash_to_lock(he->hash)]);
|
||||
psync_list_del(&he->list);
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(he->hash)]);
|
||||
he->free(he->value);
|
||||
free(he);
|
||||
he->pmem_free(PMEM_SUBSYS_OTHER, he->value);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, he);
|
||||
ptimer_stop(timer);
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +126,7 @@ void *pcache_get(const char *key) {
|
|||
psync_list_del(&he->list);
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(h)]);
|
||||
val = he->value;
|
||||
free(he);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, he);
|
||||
return val;
|
||||
}
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(h)]);
|
||||
|
|
@ -158,7 +159,7 @@ void pcache_add(const char *key, void *ptr, time_t freeafter,
|
|||
uint32_t h;
|
||||
h = compute_hash(key, &l);
|
||||
l++;
|
||||
he = (cache_entry_t *)malloc(offsetof(cache_entry_t, key) + l);
|
||||
he = (cache_entry_t *)pmem_malloc(PMEM_SUBSYS_OTHER, offsetof(cache_entry_t, key) + l);
|
||||
he->value = ptr;
|
||||
he->free = freefunc;
|
||||
he->hash = h;
|
||||
|
|
@ -172,7 +173,7 @@ void pcache_add(const char *key, void *ptr, time_t freeafter,
|
|||
!strcmp(key, he2->key) &&
|
||||
++l == maxkeys)) {
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(h)]);
|
||||
free(he);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, he);
|
||||
freefunc(ptr);
|
||||
// pdbg_logf(D_NOTICE, "not adding key %s to cache as there already %u
|
||||
// elements present", key, (unsigned int)maxkeys);
|
||||
|
|
@ -211,8 +212,8 @@ restart:
|
|||
continue;
|
||||
psync_list_del(&he->list);
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(h)]);
|
||||
he->free(he->value);
|
||||
free(he);
|
||||
he->pmem_free(PMEM_SUBSYS_OTHER, he->value);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, he);
|
||||
goto restart;
|
||||
}
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(h)]);
|
||||
|
|
@ -228,8 +229,8 @@ void pcache_clean() {
|
|||
he = psync_list_element(l1, cache_entry_t, list);
|
||||
if (!ptimer_stop(he->timer)) {
|
||||
psync_list_del(l1);
|
||||
he->free(he->value);
|
||||
free(he);
|
||||
he->pmem_free(PMEM_SUBSYS_OTHER, he->value);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, he);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(h)]);
|
||||
|
|
@ -255,8 +256,8 @@ void pcache_clean_oneof(const char **prefixes, size_t cnt) {
|
|||
continue;
|
||||
if (!ptimer_stop(he->timer)) {
|
||||
psync_list_del(l1);
|
||||
he->free(he->value);
|
||||
free(he);
|
||||
he->pmem_free(PMEM_SUBSYS_OTHER, he->value);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, he);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&cachelocks[hash_to_lock(h)]);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ char *psync_debug_path() {
|
|||
custom_path);
|
||||
} else {
|
||||
size_t len = strlen(custom_path) + 1;
|
||||
char *path = (char *)malloc(len);
|
||||
char *path = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, len);
|
||||
if (!path) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -127,14 +127,14 @@ char *psync_debug_path() {
|
|||
|
||||
const char *subdir = "/.pcloud/debug.log";
|
||||
size_t len = strlen(home) + strlen(subdir) + 1;
|
||||
char *sockpath = (char *)malloc(len);
|
||||
char *sockpath = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, len);
|
||||
if (!sockpath) {
|
||||
free(home);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, home);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf(sockpath, len, "%s%s", home, subdir);
|
||||
free(home);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, home);
|
||||
return sockpath;
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ char *pfs_event_log_path() {
|
|||
const char *custom_path = getenv("PCLOUD_FS_EVENT_LOG");
|
||||
if (custom_path && custom_path[0] != '\0') {
|
||||
size_t len = strlen(custom_path) + 1;
|
||||
char *path = (char *)malloc(len);
|
||||
char *path = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, len);
|
||||
if (!path) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -189,12 +189,12 @@ int pdbg_printf(const char *file, const char *function, int unsigned line, int u
|
|||
char *path = psync_debug_path();
|
||||
int fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0600);
|
||||
if (fd == -1) {
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
return 1;
|
||||
}
|
||||
log_file = fdopen(fd, "a");
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
if (!log_file) {
|
||||
close(fd);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
|
|
@ -212,7 +212,7 @@ int pdbg_printf(const char *file, const char *function, int unsigned line, int u
|
|||
if (fd != -1) {
|
||||
close(fd);
|
||||
}
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ static void do_reopen_log() {
|
|||
path = psync_debug_path();
|
||||
if (path) {
|
||||
fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0600);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
if (fd != -1) {
|
||||
new_log = fdopen(fd, "a");
|
||||
if (new_log) {
|
||||
|
|
@ -274,7 +274,7 @@ static void do_reopen_log() {
|
|||
path = pfs_event_log_path();
|
||||
if (path) {
|
||||
fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0600);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
if (fd != -1) {
|
||||
new_log = fdopen(fd, "a");
|
||||
if (new_log) {
|
||||
|
|
@ -310,7 +310,7 @@ void pdbg_write_fs_event(const char *fmt, ...) {
|
|||
return;
|
||||
}
|
||||
int fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0600);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
if (fd == -1) {
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ struct _psync_deflate_t {
|
|||
psync_deflate_t *pdeflate_init(int level) {
|
||||
psync_deflate_t *def;
|
||||
int ret;
|
||||
def = malloc(sizeof(psync_deflate_t));
|
||||
def = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_deflate_t));
|
||||
memset(&def->stream, 0, sizeof(def->stream));
|
||||
def->flushbuff = NULL;
|
||||
def->bufferstartoff = 0;
|
||||
|
|
@ -74,7 +74,7 @@ psync_deflate_t *pdeflate_init(int level) {
|
|||
if (pdbg_likely(ret == Z_OK))
|
||||
return def;
|
||||
else {
|
||||
free(def);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, def);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -84,8 +84,8 @@ void pdeflate_destroy(psync_deflate_t *def) {
|
|||
deflateEnd(&def->stream);
|
||||
else
|
||||
inflateEnd(&def->stream);
|
||||
free(def->flushbuff);
|
||||
free(def);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, def->flushbuff);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, def);
|
||||
}
|
||||
|
||||
static int psync_deflate_set_out_buff(psync_deflate_t *def) {
|
||||
|
|
@ -140,7 +140,7 @@ static int psync_deflate_finish_flush_add_buffer(psync_deflate_t *def,
|
|||
uint32_t alloced, used, current;
|
||||
int ret;
|
||||
alloced = 4096;
|
||||
buff = malloc(sizeof(unsigned char) * alloced);
|
||||
buff = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(unsigned char) * alloced);
|
||||
current = alloced;
|
||||
used = 0;
|
||||
def->flags &= ~FLAG_MORE_DATA;
|
||||
|
|
@ -153,7 +153,7 @@ static int psync_deflate_finish_flush_add_buffer(psync_deflate_t *def,
|
|||
if (ret != Z_BUF_ERROR)
|
||||
return ret;
|
||||
if (used == 0) {
|
||||
free(buff);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, buff);
|
||||
return Z_OK;
|
||||
}
|
||||
def->flushbuff = buff;
|
||||
|
|
@ -215,7 +215,7 @@ int pdeflate_read(psync_deflate_t *def, void *data, int len) {
|
|||
memcpy(data, def->flushbuff + def->flushbuffoff, len);
|
||||
def->flushbuffoff += len;
|
||||
if (def->flushbuffoff == def->flushbufflen) {
|
||||
free(def->flushbuff);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, def->flushbuff);
|
||||
def->flushbuff = NULL;
|
||||
}
|
||||
return len;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "pdownload.h"
|
||||
#include "pfoldersync.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plocalscan.h"
|
||||
#include "pnetlibs.h"
|
||||
#include "pp2p.h"
|
||||
|
|
@ -162,8 +163,8 @@ static void do_move(void *ptr, ppath_stat *st) {
|
|||
oldpath = putil_strcat(arr[0], st->name, NULL);
|
||||
newpath = putil_strcat(arr[1], st->name, NULL);
|
||||
pfile_rename(oldpath, newpath);
|
||||
free(newpath);
|
||||
free(oldpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, newpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, oldpath);
|
||||
}
|
||||
|
||||
static int move_folder_contents(const char *oldpath, const char *newpath) {
|
||||
|
|
@ -243,7 +244,7 @@ static int call_func_for_folder(psync_folderid_t localfolderid,
|
|||
psyncer_folder_dec_tasks(localfolderid);
|
||||
pdbg_logf(D_NOTICE, "%s %s", debug, localpath);
|
||||
}
|
||||
free(localpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, localpath);
|
||||
} else {
|
||||
pdbg_logf(D_ERROR, "could not get path for local folder id %lu, syncid %u",
|
||||
(long unsigned)localfolderid, (unsigned)syncid);
|
||||
|
|
@ -270,7 +271,7 @@ static int call_func_for_folder_name(psync_folderid_t localfolderid,
|
|||
psyncer_folder_dec_tasks(localfolderid);
|
||||
pdbg_logf(D_NOTICE, "%s %s", debug, localpath);
|
||||
}
|
||||
free(localpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, localpath);
|
||||
} else {
|
||||
pdbg_logf(D_ERROR, "could not get path for local folder id %lu, syncid %u",
|
||||
(long unsigned)localfolderid, (unsigned)syncid);
|
||||
|
|
@ -376,7 +377,7 @@ static int task_renamefolder(psync_syncid_t newsyncid,
|
|||
newpath = pfolder_lpath_lfldr(localfolderid, newsyncid, NULL);
|
||||
if (unlikely(!newpath)) {
|
||||
psql_rollback();
|
||||
free(oldpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, oldpath);
|
||||
pdbg_logf(D_ERROR, "could not get local path for folder id %lu",
|
||||
(unsigned long)localfolderid);
|
||||
return 0;
|
||||
|
|
@ -391,8 +392,8 @@ static int task_renamefolder(psync_syncid_t newsyncid,
|
|||
folderid);
|
||||
pdbg_logf(D_NOTICE, "local folder renamed from %s to %s", oldpath, newpath);
|
||||
}
|
||||
free(newpath);
|
||||
free(oldpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, newpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, oldpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -668,7 +669,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
pdbg_logf(D_NOTICE, "file %s copied from %s", dt->localname, tmpold);
|
||||
} else
|
||||
pdbg_logf(D_WARNING, "failed to copy %s from %s", dt->localname, tmpold);
|
||||
free(tmpold);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, tmpold);
|
||||
tmpold = NULL;
|
||||
if (pdbg_likely(rt == PSYNC_NET_OK))
|
||||
return 0;
|
||||
|
|
@ -702,10 +703,10 @@ static int task_download_file(download_task_t *dt) {
|
|||
pdbg_logf(D_WARNING, "got error %lu from getfilelink", (long unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL) {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, res);
|
||||
return -1;
|
||||
} else {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, res);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -720,7 +721,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
putil_strcat(dt->localpath, "/", dt->filename,
|
||||
"-old", PSYNC_APPEND_PARTIAL_FILES, NULL);
|
||||
if (pfile_rename_overwrite(dt->tmpname, tmpold)) {
|
||||
free(tmpold);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, tmpold);
|
||||
tmpold = NULL;
|
||||
} else
|
||||
oldfiles[oldcnt++] = tmpold;
|
||||
|
|
@ -742,7 +743,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
requestpath = papi_find_result2(res, "path", PARAM_STR)->str;
|
||||
putil_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
papi_find_result2(res, "dwltag", PARAM_STR)->str);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = pmem_malloc(PMEM_SUBSYS_DOWNLOAD, PSYNC_COPY_BUFFER_SIZE);
|
||||
http = NULL;
|
||||
psync_hash_init(&hashctx);
|
||||
psync_list_for_each_element(range, &ranges, psync_range_list_t, list) {
|
||||
|
|
@ -837,7 +838,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
}
|
||||
if (pdbg_unlikely(pfile_sync(fd)))
|
||||
goto err2;
|
||||
free(buff);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, buff);
|
||||
psync_hash_final(localhashbin, &hashctx);
|
||||
if (pdbg_unlikely(pfile_close(fd)))
|
||||
goto err0;
|
||||
|
|
@ -865,13 +866,13 @@ static int task_download_file(download_task_t *dt) {
|
|||
psync_list_for_each_element_call(&ranges, psync_range_list_t, list, free);
|
||||
if (tmpold) {
|
||||
pfile_delete(tmpold);
|
||||
free(tmpold);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, tmpold);
|
||||
}
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, res);
|
||||
return 0;
|
||||
err2:
|
||||
psync_hash_final(localhashbin, &hashctx); /* just in case */
|
||||
free(buff);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, buff);
|
||||
if (http)
|
||||
psync_http_close(http);
|
||||
err1:
|
||||
|
|
@ -880,9 +881,9 @@ err0:
|
|||
psync_list_for_each_element_call(&ranges, psync_range_list_t, list, free);
|
||||
if (tmpold) {
|
||||
pfile_delete(tmpold);
|
||||
free(tmpold);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, tmpold);
|
||||
}
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -910,7 +911,7 @@ static int task_delete_file(psync_syncid_t syncid, psync_fileid_t fileid,
|
|||
(int)errno);
|
||||
if (errno == EBUSY || errno == EROFS) {
|
||||
ret = -1;
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, name);
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
|
|
@ -919,7 +920,7 @@ static int task_delete_file(psync_syncid_t syncid, psync_fileid_t fileid,
|
|||
// events are not fully implemented anyway
|
||||
// pqevent_queue_sync_event_path(PEVENT_LOCAL_FILE_DELETED, row[1], name,
|
||||
// fileid, remotepath);
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, name);
|
||||
}
|
||||
stmt = psql_prepare("DELETE FROM localfile WHERE id=?");
|
||||
psql_bind_uint(stmt, 1, row[0]);
|
||||
|
|
@ -972,7 +973,7 @@ static int task_rename_file(psync_syncid_t oldsyncid, psync_syncid_t newsyncid,
|
|||
return 0;
|
||||
oldpath = pfolder_lpath_lfile(lfileid, NULL);
|
||||
if (pdbg_unlikely(!oldpath)) {
|
||||
free(newfolder);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, newfolder);
|
||||
return 0;
|
||||
}
|
||||
newpath = putil_strcat(newfolder, "/", newname, NULL);
|
||||
|
|
@ -1003,9 +1004,9 @@ static int task_rename_file(psync_syncid_t oldsyncid, psync_syncid_t newsyncid,
|
|||
}
|
||||
psync_resume_localscan();
|
||||
}
|
||||
free(newpath);
|
||||
free(oldpath);
|
||||
free(newfolder);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, newpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, oldpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, newfolder);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1038,10 +1039,10 @@ static void free_download_task(download_task_t *dt) {
|
|||
}
|
||||
if (dt->lock)
|
||||
psync_unlock_file(dt->lock);
|
||||
free(dt->localpath);
|
||||
free(dt->localname);
|
||||
free(dt->tmpname);
|
||||
free(dt);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, dt->localpath);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, dt->localname);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, dt->tmpname);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, dt);
|
||||
}
|
||||
|
||||
static void free_task_timer_thread(void *ptr) {
|
||||
|
|
@ -1202,7 +1203,7 @@ static int task_run_download_file(uint64_t taskid, psync_syncid_t syncid,
|
|||
tmpname = putil_strcat(localpath, "/", filename,
|
||||
PSYNC_APPEND_PARTIAL_FILES, NULL);
|
||||
len = strlen(filename);
|
||||
dt = (download_task_t *)malloc(offsetof(download_task_t, filename) +
|
||||
dt = (download_task_t *)pmem_malloc(PMEM_SUBSYS_DOWNLOAD, offsetof(download_task_t, filename) +
|
||||
len + 1);
|
||||
memset(dt, 0, offsetof(download_task_t, filename));
|
||||
dt->taskid = taskid;
|
||||
|
|
@ -1341,7 +1342,7 @@ static void task_del_folder_rec_do(const char *localpath,
|
|||
psync_get_string(vrow[1]), NULL);
|
||||
pdbg_logf(D_NOTICE, "deleting %s", nm);
|
||||
pfile_delete(nm);
|
||||
free(nm);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, nm);
|
||||
}
|
||||
psql_free(res);
|
||||
res = psql_prepare(
|
||||
|
|
@ -1357,7 +1358,7 @@ static void task_del_folder_rec_do(const char *localpath,
|
|||
nm = putil_strcat(localpath, "/",
|
||||
psync_get_string(vrow[1]), NULL);
|
||||
task_del_folder_rec_do(nm, psync_get_number(vrow[0]), syncid);
|
||||
free(nm);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, nm);
|
||||
}
|
||||
psql_free(res);
|
||||
res = psql_prepare(
|
||||
|
|
@ -1467,7 +1468,7 @@ static int download_task(uint64_t taskid, uint32_t type, psync_syncid_t syncid,
|
|||
pdbg_logf(D_WARNING, "task of type %u, syncid %u, id %lu localid %lu failed",
|
||||
(unsigned)type, (unsigned)syncid, (unsigned long)itemid,
|
||||
(unsigned long)localitemid);
|
||||
free(vname);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, vname);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -1499,7 +1500,7 @@ static void download_thread() {
|
|||
}
|
||||
} else if (type != PSYNC_DOWNLOAD_FILE)
|
||||
psys_sleep_milliseconds(PSYNC_SLEEP_ON_FAILED_DOWNLOAD);
|
||||
free(row);
|
||||
pmem_free(PMEM_SUBSYS_DOWNLOAD, row);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1594,7 +1595,7 @@ download_hashes_t *pdownload_get_hashes() {
|
|||
cnt = 0;
|
||||
pthread_mutex_lock(¤t_downloads_mutex);
|
||||
psync_list_for_each_element(dwl, &downloads, download_list_t, list) cnt++;
|
||||
ret = (download_hashes_t *)malloc(
|
||||
ret = (download_hashes_t *)pmem_malloc(PMEM_SUBSYS_DOWNLOAD,
|
||||
offsetof(download_hashes_t, hashes) +
|
||||
sizeof(psync_hex_hash) * cnt);
|
||||
cnt = 0;
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ static void psync_file_preread_thread(void *ptr) {
|
|||
pr->count -= rd;
|
||||
}
|
||||
pfile_close(pr->fd);
|
||||
free(pr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, pr);
|
||||
}
|
||||
|
||||
int pfile_preread(int fd, uint64_t offset, size_t count) {
|
||||
|
|
@ -282,7 +282,7 @@ int pfile_preread(int fd, uint64_t offset, size_t count) {
|
|||
cfd = pfile_dup(fd);
|
||||
if (cfd == INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
pr = malloc(sizeof(psync_file_preread_t));
|
||||
pr = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_file_preread_t));
|
||||
pr->offset = offset;
|
||||
pr->count = count;
|
||||
pr->fd = cfd;
|
||||
|
|
@ -422,7 +422,7 @@ int pfile_run_update(const char *path) {
|
|||
ex = putil_strcat(PSYNC_RUN_CMD " \"", path, "\"", NULL);
|
||||
execl("/bin/sh", "/bin/sh", "-c", ex, NULL);
|
||||
pdbg_logf(D_ERROR, "exec of %s failed", ex);
|
||||
free(ex);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ex);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
161
pclsync/pfs.c
161
pclsync/pfs.c
|
|
@ -51,6 +51,7 @@
|
|||
#include "pfsupload.h"
|
||||
#include "pfsxattr.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "pnetlibs.h"
|
||||
#include "ppagecache.h"
|
||||
#include "ppath.h"
|
||||
|
|
@ -142,12 +143,12 @@ static void delete_log_files(psync_openfile_t *of) {
|
|||
filename =
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
pfile_delete(filename);
|
||||
free(filename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filename);
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'f';
|
||||
filename =
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
pfile_delete(filename);
|
||||
free(filename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filename);
|
||||
}
|
||||
|
||||
int pfs_update_openfile(uint64_t taskid, uint64_t writeid,
|
||||
|
|
@ -340,7 +341,7 @@ int pfs_rename_openfile_locked(psync_fsfileid_t fileid,
|
|||
pthread_mutex_unlock(&fl->mutex);
|
||||
return -ENOMEM;
|
||||
}
|
||||
free(fl->currentname);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fl->currentname);
|
||||
fl->currentname = newname;
|
||||
pthread_mutex_unlock(&fl->mutex);
|
||||
return 1;
|
||||
|
|
@ -652,7 +653,7 @@ static int psync_creat_local_to_file_stat(psync_fstask_creat_t *cr,
|
|||
stret = stat(filename, &st);
|
||||
if (stret)
|
||||
pdbg_logf(D_NOTICE, "could not stat file %s", filename);
|
||||
free(filename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filename);
|
||||
}
|
||||
if (stret)
|
||||
return -1;
|
||||
|
|
@ -661,7 +662,7 @@ static int psync_creat_local_to_file_stat(psync_fstask_creat_t *cr,
|
|||
else{
|
||||
fileidhex[sizeof(psync_fsfileid_t)]='i';
|
||||
filename=putil_strcat(cachepath, "/", fileidhex,
|
||||
NULL); fd=pfile_open(filename, O_RDONLY, 0); free(filename); if
|
||||
NULL); fd=pfile_open(filename, O_RDONLY, 0); pmem_free(PMEM_SUBSYS_OTHER, filename); if
|
||||
(fd==INVALID_HANDLE_VALUE) return -EIO; stret=pfile_pread(fd, &osize,
|
||||
sizeof(osize), offsetof(index_header, copyfromoriginal));
|
||||
pfile_close(fd);
|
||||
|
|
@ -819,12 +820,12 @@ static int pfs_getattr(const char *path, struct FUSE_STAT *stbuf) {
|
|||
if (mk) {
|
||||
if (mk->flags & PSYNC_FOLDER_FLAG_INVISIBLE) {
|
||||
psql_rdunlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return -ENOENT;
|
||||
}
|
||||
psync_mkdir_to_folder_stat(mk, stbuf);
|
||||
psql_rdunlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -839,7 +840,7 @@ static int pfs_getattr(const char *path, struct FUSE_STAT *stbuf) {
|
|||
psql_free(res);
|
||||
if (row) {
|
||||
psql_rdunlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -860,7 +861,7 @@ static int pfs_getattr(const char *path, struct FUSE_STAT *stbuf) {
|
|||
} else
|
||||
crr = -1;
|
||||
psql_rdunlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
if (row || !crr)
|
||||
return 0;
|
||||
pdbg_logf(D_NOTICE, "returning ENOENT for %s", path);
|
||||
|
|
@ -877,7 +878,7 @@ static int filler_decoded(pcrypto_textdec_t dec,
|
|||
if (!namedec)
|
||||
return 0;
|
||||
ret = filler(buf, namedec, st, off);
|
||||
free(namedec);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, namedec);
|
||||
return ret;
|
||||
} else
|
||||
return filler(buf, name, st, off);
|
||||
|
|
@ -1042,10 +1043,10 @@ pfs_create_file(psync_fsfileid_t fileid, psync_fsfileid_t remotefileid,
|
|||
}
|
||||
}
|
||||
if (encoder == PSYNC_CRYPTO_INVALID_ENCODER) {
|
||||
fl = (psync_openfile_t *)malloc(offsetof(psync_openfile_t, encoder));
|
||||
fl = (psync_openfile_t *)pmem_malloc(PMEM_SUBSYS_OTHER, offsetof(psync_openfile_t, encoder));
|
||||
memset(fl, 0, offsetof(psync_openfile_t, encoder));
|
||||
} else {
|
||||
fl = malloc(sizeof(psync_openfile_t));
|
||||
fl = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_openfile_t));
|
||||
memset(fl, 0, sizeof(psync_openfile_t));
|
||||
size = pfs_crpt_plain_size(size);
|
||||
}
|
||||
|
|
@ -1161,7 +1162,7 @@ static int open_write_files(psync_openfile_t *of, int trunc) {
|
|||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
of->datafile = pfile_open(filename, O_RDWR,
|
||||
O_CREAT | (trunc ? O_TRUNC : 0));
|
||||
free(filename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filename);
|
||||
if (of->datafile == INVALID_HANDLE_VALUE) {
|
||||
pdbg_logf(D_ERROR, "could not open cache file for fileid %ld",
|
||||
(long)of->fileid);
|
||||
|
|
@ -1187,7 +1188,7 @@ static int open_write_files(psync_openfile_t *of, int trunc) {
|
|||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
of->indexfile = pfile_open(filename, O_RDWR,
|
||||
O_CREAT | (trunc ? O_TRUNC : 0));
|
||||
free(filename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filename);
|
||||
if (of->indexfile == INVALID_HANDLE_VALUE) {
|
||||
pdbg_logf(D_ERROR, "could not open cache index file for fileid %ld",
|
||||
(long)of->fileid);
|
||||
|
|
@ -1206,7 +1207,7 @@ static int open_write_files(psync_openfile_t *of, int trunc) {
|
|||
filename =
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
of->logfile = pfile_open(filename, O_RDWR, O_CREAT | O_TRUNC);
|
||||
free(filename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filename);
|
||||
if (of->logfile == INVALID_HANDLE_VALUE) {
|
||||
pdbg_logf(D_ERROR, "could not open log file for fileid %ld",
|
||||
(long)of->fileid);
|
||||
|
|
@ -1244,13 +1245,13 @@ static void pfs_del_creat(psync_fspath_t *fpath, psync_openfile_t *of) {
|
|||
if (likely((cr = pfs_task_find_creat(folder, fpath->name, 0)))) {
|
||||
ptree_del(&folder->creats, &cr->tree);
|
||||
folder->taskscnt--;
|
||||
free(cr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, cr);
|
||||
}
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
}
|
||||
pfs_dec_of_refcnt(of);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
}
|
||||
|
||||
static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
||||
|
|
@ -1287,14 +1288,14 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
if ((fi->flags & 3) != O_RDONLY &&
|
||||
!(fpath->permissions & PSYNC_PERM_MODIFY)) {
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return -EACCES;
|
||||
}
|
||||
// even if there are existing files there, just don't allow opening those
|
||||
if (fpath->flags & (PSYNC_FOLDER_FLAG_BACKUP_DEVICE_LIST |
|
||||
PSYNC_FOLDER_FLAG_BACKUP_DEVICE)) {
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return -EACCES;
|
||||
}
|
||||
folder = pfs_task_get_or_create_folder_tasks_locked(fpath->folderid);
|
||||
|
|
@ -1354,7 +1355,7 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
pdbg_logf(D_NOTICE, "opening new file %ld %s", (long)fileid, fpath->name);
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
of->newfile = 1;
|
||||
of->releasedforupload = status != 1;
|
||||
ret = open_write_files(of, fi->flags & O_TRUNC);
|
||||
|
|
@ -1408,7 +1409,7 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
of->canmodify = (fpath->permissions & PSYNC_PERM_MODIFY) != 0;
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
of->newfile = 0;
|
||||
of->releasedforupload = status != 1;
|
||||
ret = open_write_files(of, fi->flags & O_TRUNC);
|
||||
|
|
@ -1432,7 +1433,7 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
of->canmodify = (fpath->permissions & PSYNC_PERM_MODIFY) != 0;
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
of->modified = 1;
|
||||
of->staticfile = 1;
|
||||
of->staticdata = (const char *)lc->data;
|
||||
|
|
@ -1490,7 +1491,7 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
encoder = pcrypto_sec_encdec_create(symkey);
|
||||
psymkey_free(symkey);
|
||||
if (pdbg_unlikely(encoder == PSYNC_CRYPTO_INVALID_ENCODER)) {
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
ret = -ENOMEM;
|
||||
goto ex0;
|
||||
}
|
||||
|
|
@ -1502,7 +1503,7 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
}
|
||||
cr =
|
||||
pfs_task_add_creat(folder, fpath->name, 0, encsymkey, encsymkeylen);
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
ret = -EIO;
|
||||
goto ex0;
|
||||
|
|
@ -1521,7 +1522,7 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
pfs_del_creat(fpath, of);
|
||||
return ret;
|
||||
}
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
fi->fh = openfile_to_fh(of);
|
||||
return 0;
|
||||
} else if (row) {
|
||||
|
|
@ -1545,7 +1546,7 @@ static int pfs_open(const char *path, struct fuse_file_info *fi) {
|
|||
ex0:
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1579,7 +1580,7 @@ static int pfs_creat_fake_locked(psync_fspath_t *fpath,
|
|||
size_t len;
|
||||
fileid = psync_fake_fileid++;
|
||||
len = strlen(fpath->name) + 1;
|
||||
cr = (psync_fstask_creat_t *)malloc(
|
||||
cr = (psync_fstask_creat_t *)pmem_malloc(PMEM_SUBSYS_OTHER,
|
||||
offsetof(psync_fstask_creat_t, name) + len);
|
||||
cr->fileid = fileid;
|
||||
cr->rfileid = 0;
|
||||
|
|
@ -1594,7 +1595,7 @@ static int pfs_creat_fake_locked(psync_fspath_t *fpath,
|
|||
of->newfile = 0;
|
||||
of->modified = 0;
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
fi->fh = openfile_to_fh(of);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1633,7 +1634,7 @@ static int pfs_creat(const char *path, mode_t mode,
|
|||
(fpath->flags & (PSYNC_FOLDER_FLAG_BACKUP_DEVICE_LIST |
|
||||
PSYNC_FOLDER_FLAG_BACKUP_DEVICE))) {
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return -EACCES;
|
||||
}
|
||||
folder = pfs_task_get_or_create_folder_tasks_locked(fpath->folderid);
|
||||
|
|
@ -1642,14 +1643,14 @@ static int pfs_creat(const char *path, mode_t mode,
|
|||
pdbg_logf(D_NOTICE, "file %s already exists, processing as open", path);
|
||||
ret = pfs_open(path, fi);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return ret;
|
||||
}
|
||||
if (fpath->flags & PSYNC_FOLDER_FLAG_ENCRYPTED) {
|
||||
if (psync_crypto_isexpired()) {
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return -pdbg_return_const(PSYNC_FS_ERR_CRYPTO_EXPIRED);
|
||||
}
|
||||
encsymkey = pcryptofolder_filencoder_key_newplain(
|
||||
|
|
@ -1657,7 +1658,7 @@ static int pfs_creat(const char *path, mode_t mode,
|
|||
if (pdbg_unlikely(psync_crypto_is_error(encsymkey))) {
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return -pfs_crypto_err_to_errno(psync_crypto_to_error(encsymkey));
|
||||
}
|
||||
encoder = pcrypto_sec_encdec_create(symkey);
|
||||
|
|
@ -1665,8 +1666,8 @@ static int pfs_creat(const char *path, mode_t mode,
|
|||
if (pdbg_unlikely(encoder == PSYNC_CRYPTO_INVALID_ENCODER)) {
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
return -ENOMEM;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1676,11 +1677,11 @@ static int pfs_creat(const char *path, mode_t mode,
|
|||
}
|
||||
cr = pfs_task_add_creat(folder, fpath->name, 0, encsymkey, encsymkeylen);
|
||||
if (encsymkey)
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return -EIO;
|
||||
}
|
||||
of = pfs_create_file(cr->fileid, 0, 0, 0, 1, 0,
|
||||
|
|
@ -1696,7 +1697,7 @@ static int pfs_creat(const char *path, mode_t mode,
|
|||
pfs_del_creat(fpath, of);
|
||||
return ret;
|
||||
}
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
fi->fh = openfile_to_fh(of);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1757,13 +1758,13 @@ static void pfs_free_openfile(psync_openfile_t *of) {
|
|||
if (cr) {
|
||||
ptree_del(&of->currentfolder->creats, &cr->tree);
|
||||
of->currentfolder->taskscnt--;
|
||||
free(cr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, cr);
|
||||
}
|
||||
psql_unlock();
|
||||
}
|
||||
pfs_task_release_folder_tasks(of->currentfolder);
|
||||
free(of->currentname);
|
||||
free(of);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, of->currentname);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, of);
|
||||
}
|
||||
|
||||
static void pfs_get_both_locks(psync_openfile_t *of) {
|
||||
|
|
@ -1837,7 +1838,7 @@ static void pfs_upload_release_timer(void *ptr) {
|
|||
psql_run_free(res);
|
||||
}
|
||||
pfs_dec_of_refcnt(ofw->of);
|
||||
free(ofw);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ofw);
|
||||
pstatus_upload_recalc_async();
|
||||
}
|
||||
|
||||
|
|
@ -1862,7 +1863,7 @@ static void pfs_write_timer(psync_timer_t timer, void *ptr) {
|
|||
goto unlock_ex;
|
||||
}
|
||||
of->releasedforupload = 1;
|
||||
ofw = malloc(sizeof(psync_openfile_writeid_t));
|
||||
ofw = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_openfile_writeid_t));
|
||||
ofw->of = of;
|
||||
ofw->writeid = of->writeid;
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
|
|
@ -2184,7 +2185,7 @@ pfs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
if (pdbg_unlikely(!cr)) {
|
||||
psql_unlock();
|
||||
ppagecache_unlock_pages();
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
return -EIO;
|
||||
}
|
||||
pfs_update_openfile_fileid_locked(of, cr->fileid);
|
||||
|
|
@ -2195,7 +2196,7 @@ pfs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
ret = open_write_files(of, 0);
|
||||
if (pdbg_unlikely(ret)) {
|
||||
ppagecache_unlock_pages();
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
return ret;
|
||||
}
|
||||
if (of->origctime)
|
||||
|
|
@ -2205,7 +2206,7 @@ pfs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
of, of->hash, size);
|
||||
ppagecache_unlock_pages();
|
||||
if (pdbg_unlikely(ret)) {
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
|
@ -2215,7 +2216,7 @@ pfs_reopen_file_for_writing(psync_openfile_t *of) {
|
|||
cr = pfs_task_add_modified_file(of->currentfolder, of->currentname,
|
||||
of->fileid, of->hash, encsymkey,
|
||||
encsymkeylen);
|
||||
free(encsymkey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encsymkey);
|
||||
if (pdbg_unlikely(!cr)) {
|
||||
psql_unlock();
|
||||
return -EIO;
|
||||
|
|
@ -2271,13 +2272,13 @@ pfs_reopen_static_file_for_writing(psync_openfile_t *of) {
|
|||
if (pdbg_likely(cr)) {
|
||||
ptree_del(&of->currentfolder->creats, &cr->tree);
|
||||
of->currentfolder->taskscnt--;
|
||||
free(cr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, cr);
|
||||
}
|
||||
un = pfs_task_find_unlink(of->currentfolder, of->currentname, taskid);
|
||||
if (pdbg_likely(un)) {
|
||||
ptree_del(&of->currentfolder->unlinks, &un->tree);
|
||||
of->currentfolder->taskscnt--;
|
||||
free(un);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, un);
|
||||
}
|
||||
psql_unlock();
|
||||
of->writeid = 0;
|
||||
|
|
@ -2556,7 +2557,7 @@ static int pfs_mkdir(const char *path, mode_t mode) {
|
|||
else
|
||||
ret = pfs_task_mkdir(fpath->folderid, fpath->name, fpath->flags);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
pdbg_logf(D_NOTICE, "mkdir %s=%d", path, ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -2576,7 +2577,7 @@ static int pfs_can_rmdir(const char *path) {
|
|||
else
|
||||
ret = pfs_task_can_rmdir(fpath->folderid, fpath->flags, fpath->name);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
pdbg_logf(D_NOTICE, "can_rmdir %s=%d", path, ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -2597,7 +2598,7 @@ static int pfs_rmdir(const char *path) {
|
|||
else
|
||||
ret = pfs_task_rmdir(fpath->folderid, fpath->flags, fpath->name);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
pdbg_logf(D_NOTICE, "rmdir %s=%d", path, ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -2617,7 +2618,7 @@ static int pfs_can_unlink(const char *path) {
|
|||
else
|
||||
ret = pfs_task_can_unlink(fpath->folderid, fpath->name);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
pdbg_logf(D_NOTICE, "can_unlink %s=%d", path, ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -2648,7 +2649,7 @@ static int pfs_unlink(const char *path) {
|
|||
(void *)PEVENT_BKUP_F_DEL_DRIVE);
|
||||
}
|
||||
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
pdbg_logf(D_NOTICE, "unlink %s=%d", path, ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -2669,22 +2670,22 @@ static int pfs_rename_static_file(psync_fstask_folder_t *srcfolder,
|
|||
un = pfs_task_find_unlink(dstfolder, new_name, cr->taskid);
|
||||
if (un) {
|
||||
ptree_del(&dstfolder->unlinks, &un->tree);
|
||||
free(un);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, un);
|
||||
dstfolder->taskscnt--;
|
||||
}
|
||||
ptree_del(&dstfolder->creats, &cr->tree);
|
||||
free(cr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, cr);
|
||||
dstfolder->taskscnt--;
|
||||
}
|
||||
len = strlen(new_name) + 1;
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
un = (psync_fstask_unlink_t *)pmem_malloc(PMEM_SUBSYS_OTHER,
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->fileid = 0;
|
||||
un->taskid = srccr->taskid;
|
||||
memcpy(un->name, new_name, len);
|
||||
pfs_task_inject_unlink(dstfolder, un);
|
||||
addlen = pfs_task_creat_local_offset(len - 1);
|
||||
cr = (psync_fstask_creat_t *)malloc(addlen +
|
||||
cr = (psync_fstask_creat_t *)pmem_malloc(PMEM_SUBSYS_OTHER, addlen +
|
||||
sizeof(psync_fstask_local_creat_t));
|
||||
cr->fileid = 0;
|
||||
cr->rfileid = 0;
|
||||
|
|
@ -2697,11 +2698,11 @@ static int pfs_rename_static_file(psync_fstask_folder_t *srcfolder,
|
|||
un = pfs_task_find_unlink(srcfolder, srccr->name, srccr->taskid);
|
||||
if (pdbg_likely(un)) {
|
||||
ptree_del(&srcfolder->unlinks, &un->tree);
|
||||
free(un);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, un);
|
||||
srcfolder->taskscnt--;
|
||||
}
|
||||
ptree_del(&srcfolder->creats, &srccr->tree);
|
||||
free(srccr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, srccr);
|
||||
srcfolder->taskscnt--;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3018,16 +3019,16 @@ finish:
|
|||
if (folder)
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fold_path);
|
||||
free(fnew_path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fold_path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fnew_path);
|
||||
return pdbg_returnf(ret, " for rename from %s to %s", old_path,
|
||||
new_path);
|
||||
err_enoent:
|
||||
if (folder)
|
||||
pfs_task_release_folder_tasks_locked(folder);
|
||||
psql_unlock();
|
||||
free(fold_path);
|
||||
free(fnew_path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fold_path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fnew_path);
|
||||
pdbg_logf(D_NOTICE, "returning ENOENT, folder not found");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
@ -3117,7 +3118,7 @@ static int pfs_set_filetime_locked(psync_fsfileid_t fileid,
|
|||
pdbg_logf(D_NOTICE, "setting %s time of %s to %lu=%d",
|
||||
crtime ? "creation" : "modification", filename,
|
||||
(unsigned long)tv->tv_sec, ret);
|
||||
free(filename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filename);
|
||||
return ret ? -EACCES : 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -3216,7 +3217,7 @@ static int pfs_set_time(const char *path, const struct timespec *tv,
|
|||
else
|
||||
ret = pfs_set_time_locked(fpath->folderid, fpath->name, tv, crtime);
|
||||
psql_unlock();
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -3339,7 +3340,7 @@ static void psync_invalidate_os_cache_noret() {
|
|||
pthread_mutex_unlock(&start_mutex);
|
||||
if (path) {
|
||||
pfile_invalidate_os_cache(path);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3412,7 +3413,7 @@ void pfs_refresh_folder(psync_folderid_t folderid) {
|
|||
} else
|
||||
fpath = NULL;
|
||||
pthread_mutex_unlock(&start_mutex);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
if (!fpath)
|
||||
return;
|
||||
if (pfile_invalidate_os_cache_needed())
|
||||
|
|
@ -3425,7 +3426,7 @@ void pfs_refresh_folder(psync_folderid_t folderid) {
|
|||
pfile_delete(fpath);
|
||||
}
|
||||
}
|
||||
free(fpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fpath);
|
||||
}
|
||||
|
||||
static char *psync_fuse_get_mountpoint() {
|
||||
|
|
@ -3455,7 +3456,7 @@ static char *psync_fuse_get_mountpoint() {
|
|||
"Please verify the path exists and is accessible.",
|
||||
mp, stat_errno, strerror(stat_errno));
|
||||
}
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -3463,7 +3464,7 @@ static char *psync_fuse_get_mountpoint() {
|
|||
if (!S_ISDIR(st.st_mode)) {
|
||||
pdbg_logf(D_CRITICAL,
|
||||
"Mount point %s exists but is not a directory", mp);
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -3498,12 +3499,12 @@ char *pfs_get_path_by_folderid(psync_folderid_t folderid) {
|
|||
path =
|
||||
pfolder_path_sep(folderid, "/", NULL);
|
||||
if (path == PSYNC_INVALID_PATH) {
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
return NULL;
|
||||
}
|
||||
ret = putil_strcat(mp, path, NULL);
|
||||
free(mp);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -3519,12 +3520,12 @@ char *pfs_get_path_by_fileid(psync_fileid_t fileid) {
|
|||
return NULL;
|
||||
path = pfolder_file_path(fileid, NULL);
|
||||
if (path == PSYNC_INVALID_PATH) {
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
return NULL;
|
||||
}
|
||||
ret = putil_strcat(mp, path, NULL);
|
||||
free(mp);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -3586,7 +3587,7 @@ static void pfs_do_stop(void) {
|
|||
}
|
||||
|
||||
pfs_debug_dump_internals();
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
}
|
||||
pthread_mutex_unlock(&start_mutex);
|
||||
}
|
||||
|
|
@ -3643,7 +3644,7 @@ static void psync_fuse_thread() {
|
|||
pthread_mutex_lock(&start_mutex);
|
||||
fuse_destroy(psync_fuse);
|
||||
pdbg_logf(D_NOTICE, "fuse_destroy exited");
|
||||
free(psync_current_mountpoint);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, psync_current_mountpoint);
|
||||
started = 0;
|
||||
pthread_cond_broadcast(&start_cond);
|
||||
pthread_mutex_unlock(&start_mutex);
|
||||
|
|
@ -3713,7 +3714,7 @@ static int pfs_do_start() {
|
|||
}
|
||||
token = strtok_r(NULL, ",", &saveptr);
|
||||
}
|
||||
free(fuse_opts);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fuse_opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3790,7 +3791,7 @@ static int pfs_do_start() {
|
|||
err1:
|
||||
fuse_unmount(mp, psync_fuse_channel);
|
||||
err0:
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
err00:
|
||||
pthread_mutex_unlock(&start_mutex);
|
||||
fuse_opt_free_args(&args);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "pfile.h"
|
||||
#include "pfscrypto.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "ppagecache.h"
|
||||
#include "ppath.h"
|
||||
#include "prun.h"
|
||||
|
|
@ -561,7 +562,7 @@ pfs_crypto_set_sector_log_offset(psync_openfile_t *of,
|
|||
return;
|
||||
}
|
||||
}
|
||||
ntr = malloc(sizeof(psync_sector_inlog_t));
|
||||
ntr = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_sector_inlog_t));
|
||||
*pe = &ntr->tree;
|
||||
ntr->sectorid = sectorid;
|
||||
ntr->logoffset = offset;
|
||||
|
|
@ -1088,16 +1089,16 @@ static int pfs_crypto_do_finalize_log(psync_openfile_t *of, int fullsync) {
|
|||
O_CREAT | O_TRUNC)) ==
|
||||
INVALID_HANDLE_VALUE) ||
|
||||
pdbg_unlikely(pfs_crpt_init_log(of))) {
|
||||
free(olog);
|
||||
free(flog);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, olog);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, flog);
|
||||
return -EIO;
|
||||
}
|
||||
ptree_for_each_element_call_safe(of->sectorsinlog, psync_sector_inlog_t, tree, free);
|
||||
of->sectorsinlog = PSYNC_TREE_EMPTY;
|
||||
ret = pfs_crypto_log_flush_and_process(of, flog, 0, 1);
|
||||
pfile_delete(flog);
|
||||
free(olog);
|
||||
free(flog);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, olog);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, flog);
|
||||
return pdbg_return_neg(ret);
|
||||
}
|
||||
|
||||
|
|
@ -1593,8 +1594,8 @@ retry:
|
|||
if (!icnt)
|
||||
psync_interval_tree_free(needtodwl);
|
||||
else {
|
||||
ranges = malloc(sizeof(psync_pagecache_read_range) * icnt);
|
||||
tmpbuf = malloc(sizeof(char) * isize);
|
||||
ranges = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_pagecache_read_range) * icnt);
|
||||
tmpbuf = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(char) * isize);
|
||||
icnt = 0;
|
||||
isize = 0;
|
||||
itr = psync_interval_tree_get_first(needtodwl);
|
||||
|
|
@ -1613,8 +1614,8 @@ retry:
|
|||
// we are unlocked now
|
||||
pfs_lock_file(of);
|
||||
if (unlikely(ret)) {
|
||||
free(ranges);
|
||||
free(tmpbuf);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ranges);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, tmpbuf);
|
||||
pdbg_logf(D_NOTICE, "downloading of ranges failed");
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1633,8 +1634,8 @@ retry:
|
|||
(unsigned long)ranges[l].offset,
|
||||
(unsigned long)(ranges[l].offset + ranges[l].size),
|
||||
(unsigned long)itr->from, (unsigned long)itr->to);
|
||||
free(ranges);
|
||||
free(tmpbuf);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ranges);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, tmpbuf);
|
||||
goto retry;
|
||||
}
|
||||
pdbg_logf(D_NOTICE, "wrote %u bytes to offset %lu",
|
||||
|
|
@ -1652,8 +1653,8 @@ retry:
|
|||
}
|
||||
// we do NOT need to fsync of->datafile, as we wrote to positions that
|
||||
// were empty
|
||||
free(ranges);
|
||||
free(tmpbuf);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ranges);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, tmpbuf);
|
||||
if (unlikely(ret))
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1777,7 +1778,7 @@ retry:
|
|||
ptree_element(tr, psync_sector_inlog_t, tree)->sectorid >
|
||||
ptree_element(ntr, psync_sector_inlog_t, tree)->sectorid);
|
||||
ptree_del(&of->sectorsinlog, tr);
|
||||
free(tr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, tr);
|
||||
tr = ntr;
|
||||
}
|
||||
ret = pfs_crypto_write_newfile_full_sector(of, buf, lastsectorid,
|
||||
|
|
@ -1859,7 +1860,7 @@ static void pfs_extender_thread(void *ptr) {
|
|||
of->extender = NULL;
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
pthread_cond_destroy(&ext->cond);
|
||||
free(ext);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ext);
|
||||
pfs_dec_of_refcnt(of);
|
||||
}
|
||||
|
||||
|
|
@ -1869,7 +1870,7 @@ static int pfs_crypto_run_extender(psync_openfile_t *of, uint64_t size) {
|
|||
pdbg_assert(!of->extender);
|
||||
pdbg_logf(D_NOTICE, "will run extender thread to extend from %lu to %lu",
|
||||
(unsigned long)of->currentsize, (unsigned long)size);
|
||||
ext = malloc(sizeof(psync_enc_file_extender_t));
|
||||
ext = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_enc_file_extender_t));
|
||||
pthread_cond_init(&ext->cond, NULL);
|
||||
ext->extendto = size;
|
||||
ext->extendedto = of->currentsize;
|
||||
|
|
@ -2079,7 +2080,7 @@ static void pfs_crypto_check_file(void *ptr, ppath_fast_stat *st) {
|
|||
path = putil_strcat((const char *)ptr, "/", st->name,
|
||||
NULL);
|
||||
pfs_crypto_check_log(path, st->name);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "pfsfolder.h"
|
||||
#include "pfstasks.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "psys.h"
|
||||
#include "pdbg.h"
|
||||
#include "psql.h"
|
||||
|
|
@ -65,7 +66,7 @@ static char *get_encname_for_folder(psync_fsfolderid_t folderid,
|
|||
name = putil_strndup(path, len);
|
||||
encname = pcryptofolder_fldencode_filename(enc, name);
|
||||
pcryptofolder_fldencoder_release(folderid, enc);
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, name);
|
||||
return encname;
|
||||
}
|
||||
|
||||
|
|
@ -86,16 +87,16 @@ static psync_fspath_t *ret_folder_data(psync_fsfolderid_t folderid,
|
|||
encname = pcryptofolder_fldencode_filename(enc, name);
|
||||
pcryptofolder_fldencoder_release(folderid, enc);
|
||||
len = strlen(encname);
|
||||
ret = (psync_fspath_t *)malloc(sizeof(psync_fspath_t) + len + 1);
|
||||
ret = (psync_fspath_t *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_fspath_t) + len + 1);
|
||||
memcpy(ret + 1, encname, len + 1);
|
||||
free(encname);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encname);
|
||||
ret->folderid = folderid;
|
||||
ret->name = (char *)(ret + 1);
|
||||
ret->shareid = shareid;
|
||||
ret->permissions = permissions;
|
||||
ret->flags = flags;
|
||||
} else {
|
||||
ret = malloc(sizeof(psync_fspath_t));
|
||||
ret = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_fspath_t));
|
||||
ret->folderid = folderid;
|
||||
ret->name = name;
|
||||
ret->shareid = shareid;
|
||||
|
|
@ -117,7 +118,7 @@ char *pfs_fldr_get_decname(psync_fsfolderid_t folderid, const char *path,
|
|||
name = putil_strndup(path, len);
|
||||
decname = pcryptofolder_flddecode_filename(dec, name);
|
||||
pcryptofolder_flddecoder_release(folderid, dec);
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, name);
|
||||
return decname;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +217,7 @@ psync_fspath_t *pfs_fldr_resolve_path(const char *path) {
|
|||
char *name = putil_strndup(ename, elen);
|
||||
if ((mk = pfs_task_find_mkdir(folder, name, 0))) {
|
||||
if (mk->flags & PSYNC_FOLDER_FLAG_INVISIBLE) {
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, name);
|
||||
break;
|
||||
}
|
||||
cfolderid = mk->folderid;
|
||||
|
|
@ -230,7 +231,7 @@ psync_fspath_t *pfs_fldr_resolve_path(const char *path) {
|
|||
check_userid(row[3], row[0], &shareid);
|
||||
} else
|
||||
hasit = 0;
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, name);
|
||||
} else {
|
||||
if (row) {
|
||||
cfolderid = row[0];
|
||||
|
|
@ -242,7 +243,7 @@ psync_fspath_t *pfs_fldr_resolve_path(const char *path) {
|
|||
hasit = 0;
|
||||
}
|
||||
if (ename != path)
|
||||
free(ename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ename);
|
||||
if (!hasit)
|
||||
break;
|
||||
path += len;
|
||||
|
|
@ -318,7 +319,7 @@ psync_fsfolderid_t pfs_fldr_id_by_path(const char *path,
|
|||
hasit = 1;
|
||||
} else
|
||||
hasit = 0;
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, name);
|
||||
} else {
|
||||
if (row) {
|
||||
cfolderid = row[0];
|
||||
|
|
@ -328,7 +329,7 @@ psync_fsfolderid_t pfs_fldr_id_by_path(const char *path,
|
|||
hasit = 0;
|
||||
}
|
||||
if (ename != path)
|
||||
free(ename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ename);
|
||||
if (!hasit)
|
||||
break;
|
||||
path += len;
|
||||
|
|
@ -405,7 +406,7 @@ psync_fsfolderid_t pfs_fldr_idperm_by_path(const char *path,
|
|||
hasit = 1;
|
||||
} else
|
||||
hasit = 0;
|
||||
free(name);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, name);
|
||||
} else {
|
||||
if (row) {
|
||||
cfolderid = row[0];
|
||||
|
|
@ -416,7 +417,7 @@ psync_fsfolderid_t pfs_fldr_idperm_by_path(const char *path,
|
|||
hasit = 0;
|
||||
}
|
||||
if (ename != path)
|
||||
free(ename);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ename);
|
||||
if (!hasit)
|
||||
break;
|
||||
path += len;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
static psync_interval_tree_t *psync_interval_tree_new(uint64_t from,
|
||||
uint64_t to) {
|
||||
psync_interval_tree_t *tree = malloc(sizeof(psync_interval_tree_t));
|
||||
psync_interval_tree_t *tree = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_interval_tree_t));
|
||||
tree->from = from;
|
||||
tree->to = to;
|
||||
return psync_interval_tree_element(
|
||||
|
|
@ -42,7 +42,7 @@ static psync_interval_tree_t *psync_interval_tree_new(uint64_t from,
|
|||
}
|
||||
|
||||
static psync_interval_tree_t *psync_interval_new(uint64_t from, uint64_t to) {
|
||||
psync_interval_tree_t *tree = malloc(sizeof(psync_interval_tree_t));
|
||||
psync_interval_tree_t *tree = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_interval_tree_t));
|
||||
tree->from = from;
|
||||
tree->to = to;
|
||||
return tree;
|
||||
|
|
@ -58,10 +58,10 @@ psync_interval_tree_consume_intervals(psync_interval_tree_t *tree,
|
|||
psync_interval_tree_del(&tree, next);
|
||||
if (next->to >= e->to) {
|
||||
e->to = next->to;
|
||||
free(next);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, next);
|
||||
break;
|
||||
}
|
||||
free(next);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, next);
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ psync_interval_tree_get_cut_end(psync_interval_tree_t *tree, uint64_t end) {
|
|||
prev = psync_interval_tree_get_prev(last);
|
||||
tree = psync_interval_tree_element(
|
||||
ptree_get_del(&tree->tree, &last->tree));
|
||||
free(last);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, last);
|
||||
last = prev;
|
||||
}
|
||||
return tree;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "pdbg.h"
|
||||
#include "pfile.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "ptimer.h"
|
||||
#include "putil.h"
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ int psync_rename_conflicted_file(const char *path) {
|
|||
dotidx--;
|
||||
if (!dotidx)
|
||||
dotidx = plen;
|
||||
npath = (char *)malloc(plen + 32);
|
||||
npath = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, plen + 32);
|
||||
memcpy(npath, path, dotidx);
|
||||
num = 0;
|
||||
while (1) {
|
||||
|
|
@ -101,7 +102,7 @@ int psync_rename_conflicted_file(const char *path) {
|
|||
if (stat(npath, &st)) {
|
||||
pdbg_logf(D_NOTICE, "renaming conflict %s to %s", path, npath);
|
||||
l = pfile_rename(path, npath);
|
||||
free(npath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, npath);
|
||||
return l;
|
||||
}
|
||||
num++;
|
||||
|
|
@ -112,12 +113,12 @@ static void run_after_sec(psync_timer_t timer, void *ptr) {
|
|||
struct run_after_ptr *fp = (struct run_after_ptr *)ptr;
|
||||
ptimer_stop(timer);
|
||||
fp->run(fp->ptr);
|
||||
free(fp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fp);
|
||||
}
|
||||
|
||||
void psync_run_after_sec(psync_run_after_t run, void *ptr, uint32_t seconds) {
|
||||
struct run_after_ptr *fp;
|
||||
fp = malloc(sizeof(struct run_after_ptr));
|
||||
fp = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(struct run_after_ptr));
|
||||
fp->run = run;
|
||||
fp->ptr = ptr;
|
||||
ptimer_register(run_after_sec, seconds, fp);
|
||||
|
|
@ -125,7 +126,7 @@ void psync_run_after_sec(psync_run_after_t run, void *ptr, uint32_t seconds) {
|
|||
|
||||
static void proc_free_after(psync_timer_t timer, void *ptr) {
|
||||
ptimer_stop(timer);
|
||||
free(ptr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ptr);
|
||||
}
|
||||
|
||||
void psync_free_after_sec(void *ptr, uint32_t seconds) {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ void psync_list_extract_repeating(psync_list *l1, psync_list *l2, psync_list *ex
|
|||
|
||||
psync_list_builder_t *psync_list_builder_create(size_t element_size, size_t offset) {
|
||||
psync_list_builder_t *builder;
|
||||
builder = malloc(sizeof(psync_list_builder_t));
|
||||
builder = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_list_builder_t));
|
||||
builder->element_size = element_size;
|
||||
builder->elements_offset = offset;
|
||||
if (element_size <= 200)
|
||||
|
|
@ -164,7 +164,7 @@ uint32_t *psync_list_builder_push_num(psync_list_builder_t *builder) {
|
|||
if (!builder->last_numbers ||
|
||||
builder->last_numbers->used >=
|
||||
sizeof(builder->last_numbers->numbers) / sizeof(uint32_t)) {
|
||||
psync_list_num_list *l = malloc(sizeof(psync_list_num_list));
|
||||
psync_list_num_list *l = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_list_num_list));
|
||||
l->used = 0;
|
||||
builder->last_numbers = l;
|
||||
psync_list_add_tail(&builder->number_list, &l->list);
|
||||
|
|
@ -187,7 +187,7 @@ uint32_t psync_list_builder_pop_num(psync_list_builder_t *builder) {
|
|||
void *psync_list_builder_add_element(psync_list_builder_t *builder) {
|
||||
if (!builder->last_elements ||
|
||||
builder->last_elements->used >= builder->elements_per_list) {
|
||||
builder->last_elements = (psync_list_element_list *)malloc(
|
||||
builder->last_elements = (psync_list_element_list *)pmem_malloc(PMEM_SUBSYS_OTHER,
|
||||
offsetof(psync_list_element_list, elements) +
|
||||
builder->element_size * builder->elements_per_list);
|
||||
psync_list_add_tail(&builder->element_list, &builder->last_elements->list);
|
||||
|
|
@ -210,13 +210,13 @@ void psync_list_add_lstring_offset(psync_list_builder_t *builder, size_t offset,
|
|||
str = (char **)(builder->current_element + offset);
|
||||
builder->stringalloc += length;
|
||||
if (unlikely(length > 2000)) {
|
||||
l = (psync_list_string_list *)malloc(sizeof(psync_list_string_list) +
|
||||
l = (psync_list_string_list *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_list_string_list) +
|
||||
length);
|
||||
s = (char *)(l + 1);
|
||||
psync_list_add_tail(&builder->string_list, &l->list);
|
||||
} else if (!builder->last_strings || builder->last_strings->next + length >
|
||||
builder->last_strings->end) {
|
||||
l = (psync_list_string_list *)malloc(sizeof(psync_list_string_list) +
|
||||
l = (psync_list_string_list *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_list_string_list) +
|
||||
4000);
|
||||
s = (char *)(l + 1);
|
||||
l->next = s + length;
|
||||
|
|
@ -265,7 +265,7 @@ void *psync_list_builder_finalize(psync_list_builder_t *builder) {
|
|||
sz = builder->elements_offset + elem_total + builder->stringalloc;
|
||||
pdbg_logf(D_NOTICE, "allocating %lu bytes, %lu of which for strings",
|
||||
(unsigned long)sz, (unsigned long)builder->stringalloc);
|
||||
ret = malloc(sizeof(char) * sz);
|
||||
ret = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(char) * sz);
|
||||
if (builder->elements_offset <= sizeof(builder->cnt))
|
||||
memcpy(ret, &builder->cnt, builder->elements_offset);
|
||||
else
|
||||
|
|
@ -298,7 +298,7 @@ void *psync_list_builder_finalize(psync_list_builder_t *builder) {
|
|||
psync_list_for_each_element_call(&builder->element_list, psync_list_element_list, list, free);
|
||||
psync_list_for_each_element_call(&builder->string_list, psync_list_string_list, list, free);
|
||||
psync_list_for_each_element_call(&builder->number_list, psync_list_num_list, list, free);
|
||||
free(builder);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, builder);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "pfoldersync.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plist.h"
|
||||
#include "plocalnotify.h"
|
||||
#include "plocalscan.h"
|
||||
|
|
@ -99,7 +100,7 @@ static void add_dir_scan(localnotify_dir *dir, const char *path) {
|
|||
namelen = 255;
|
||||
if (namelen < sizeof(de->d_name) - 1)
|
||||
namelen = sizeof(de->d_name) - 1;
|
||||
wch = (localnotify_watch *)malloc(offsetof(localnotify_watch, path) +
|
||||
wch = (localnotify_watch *)pmem_malloc(PMEM_SUBSYS_OTHER, offsetof(localnotify_watch, path) +
|
||||
pl + 1 + namelen + 1);
|
||||
wch->next = dir->watches[wid % WATCH_HASH];
|
||||
dir->watches[wid % WATCH_HASH] = wch;
|
||||
|
|
@ -109,8 +110,8 @@ static void add_dir_scan(localnotify_dir *dir, const char *path) {
|
|||
memcpy(wch->path, path, pl + 1);
|
||||
if (pdbg_likely(dh = opendir(path))) {
|
||||
entrylen = offsetof(struct dirent, d_name) + namelen + 1;
|
||||
cpath = (char *)malloc(pl + namelen + 2);
|
||||
entry = (struct dirent *)malloc(entrylen);
|
||||
cpath = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, pl + namelen + 2);
|
||||
entry = (struct dirent *)pmem_malloc(PMEM_SUBSYS_OTHER, entrylen);
|
||||
memcpy(cpath, path, pl);
|
||||
if (!pl || cpath[pl - 1] != '/')
|
||||
cpath[pl++] = '/';
|
||||
|
|
@ -124,8 +125,8 @@ static void add_dir_scan(localnotify_dir *dir, const char *path) {
|
|||
add_dir_scan(dir, cpath);
|
||||
}
|
||||
}
|
||||
free(entry);
|
||||
free(cpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, entry);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, cpath);
|
||||
closedir(dh);
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +144,7 @@ static void add_syncid(psync_syncid_t syncid) {
|
|||
str = psync_get_lstring(row[0], &len);
|
||||
len++;
|
||||
dir =
|
||||
(localnotify_dir *)malloc(offsetof(localnotify_dir, path) + len);
|
||||
(localnotify_dir *)pmem_malloc(PMEM_SUBSYS_OTHER, offsetof(localnotify_dir, path) + len);
|
||||
memcpy(dir->path, str, len);
|
||||
psql_free(res);
|
||||
} else {
|
||||
|
|
@ -167,7 +168,7 @@ static void add_syncid(psync_syncid_t syncid) {
|
|||
err2:
|
||||
close(dir->inotifyfd);
|
||||
err:
|
||||
free(dir);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, dir);
|
||||
}
|
||||
|
||||
static void del_syncid(psync_syncid_t syncid) {
|
||||
|
|
@ -182,13 +183,13 @@ static void del_syncid(psync_syncid_t syncid) {
|
|||
while (wch) {
|
||||
next = wch->next;
|
||||
inotify_rm_watch(dir->inotifyfd, wch->watchid);
|
||||
free(wch);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, wch);
|
||||
wch = next;
|
||||
}
|
||||
}
|
||||
epoll_ctl(epoll_fd, EPOLL_CTL_DEL, dir->inotifyfd, NULL);
|
||||
close(dir->inotifyfd);
|
||||
free(dir);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, dir);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -239,7 +240,7 @@ static uint32_t process_notification(localnotify_dir *dir) {
|
|||
if (wch->watchid == ev.wd) {
|
||||
*pwch = wch->next;
|
||||
inotify_rm_watch(dir->inotifyfd, wch->watchid);
|
||||
free(wch);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, wch);
|
||||
break;
|
||||
} else {
|
||||
pwch = &wch->next;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void *pmem_malloc(pmem_subsystem_t subsystem, size_t size) {
|
|||
pmem_header_t *hdr;
|
||||
size_t total_size = sizeof(pmem_header_t) + size;
|
||||
|
||||
hdr = (pmem_header_t *)malloc(total_size);
|
||||
hdr = (pmem_header_t *)pmem_malloc(PMEM_SUBSYS_OTHER, total_size);
|
||||
if (!hdr) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ void pmem_free(pmem_subsystem_t subsystem, void *ptr) {
|
|||
|
||||
hdr = ((pmem_header_t *)ptr) - 1;
|
||||
__atomic_sub_fetch(&subsystem_stats[hdr->subsystem], hdr->size, __ATOMIC_RELAXED);
|
||||
free(hdr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, hdr);
|
||||
}
|
||||
|
||||
void *pmem_realloc(pmem_subsystem_t subsystem, void *ptr, size_t size) {
|
||||
|
|
@ -150,7 +150,7 @@ void *pmem_malloc_array(pmem_subsystem_t subsystem, size_t nmemb, size_t size) {
|
|||
alloc_size = nmemb * size;
|
||||
total_size = sizeof(pmem_header_t) + alloc_size;
|
||||
|
||||
hdr = (pmem_header_t *)malloc(total_size);
|
||||
hdr = (pmem_header_t *)pmem_malloc(PMEM_SUBSYS_OTHER, total_size);
|
||||
if (!hdr) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "pfile.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "pnetlibs.h"
|
||||
#include "pnotify.h"
|
||||
#include "ppath.h"
|
||||
|
|
@ -60,7 +61,7 @@ const char *pnotify_get_thumb_size() { return ntf_thumb_size; }
|
|||
void pnotify_notify(binresult *res) {
|
||||
pthread_mutex_lock(&ntf_mutex);
|
||||
if (ntf_result)
|
||||
free(ntf_result);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ntf_result);
|
||||
ntf_result = res;
|
||||
pthread_cond_signal(&ntf_cond);
|
||||
pthread_mutex_unlock(&ntf_mutex);
|
||||
|
|
@ -101,7 +102,7 @@ static void psync_notifications_download_thumb(const binresult *thumb,
|
|||
goto err3;
|
||||
if (pdbg_unlikely(psync_http_next_request(sock)))
|
||||
goto err3;
|
||||
buff = (char *)malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, PSYNC_COPY_BUFFER_SIZE);
|
||||
while (1) {
|
||||
rd = psync_http_request_readall(sock, buff, PSYNC_COPY_BUFFER_SIZE);
|
||||
if (rd <= 0)
|
||||
|
|
@ -109,7 +110,7 @@ static void psync_notifications_download_thumb(const binresult *thumb,
|
|||
if (pfile_write(fd, buff, rd) != rd)
|
||||
break;
|
||||
}
|
||||
free(buff);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, buff);
|
||||
err3:
|
||||
psync_http_close(sock);
|
||||
err2:
|
||||
|
|
@ -119,9 +120,9 @@ err1:
|
|||
pdbg_logf(D_NOTICE, "downloaded thumbnail %s", filename);
|
||||
else
|
||||
pdbg_logf(D_WARNING, "downloading of thumbnail %s failed", filename);
|
||||
free(tmpfilepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, tmpfilepath);
|
||||
err0:
|
||||
free(filepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filepath);
|
||||
}
|
||||
|
||||
static void psync_notifications_set_current_list(binresult *res,
|
||||
|
|
@ -145,13 +146,13 @@ static void psync_notifications_set_current_list(binresult *res,
|
|||
ores = ntf_processed_result;
|
||||
if (ntf_processing == 2) {
|
||||
ntf_processed_result = NULL;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
} else
|
||||
ntf_processed_result = res;
|
||||
ntf_processing = 0;
|
||||
cb = ntf_callback;
|
||||
pthread_mutex_unlock(&ntf_mutex);
|
||||
free(ores);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ores);
|
||||
if (cb) {
|
||||
pdbg_logf(D_NOTICE, "calling notification callback, cnt=%u, newcnt=%u",
|
||||
(unsigned)cnttotal, (unsigned)cntnew);
|
||||
|
|
@ -178,7 +179,7 @@ static void psync_notifications_thread() {
|
|||
pthread_mutex_unlock(&ntf_mutex);
|
||||
psync_notifications_set_current_list(res, thumbpath);
|
||||
}
|
||||
free(thumbpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, thumbpath);
|
||||
}
|
||||
|
||||
void pnotify_set_callback(
|
||||
|
|
@ -258,7 +259,7 @@ static void psync_notifications_thumb_dir_list(void *ptr,
|
|||
} else
|
||||
addto = tree;
|
||||
len = strlen(st->name) + 1;
|
||||
tl = (psync_thumb_list_t *)malloc(offsetof(psync_thumb_list_t, name) +
|
||||
tl = (psync_thumb_list_t *)pmem_malloc(PMEM_SUBSYS_OTHER, offsetof(psync_thumb_list_t, name) +
|
||||
len);
|
||||
memcpy(tl->name, st->name, len);
|
||||
*addto = &tl->tree;
|
||||
|
|
@ -336,7 +337,7 @@ psync_notification_list_t *pnotify_get() {
|
|||
pdbg_logf(D_WARNING,
|
||||
"could not stat thumb %s which is supposed to be downloaded",
|
||||
filename);
|
||||
free(filepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filepath);
|
||||
}
|
||||
}
|
||||
pntf->mtime = papi_find_result2(ntf, "mtime", PARAM_NUM)->num;
|
||||
|
|
@ -359,11 +360,11 @@ psync_notification_list_t *pnotify_get() {
|
|||
thumbpath, "/",
|
||||
ptree_element(thumbs, psync_thumb_list_t, tree)->name, NULL);
|
||||
pfile_delete(filepath);
|
||||
free(filepath);
|
||||
free(ptree_element(thumbs, psync_thumb_list_t, tree));
|
||||
pmem_free(PMEM_SUBSYS_OTHER, filepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ptree_element(thumbs, psync_thumb_list_t, tree));
|
||||
thumbs = nx;
|
||||
}
|
||||
free(thumbpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, thumbpath);
|
||||
res = (psync_notification_list_t *)psync_list_builder_finalize(builder);
|
||||
res->newnotificationcnt = cntnew;
|
||||
return res;
|
||||
|
|
@ -382,14 +383,14 @@ void pnotify_clean() {
|
|||
thumbpath = ppath_private(PSYNC_DEFAULT_NTF_THUMB_DIR);
|
||||
if (thumbpath) {
|
||||
ppath_ls(thumbpath, psync_notifications_del_thumb, NULL);
|
||||
free(thumbpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, thumbpath);
|
||||
}
|
||||
if (ntf_processed_result) {
|
||||
free(ntf_processed_result);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ntf_processed_result);
|
||||
ntf_processed_result = NULL;
|
||||
}
|
||||
if (ntf_result) {
|
||||
free(ntf_result);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ntf_result);
|
||||
ntf_result = NULL;
|
||||
}
|
||||
if (ntf_processing == 1)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include "pfile.h"
|
||||
#include "pfoldersync.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "pnetlibs.h"
|
||||
#include "pp2p.h"
|
||||
#include "prun.h"
|
||||
|
|
@ -199,11 +200,11 @@ static int is_downloading(const unsigned char *hashstart,
|
|||
if (!memcmp(hashhex, genhash, PSYNC_HASH_DIGEST_HEXLEN)) {
|
||||
if (realhash)
|
||||
memcpy(realhash, hashsource, PSYNC_HASH_DIGEST_HEXLEN);
|
||||
free(hashes);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, hashes);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
free(hashes);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, hashes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +314,7 @@ static int check_token(char *token, uint32_t tlen, unsigned char *key,
|
|||
}
|
||||
psync_apipool_release(api);
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +334,7 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
uint32_t keylen, enctype;
|
||||
unsigned char hashhex[PSYNC_HASH_DIGEST_HEXLEN], buff[4096];
|
||||
sock = *((int *)ptr);
|
||||
free(ptr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ptr);
|
||||
pdbg_logf(D_NOTICE, "got tcp connection");
|
||||
if (pdbg_unlikely(socket_read_all(sock, &packet, sizeof(packet))))
|
||||
goto err0;
|
||||
|
|
@ -350,20 +351,20 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
binpubrsa = pssl_alloc_binary_rsa(packet.keylen);
|
||||
if (pdbg_unlikely(
|
||||
socket_read_all(sock, binpubrsa->data, binpubrsa->datalen))) {
|
||||
free(binpubrsa);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, binpubrsa);
|
||||
goto err0;
|
||||
}
|
||||
token = malloc(sizeof(char) * packet.tokenlen);
|
||||
token = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(char) * packet.tokenlen);
|
||||
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);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, binpubrsa);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, token);
|
||||
goto err0;
|
||||
}
|
||||
free(token);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, token);
|
||||
pubrsa = prsa_binary_to_public(binpubrsa);
|
||||
free(binpubrsa);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, binpubrsa);
|
||||
if (pdbg_unlikely(pubrsa == PSYNC_INVALID_RSA))
|
||||
goto err0;
|
||||
localpath = pfolder_lpath_lfile(localfileid, NULL);
|
||||
|
|
@ -371,7 +372,7 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
goto err0;
|
||||
fd = pfile_open(localpath, O_RDONLY, 0);
|
||||
pdbg_logf(D_NOTICE, "sending file %s to peer", localpath);
|
||||
free(localpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, localpath);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
pdbg_logf(D_WARNING, "could not open local file %lu",
|
||||
(unsigned long)localfileid);
|
||||
|
|
@ -390,13 +391,13 @@ static void psync_p2p_tcphandler(void *ptr) {
|
|||
socket_write_all(sock, &enctype, sizeof(enctype)) ||
|
||||
socket_write_all(sock, encaeskey->data, encaeskey->datalen))) {
|
||||
if (encaeskey != PSYNC_INVALID_ENC_SYM_KEY)
|
||||
free(encaeskey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encaeskey);
|
||||
if (encoder != PSYNC_CRYPTO_INVALID_ENCODER)
|
||||
pcrypto_ctr_encdec_free(encoder);
|
||||
pfile_close(fd);
|
||||
goto err0;
|
||||
}
|
||||
free(encaeskey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encaeskey);
|
||||
off = 0;
|
||||
while (off < packet.filesize) {
|
||||
if (packet.filesize - off < sizeof(buff))
|
||||
|
|
@ -509,10 +510,10 @@ static void psync_p2p_thread() {
|
|||
else
|
||||
psys_sleep_milliseconds(1);
|
||||
} else if (sret == 1) {
|
||||
inconn = malloc(sizeof(int));
|
||||
inconn = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(int));
|
||||
*inconn = accept(tcpsock, NULL, NULL);
|
||||
if (pdbg_unlikely(*inconn == INVALID_SOCKET))
|
||||
free(inconn);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, inconn);
|
||||
else
|
||||
prun_thread1("p2p tcp", psync_p2p_tcphandler, inconn);
|
||||
}
|
||||
|
|
@ -636,14 +637,14 @@ static int psync_p2p_get_download_token(psync_fileid_t fileid,
|
|||
}
|
||||
psync_apipool_release(api);
|
||||
if (pdbg_unlikely(papi_find_result2(res, "result", PARAM_NUM)->num != 0)) {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return PSYNC_NET_PERMFAIL;
|
||||
}
|
||||
ctoken = papi_find_result2(res, "token", PARAM_STR);
|
||||
*token = malloc(ctoken->length + 1);
|
||||
*token = pmem_malloc(PMEM_SUBSYS_OTHER, ctoken->length + 1);
|
||||
memcpy(*token, ctoken->str, ctoken->length + 1);
|
||||
*tlen = ctoken->length;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return PSYNC_NET_OK;
|
||||
}
|
||||
|
||||
|
|
@ -679,10 +680,10 @@ static int psync_p2p_download(int sock, psync_fileid_t fileid,
|
|||
&privkey, &ekey)) == PSYNC_INVALID_SYM_KEY)) {
|
||||
// pdbg_unlikely((key=psymkey_decrypt(&psync_rsa_private,
|
||||
// &ekey))==PSYNC_INVALID_SYM_KEY)){
|
||||
free(ekey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ekey);
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
}
|
||||
free(ekey);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ekey);
|
||||
decoder = pcrypto_ctr_encdec_create(key);
|
||||
psymkey_free(key);
|
||||
if (decoder == PSYNC_CRYPTO_INVALID_ENCODER)
|
||||
|
|
@ -762,7 +763,7 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
psync_binhex(pct1.genhash, hashbin, PSYNC_HASH_DIGEST_LEN);
|
||||
memcpy(pct1.computername, computername, PSYNC_HASH_DIGEST_HEXLEN);
|
||||
il = psock_list_adapters();
|
||||
sockets = malloc(sizeof(int) * il->interfacecnt);
|
||||
sockets = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(int) * il->interfacecnt);
|
||||
FD_ZERO(&rfds);
|
||||
msock = 0;
|
||||
for (i = 0; i < il->interfacecnt; i++) {
|
||||
|
|
@ -836,8 +837,8 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
for (i = 0; i < il->interfacecnt; i++)
|
||||
if (sockets[i] != INVALID_SOCKET)
|
||||
close(sockets[i]);
|
||||
free(il);
|
||||
free(sockets);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, il);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, sockets);
|
||||
if (bresp == P2P_RESP_NOPE)
|
||||
goto err_perm2;
|
||||
else if (bresp == P2P_RESP_WAIT) {
|
||||
|
|
@ -891,24 +892,24 @@ int pp2p_check_download(psync_fileid_t fileid,
|
|||
pdbg_logf(D_WARNING, "writing to socket failed");
|
||||
goto err_temp3;
|
||||
}
|
||||
free(token);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, token);
|
||||
sret = psync_p2p_download(sock, fileid, filehashhex, fsize, filename);
|
||||
close(sock);
|
||||
return sret;
|
||||
err_perm3:
|
||||
free(token);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, token);
|
||||
goto err_perm2;
|
||||
err_perm:
|
||||
for (i = 0; i < il->interfacecnt; i++)
|
||||
if (sockets[i] != INVALID_SOCKET)
|
||||
close(sockets[i]);
|
||||
free(il);
|
||||
free(sockets);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, il);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, sockets);
|
||||
err_perm2:
|
||||
return PSYNC_NET_PERMFAIL;
|
||||
err_temp3:
|
||||
close(sock);
|
||||
free(token);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, token);
|
||||
err_temp2:
|
||||
return PSYNC_NET_TEMPFAIL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,8 +320,8 @@ uint64_t ppassword_score(const char *cpassword) {
|
|||
}
|
||||
if (!plen)
|
||||
return score;
|
||||
lpwd = malloc(sizeof(unsigned char) * plen);
|
||||
ldpwd = malloc(sizeof(unsigned char) * plen);
|
||||
lpwd = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(unsigned char) * plen);
|
||||
ldpwd = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(unsigned char) * plen);
|
||||
for (nlen = 0; nlen < plen; nlen++) {
|
||||
lpwd[nlen] = tolower(password[nlen]);
|
||||
if (lpwd[nlen] == '0')
|
||||
|
|
@ -348,8 +348,8 @@ uint64_t ppassword_score(const char *cpassword) {
|
|||
num = score_variants(password, lpwd, ldpwd, plen);
|
||||
putil_wipe(lpwd, plen);
|
||||
putil_wipe(ldpwd, plen);
|
||||
free(lpwd);
|
||||
free(ldpwd);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, lpwd);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ldpwd);
|
||||
mul_score(num);
|
||||
return score;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "pcompiler.h"
|
||||
#include "pfile.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "ppath.h"
|
||||
#include "psettings.h"
|
||||
#include "psql.h"
|
||||
|
|
@ -21,24 +22,24 @@ char *ppath_default_db() {
|
|||
}
|
||||
|
||||
dbp = putil_strcat(pcdir, "/", PSYNC_DEFAULT_DB_NAME, NULL);
|
||||
free(pcdir);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, pcdir);
|
||||
|
||||
if (stat(dbp, &st)) {
|
||||
// Inline the old database path function here
|
||||
if ((home = ppath_home())) {
|
||||
oldp = putil_strcat(home, "/", PSYNC_DEFAULT_POSIX_DBNAME, NULL);
|
||||
free(home);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, home);
|
||||
|
||||
if (oldp) {
|
||||
if (!stat(oldp, &st)) {
|
||||
if (psql_reopen(oldp)) {
|
||||
free(dbp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, dbp);
|
||||
return oldp;
|
||||
} else {
|
||||
pfile_rename(oldp, dbp);
|
||||
}
|
||||
}
|
||||
free(oldp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, oldp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +88,7 @@ int ppath_ls(const char *path, ppath_ls_cb callback, void *ptr) {
|
|||
}
|
||||
|
||||
pl = strlen(path);
|
||||
cpath = (char *)malloc(pl + NAME_MAX + 2);
|
||||
cpath = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, pl + NAME_MAX + 2);
|
||||
memcpy(cpath, path, pl);
|
||||
if (!pl || cpath[pl - 1] != '/')
|
||||
cpath[pl++] = '/';
|
||||
|
|
@ -109,7 +110,7 @@ int ppath_ls(const char *path, ppath_ls_cb callback, void *ptr) {
|
|||
}
|
||||
}
|
||||
|
||||
free(cpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, cpath);
|
||||
closedir(dh);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -129,7 +130,7 @@ int ppath_ls_fast(const char *path, ppath_ls_fast_cb callback, void *ptr) {
|
|||
}
|
||||
|
||||
pl = strlen(path);
|
||||
cpath = (char *)malloc(pl + NAME_MAX + 2);
|
||||
cpath = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, pl + NAME_MAX + 2);
|
||||
memcpy(cpath, path, pl);
|
||||
if (!pl || cpath[pl - 1] != '/')
|
||||
cpath[pl++] = '/';
|
||||
|
|
@ -159,7 +160,7 @@ int ppath_ls_fast(const char *path, ppath_ls_fast_cb callback, void *ptr) {
|
|||
// Ignore other file types
|
||||
}
|
||||
|
||||
free(cpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, cpath);
|
||||
closedir(dh);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -173,14 +174,14 @@ char *ppath_pcloud() {
|
|||
}
|
||||
|
||||
path = putil_strcat(homedir, "/", PSYNC_DEFAULT_POSIX_DIR, NULL);
|
||||
free(homedir);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, homedir);
|
||||
if (pdbg_unlikely(!path)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (stat(path, &st) &&
|
||||
pdbg_unlikely(mkdir(path, PSYNC_DEFAULT_POSIX_FOLDER_MODE))) {
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
return NULL;
|
||||
}
|
||||
return path;
|
||||
|
|
@ -194,11 +195,11 @@ char *ppath_private(char *name) {
|
|||
return NULL;
|
||||
rpath = putil_strcat(path, "/", name, NULL);
|
||||
if (stat(rpath, &st) && mkdir(path, PSYNC_DEFAULT_POSIX_FOLDER_MODE)) {
|
||||
free(rpath);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, rpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
return NULL;
|
||||
}
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
return rpath;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "pfoldersync.h"
|
||||
#include "pfstasks.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plist.h"
|
||||
#include "ppathstatus.h"
|
||||
#include "psql.h"
|
||||
|
|
@ -280,7 +281,7 @@ static folder_tasks_t *get_folder_tasks(psync_folderid_t folderid, int create) {
|
|||
}
|
||||
}
|
||||
if (create) {
|
||||
ft = malloc(sizeof(folder_tasks_t));
|
||||
ft = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(folder_tasks_t));
|
||||
*atr = &ft->tree;
|
||||
ptree_added_at(&folder_tasks, tr, &ft->tree);
|
||||
ft->folderid = folderid;
|
||||
|
|
@ -297,7 +298,7 @@ static folder_tasks_t *get_folder_tasks(psync_folderid_t folderid, int create) {
|
|||
static void free_folder_tasks(folder_tasks_t *ft) {
|
||||
pdbg_logf(D_NOTICE, "marking folderid %lu as clean", (unsigned long)ft->folderid);
|
||||
ptree_del(&folder_tasks, &ft->tree);
|
||||
free(ft);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ft);
|
||||
}
|
||||
|
||||
static psync_folderid_t get_parent_folder(psync_folderid_t folderid) {
|
||||
|
|
@ -408,7 +409,7 @@ static void folder_moved(psync_folderid_t folderid,
|
|||
static void folder_moved_commit(void *ptr) {
|
||||
folder_moved_params_t *mp = (folder_moved_params_t *)ptr;
|
||||
folder_moved(mp->folderid, mp->old_parent_folderid, mp->new_parent_folderid);
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
}
|
||||
|
||||
void ppathstatus_fldr_moved(psync_folderid_t folderid,
|
||||
|
|
@ -420,7 +421,7 @@ void ppathstatus_fldr_moved(psync_folderid_t folderid,
|
|||
ppathstatus_del_from_parent_cache(folderid);
|
||||
if (!get_folder_tasks(folderid, 0))
|
||||
return;
|
||||
mp = malloc(sizeof(folder_moved_params_t));
|
||||
mp = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(folder_moved_params_t));
|
||||
mp->folderid = folderid;
|
||||
mp->old_parent_folderid = old_parent_folderid;
|
||||
mp->new_parent_folderid = new_parent_folderid;
|
||||
|
|
@ -447,7 +448,7 @@ void ppathstatus_fldr_deleted(psync_folderid_t folderid) {
|
|||
|
||||
static void sync_data_free(sync_data_t *sd) {
|
||||
ptree_for_each_element_call_safe(sd->folder_tasks, folder_tasks_t, tree, free);
|
||||
free(sd);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, sd);
|
||||
}
|
||||
|
||||
static sync_data_t *get_sync_data(psync_syncid_t syncid, int create) {
|
||||
|
|
@ -479,7 +480,7 @@ static sync_data_t *get_sync_data(psync_syncid_t syncid, int create) {
|
|||
return NULL;
|
||||
} else {
|
||||
size_t i;
|
||||
sd = malloc(sizeof(sync_data_t));
|
||||
sd = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(sync_data_t));
|
||||
sd->syncid = syncid;
|
||||
*atr = &sd->tree;
|
||||
ptree_added_at(&sync_data, tr, &sd->tree);
|
||||
|
|
@ -525,7 +526,7 @@ get_sync_folder_tasks(sync_data_t *sd, psync_folderid_t folderid, int create) {
|
|||
}
|
||||
}
|
||||
if (create) {
|
||||
ft = malloc(sizeof(folder_tasks_t));
|
||||
ft = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(folder_tasks_t));
|
||||
*atr = &ft->tree;
|
||||
ptree_added_at(&sd->folder_tasks, tr, &ft->tree);
|
||||
ft->folderid = folderid;
|
||||
|
|
@ -656,7 +657,7 @@ static void free_sync_folder_tasks(sync_data_t *sd, folder_tasks_t *ft) {
|
|||
pdbg_logf(D_NOTICE, "marking folderid %lu from syncid %u as clean",
|
||||
(unsigned long)ft->folderid, (unsigned)sd->syncid);
|
||||
ptree_del(&sd->folder_tasks, &ft->tree);
|
||||
free(ft);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ft);
|
||||
}
|
||||
|
||||
void ppathstatus_syncfldr_task_completed(
|
||||
|
|
@ -751,7 +752,7 @@ static void sync_folder_moved_commit(void *ptr) {
|
|||
sync_folder_moved_params_t *mp = (sync_folder_moved_params_t *)ptr;
|
||||
sync_folder_moved(mp->folderid, mp->old_syncid, mp->old_parent_folderid,
|
||||
mp->new_syncid, mp->new_parent_folderid);
|
||||
free(mp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, mp);
|
||||
}
|
||||
|
||||
void ppathstatus_syncfldr_moved(psync_folderid_t folderid,
|
||||
|
|
@ -769,7 +770,7 @@ void ppathstatus_syncfldr_moved(psync_folderid_t folderid,
|
|||
sync_del_from_parent_cache(sd, folderid);
|
||||
if (!get_folder_tasks(folderid, 0))
|
||||
return;
|
||||
mp = malloc(sizeof(sync_folder_moved_params_t));
|
||||
mp = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(sync_folder_moved_params_t));
|
||||
mp->folderid = folderid;
|
||||
mp->old_parent_folderid = old_parent_folderid;
|
||||
mp->new_parent_folderid = new_parent_folderid;
|
||||
|
|
@ -894,7 +895,7 @@ static int move_encname_to_buff(psync_folderid_t folderid, char *buff,
|
|||
if (unlikely(len >= sizeof(buff)))
|
||||
return -1;
|
||||
memcpy(buff, encname, len + 1);
|
||||
free(encname);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, encname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1436,7 +1437,7 @@ psync_path_status_t ppathstatus_get(const char *path) {
|
|||
dp = NULL;
|
||||
}
|
||||
psql_unlock();
|
||||
free(dp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, dp);
|
||||
if (len >= drive_path_len && !memcmp(drive_path, path, drive_path_len) &&
|
||||
valid_last_char(path[drive_path_len]))
|
||||
return psync_path_status_drive(path + drive_path_len,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "pfoldersync.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plist.h"
|
||||
#include "pqevent.h"
|
||||
#include "prun.h"
|
||||
|
|
@ -322,9 +323,9 @@ static void proc_send_event(void *ptr) {
|
|||
callback(event->event, event->data);
|
||||
|
||||
if (event->freedata)
|
||||
free(event->data.ptr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, event->data.ptr);
|
||||
|
||||
free(event);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +373,7 @@ void pqevent_queue_sync_event_id(psync_eventtype_t eventid, psync_syncid_t synci
|
|||
if (pdbg_unlikely(!remotepath))
|
||||
return;
|
||||
pqevent_queue_sync_event_path(eventid, syncid, localpath, remoteid, remotepath);
|
||||
free(remotepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, remotepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +392,7 @@ void pqevent_queue_sync_event_path(psync_eventtype_t eventid, psync_syncid_t syn
|
|||
else
|
||||
slen = sizeof(psync_file_event_t);
|
||||
event =
|
||||
(event_list_t *)malloc(sizeof(event_list_t) + slen + llen + rlen);
|
||||
(event_list_t *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(event_list_t) + slen + llen + rlen);
|
||||
strct = (char *)(event + 1);
|
||||
lcopy = strct + slen;
|
||||
rcopy = lcopy + llen;
|
||||
|
|
@ -428,7 +429,7 @@ void pqevent_queue_eventid(psync_eventtype_t eventid) {
|
|||
if (eventthreadrunning) {
|
||||
event_list_t *event;
|
||||
|
||||
event = malloc(sizeof(event_list_t));
|
||||
event = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(event_list_t));
|
||||
event->data.ptr = NULL;
|
||||
event->event = eventid;
|
||||
event->freedata = 0;
|
||||
|
|
@ -444,7 +445,7 @@ void pqevent_queue_event(psync_eventtype_t eventid, void *eventdata) {
|
|||
if (eventthreadrunning) {
|
||||
event_list_t *event;
|
||||
|
||||
event = malloc(sizeof(event_list_t));
|
||||
event = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(event_list_t));
|
||||
event->data.ptr = eventdata;
|
||||
event->event = eventid;
|
||||
event->freedata = 1;
|
||||
|
|
@ -454,5 +455,5 @@ void pqevent_queue_event(psync_eventtype_t eventid, void *eventdata) {
|
|||
pthread_cond_signal(&eventcond);
|
||||
pthread_mutex_unlock(&eventmutex);
|
||||
} else
|
||||
free(eventdata);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, eventdata);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ static void on_request(void *lpvParam) {
|
|||
}
|
||||
|
||||
request = (rpc_message_t *)rqbuf;
|
||||
response = (rpc_message_t *)malloc(POVERLAY_BUFSIZE);
|
||||
response = (rpc_message_t *)pmem_malloc(PMEM_SUBSYS_OTHER, POVERLAY_BUFSIZE);
|
||||
if (request) {
|
||||
respond(request, response);
|
||||
|
||||
|
|
@ -128,10 +128,10 @@ static void on_request(void *lpvParam) {
|
|||
cleanup:
|
||||
if (sockfd) {
|
||||
close(*sockfd);
|
||||
free(sockfd);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, sockfd);
|
||||
}
|
||||
if (response) {
|
||||
free(response);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, response);
|
||||
}
|
||||
|
||||
pdbg_logf(D_NOTICE, "InstanceThread exiting.");
|
||||
|
|
@ -259,7 +259,7 @@ void prpc_main_loop() {
|
|||
return;
|
||||
}
|
||||
|
||||
free(sockpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, sockpath);
|
||||
|
||||
if (listen(fd, 5) == -1) {
|
||||
pdbg_logf(D_ERROR, "Unix socket listen error");
|
||||
|
|
@ -272,7 +272,7 @@ void prpc_main_loop() {
|
|||
continue;
|
||||
}
|
||||
|
||||
int *cl_ptr = malloc(sizeof(int));
|
||||
int *cl_ptr = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(int));
|
||||
if (!cl_ptr) {
|
||||
pdbg_logf(D_ERROR, "Failed to allocate memory for socket fd");
|
||||
close(cl);
|
||||
|
|
@ -305,14 +305,14 @@ int prpc_register(int cmdid, prpc_handler h) {
|
|||
}
|
||||
memcpy(handlers, handlers_old,
|
||||
handlers_size_old * sizeof(prpc_handler));
|
||||
free(handlers_old);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, handlers_old);
|
||||
}
|
||||
handlers[cmdid - calbacks_lower_band] = h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void prpc_init() {
|
||||
handlers = (prpc_handler *)malloc(sizeof(prpc_handler) * handlers_size);
|
||||
handlers = (prpc_handler *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(prpc_handler) * handlers_size);
|
||||
if (!handlers) {
|
||||
pdbg_logf(D_ERROR, "Failed to allocate handler table");
|
||||
return;
|
||||
|
|
@ -328,7 +328,7 @@ char *prpc_sockpath() {
|
|||
|
||||
const char *subdir = "/.pcloud/prpc.sock";
|
||||
size_t len = strlen(home) + strlen(subdir) + 1;
|
||||
char *sockpath = (char *)malloc(len);
|
||||
char *sockpath = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, len);
|
||||
if (!sockpath) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ static void *thread_entry(void *data) {
|
|||
td->fn.run0();
|
||||
}
|
||||
|
||||
free(data);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -44,13 +44,13 @@ static int start_thread_common(const char *name, thread_data *data) {
|
|||
|
||||
if (ret) {
|
||||
pdbg_logf(D_ERROR, "pthread_create failed for thread %s: %d", name, ret);
|
||||
free(data);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void prun_thread(const char *name, thread0_run run) {
|
||||
thread_data *data = malloc(sizeof(thread_data));
|
||||
thread_data *data = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(thread_data));
|
||||
if (!data) {
|
||||
pdbg_logf(D_ERROR, "malloc failed for thread %s", name);
|
||||
return;
|
||||
|
|
@ -62,7 +62,7 @@ void prun_thread(const char *name, thread0_run run) {
|
|||
}
|
||||
|
||||
void prun_thread1(const char *name, thread1_run run, void *ptr) {
|
||||
thread_data *data = malloc(sizeof(thread_data));
|
||||
thread_data *data = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(thread_data));
|
||||
if (!data) {
|
||||
pdbg_logf(D_ERROR, "malloc failed for thread %s", name);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "prunthrottled.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "ptimer.h"
|
||||
#include "ptree.h"
|
||||
#include "prun.h"
|
||||
|
|
@ -68,7 +69,7 @@ static void ratelimit_timer(psync_timer_t timer, void *ptr) {
|
|||
prun_thread(name, call);
|
||||
} else {
|
||||
ptimer_stop(timer);
|
||||
free(node);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, node);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +113,7 @@ void prun_throttled(const char *name, prun_throttle_cb call,
|
|||
node->scheduled = 1;
|
||||
}
|
||||
} else {
|
||||
node = malloc(sizeof(psync_rr_tree_node));
|
||||
node = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_rr_tree_node));
|
||||
node->call = call;
|
||||
node->name = name;
|
||||
node->scheduled = 0;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ static key_t get_key() {
|
|||
return (key_t)-1;
|
||||
}
|
||||
snprintf(path, sizeof(path), "%s/.pcloud/data.db", home);
|
||||
free(home);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, home);
|
||||
return ftok(path, 'A');
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ bool pshm_read(void **data, size_t *datasz) {
|
|||
*datasz = shm->datasz;
|
||||
}
|
||||
|
||||
*data = malloc(shm->datasz);
|
||||
*data = pmem_malloc(PMEM_SUBSYS_OTHER, shm->datasz);
|
||||
if(*data == NULL) {
|
||||
pdbg_logf(D_ERROR, "Failed to allocate memory for shared data");
|
||||
shmdt(shm);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "pfile.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plist.h"
|
||||
#include "ppath.h"
|
||||
#include "pscanexts.h"
|
||||
|
|
@ -116,7 +117,7 @@ static void dir_scan(void *ptr, ppath_fast_stat *st) {
|
|||
size_t l, o;
|
||||
l = strlen(st->name);
|
||||
o = f->pathlen;
|
||||
nf = (scan_folder *)malloc(sizeof(scan_folder) + o + l + 2);
|
||||
nf = (scan_folder *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(scan_folder) + o + l + 2);
|
||||
psync_list_init(&nf->subfolders);
|
||||
path = (char *)(nf + 1);
|
||||
memcpy(path, f->path, o);
|
||||
|
|
@ -163,7 +164,7 @@ static void suggest_folders(scan_folder *f, psync_list *suggestions) {
|
|||
if (sum >= PSYNC_SCANNER_MIN_FILES &&
|
||||
sum >= (f->filecnt[0] + sum) * PSYNC_SCANNER_PERCENT / 100) {
|
||||
// pdbg_logf(D_NOTICE, "suggesting %s sum %u", f->path, sum);
|
||||
s = malloc(sizeof(suggested_folder));
|
||||
s = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(suggested_folder));
|
||||
s->folder = f;
|
||||
s->filecnt = sum;
|
||||
psync_list_add_tail(suggestions, &s->list);
|
||||
|
|
@ -185,7 +186,7 @@ static int sort_comp_tuple_rev(const void *p1, const void *p2) {
|
|||
static void free_folder(scan_folder *f) {
|
||||
psync_list_for_each_element_call(&f->subfolders, scan_folder, nextfolder,
|
||||
free_folder);
|
||||
free(f);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, f);
|
||||
}
|
||||
|
||||
psuggested_folders_t *psuggest_scan_folder(const char *path) {
|
||||
|
|
@ -200,7 +201,7 @@ psuggested_folders_t *psuggest_scan_folder(const char *path) {
|
|||
size_t descslen[PSYNC_SCANNER_MAX_SUGGESTIONS];
|
||||
char buff[256];
|
||||
uint32_t scnt[PSYNC_SCAN_TYPES_CNT][2];
|
||||
f = malloc(sizeof(scan_folder));
|
||||
f = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(scan_folder));
|
||||
psync_list_init(&f->nextfolder);
|
||||
psync_list_init(&f->subfolders);
|
||||
f->path = path;
|
||||
|
|
@ -234,12 +235,12 @@ psuggested_folders_t *psuggest_scan_folder(const char *path) {
|
|||
ln += s->folder->pathlen + off + 2;
|
||||
sf[cnt] = s;
|
||||
descslen[cnt] = off + 1;
|
||||
descs[cnt] = malloc(descslen[cnt]);
|
||||
descs[cnt] = pmem_malloc(PMEM_SUBSYS_OTHER, descslen[cnt]);
|
||||
memcpy(descs[cnt], buff, descslen[cnt]);
|
||||
if (++cnt >= PSYNC_SCANNER_MAX_SUGGESTIONS)
|
||||
break;
|
||||
}
|
||||
ret = malloc(offsetof(psuggested_folders_t, entries) +
|
||||
ret = pmem_malloc(PMEM_SUBSYS_OTHER, offsetof(psuggested_folders_t, entries) +
|
||||
sizeof(psuggested_folder_t) * cnt + ln);
|
||||
str = ((char *)ret) + offsetof(psuggested_folders_t, entries) +
|
||||
sizeof(psuggested_folder_t) * cnt;
|
||||
|
|
@ -260,7 +261,7 @@ psuggested_folders_t *psuggest_scan_folder(const char *path) {
|
|||
ret->entries[i].description = str;
|
||||
memcpy(str, descs[i], descslen[i]);
|
||||
str += descslen[i];
|
||||
free(descs[i]);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, descs[i]);
|
||||
pdbg_logf(D_NOTICE, "suggesting %s (%s, %s)", ret->entries[i].localpath,
|
||||
ret->entries[i].name, ret->entries[i].description);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "pfile.h"
|
||||
#include "pfoldersync.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plocalnotify.h"
|
||||
#include "plocalscan.h"
|
||||
#include "ppathstatus.h"
|
||||
|
|
@ -61,7 +62,7 @@ static psync_tree *synced_down_folders = PSYNC_TREE_EMPTY;
|
|||
static pthread_mutex_t sync_down_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static psync_tree *psync_new_sd_folder(psync_folderid_t folderid) {
|
||||
synced_down_folder *f = malloc(sizeof(synced_down_folder));
|
||||
synced_down_folder *f = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(synced_down_folder));
|
||||
f->folderid = folderid;
|
||||
return &f->tree;
|
||||
}
|
||||
|
|
@ -117,7 +118,7 @@ void psyncer_dl_queue_del(psync_folderid_t folderid) {
|
|||
f = ptree_element(f->tree.right, synced_down_folder, tree);
|
||||
else {
|
||||
ptree_del(&synced_down_folders, &f->tree);
|
||||
free(f);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -208,7 +209,7 @@ psync_folderid_t psyncer_db_folder_create(
|
|||
if (psql_affected() > 0) {
|
||||
lfolderid = psql_insertid();
|
||||
psql_free(res);
|
||||
free(vname);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, vname);
|
||||
return lfolderid;
|
||||
}
|
||||
psql_free(res);
|
||||
|
|
@ -238,7 +239,7 @@ psync_folderid_t psyncer_db_folder_create(
|
|||
psql_run_free(res);
|
||||
}
|
||||
psyncer_folder_inc_tasks(lfolderid);
|
||||
free(vname);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, vname);
|
||||
return lfolderid;
|
||||
}
|
||||
|
||||
|
|
@ -338,16 +339,16 @@ static void psync_sync_newsyncedfolder(psync_syncid_t syncid) {
|
|||
}
|
||||
} else
|
||||
psql_rollback();
|
||||
free(localpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, localpath);
|
||||
}
|
||||
|
||||
static void psync_do_sync_thread(void *ptr) {
|
||||
psync_sync_newsyncedfolder(*((psync_syncid_t *)ptr));
|
||||
free(ptr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ptr);
|
||||
}
|
||||
|
||||
void psyncer_create(psync_syncid_t syncid) {
|
||||
psync_syncid_t *psid = malloc(sizeof(psync_syncid_t));
|
||||
psync_syncid_t *psid = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_syncid_t));
|
||||
*psid = syncid;
|
||||
prun_thread1("syncer", psync_do_sync_thread, psid);
|
||||
}
|
||||
|
|
@ -470,8 +471,8 @@ re:
|
|||
folderid = pfolder_id_create(remotepath);
|
||||
if (unlikely(folderid == PSYNC_INVALID_FOLDERID)) {
|
||||
pdbg_logf(D_WARNING, "could not get folderid/create folder %s", remotepath);
|
||||
free(localpath);
|
||||
free(remotepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, localpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, remotepath);
|
||||
if (psync_error != PERROR_OFFLINE) {
|
||||
delete_delayed_sync(id);
|
||||
goto re;
|
||||
|
|
@ -486,8 +487,8 @@ re:
|
|||
psql_free(stmt);
|
||||
if (!urow) {
|
||||
psql_commit();
|
||||
free(localpath);
|
||||
free(remotepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, localpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, remotepath);
|
||||
goto re;
|
||||
}
|
||||
stmt = psql_prepare(
|
||||
|
|
@ -504,8 +505,8 @@ re:
|
|||
else
|
||||
syncid = -1;
|
||||
psql_free(stmt);
|
||||
free(localpath);
|
||||
free(remotepath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, localpath);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, remotepath);
|
||||
if (!psql_commit() && syncid != -1) {
|
||||
ppathstatus_reload_syncs();
|
||||
psyncer_create(syncid);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
#include "pfoldersync.h"
|
||||
#include "pfsfolder.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "plist.h"
|
||||
#include "plocalnotify.h"
|
||||
#include "plocalscan.h"
|
||||
|
|
@ -287,9 +288,9 @@ void psync_set_user_pass(const char *username, const char *password, int save) {
|
|||
psync_set_string_value("pass", password);
|
||||
} else {
|
||||
pthread_mutex_lock(&psync_my_auth_mutex);
|
||||
free(psync_my_user);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, psync_my_user);
|
||||
psync_my_user = putil_strdup(username);
|
||||
free(psync_my_pass);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, psync_my_pass);
|
||||
if (password && password[0])
|
||||
psync_my_pass = putil_strdup(password);
|
||||
pthread_mutex_unlock(&psync_my_auth_mutex);
|
||||
|
|
@ -304,7 +305,7 @@ void psync_set_pass(const char *password, int save) {
|
|||
psync_set_string_value("pass", password);
|
||||
else {
|
||||
pthread_mutex_lock(&psync_my_auth_mutex);
|
||||
free(psync_my_pass);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, psync_my_pass);
|
||||
psync_my_pass = putil_strdup(password);
|
||||
pthread_mutex_unlock(&psync_my_auth_mutex);
|
||||
}
|
||||
|
|
@ -345,7 +346,7 @@ void psync_logout(uint32_t auth_status, int doinvauth) {
|
|||
pthread_mutex_lock(&psync_my_auth_mutex);
|
||||
if (psync_my_pass) {
|
||||
putil_wipe(psync_my_pass, strlen(psync_my_pass));
|
||||
free(psync_my_pass);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, psync_my_pass);
|
||||
psync_my_pass = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&psync_my_auth_mutex);
|
||||
|
|
@ -407,7 +408,7 @@ apiservers_list_t *psync_get_apiservers(char **err) {
|
|||
locations = papi_find_result2(bres, "locations", PARAM_ARRAY);
|
||||
locationscnt = locations->length;
|
||||
if (!locationscnt) {
|
||||
free(bres);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, bres);
|
||||
return NULL;
|
||||
}
|
||||
builder = psync_list_builder_create(sizeof(apiserver_info_t),
|
||||
|
|
@ -475,7 +476,7 @@ void psync_unlink() {
|
|||
ret = psql_close();
|
||||
pfile_delete(psync_database);
|
||||
if (ret) {
|
||||
free(deviceid);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, deviceid);
|
||||
pdbg_logf(D_ERROR, "failed to close database, exiting");
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -485,7 +486,7 @@ void psync_unlink() {
|
|||
res = psql_prepare("REPLACE INTO setting (id, value) VALUES ('deviceid', ?)");
|
||||
psql_bind_str(res, 1, deviceid);
|
||||
psql_run_free(res);
|
||||
free(deviceid);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, deviceid);
|
||||
}
|
||||
pthread_mutex_lock(&psync_my_auth_mutex);
|
||||
putil_wipe(psync_my_auth, sizeof(psync_my_auth));
|
||||
|
|
@ -523,7 +524,7 @@ int psync_tfa_type() { return psync_my_2fa_type; }
|
|||
static void check_tfa_result(uint64_t result) {
|
||||
if (result == 2064) {
|
||||
if (pstatus_get(PSTATUS_TYPE_AUTH) == PSTATUS_AUTH_TFAREQ) {
|
||||
free(psync_my_2fa_token);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, psync_my_2fa_token);
|
||||
psync_my_2fa_token = NULL;
|
||||
pstatus_set(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
|
||||
}
|
||||
|
|
@ -567,7 +568,7 @@ int psync_tfa_send_sms(char **country_code, char **phone_number) {
|
|||
return -1;
|
||||
code = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
if (code) {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
check_tfa_result(code);
|
||||
return code;
|
||||
}
|
||||
|
|
@ -578,7 +579,7 @@ int psync_tfa_send_sms(char **country_code, char **phone_number) {
|
|||
if (phone_number)
|
||||
*phone_number = binresult_to_str(papi_get_result2(cres, "msisdn"));
|
||||
}
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -597,7 +598,7 @@ int psync_tfa_send_nofification(plogged_device_list_t **devices_list) {
|
|||
return -1;
|
||||
code = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
if (code) {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
check_tfa_result(code);
|
||||
return code;
|
||||
}
|
||||
|
|
@ -620,7 +621,7 @@ int psync_tfa_send_nofification(plogged_device_list_t **devices_list) {
|
|||
*devices_list =
|
||||
(plogged_device_list_t *)psync_list_builder_finalize(builder);
|
||||
}
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -799,7 +800,7 @@ psuggested_folders_t *psync_get_sync_suggestions() {
|
|||
home = ppath_home();
|
||||
if (pdbg_likely(home)) {
|
||||
ret = psuggest_scan_folder(home);
|
||||
free(home);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, home);
|
||||
return ret;
|
||||
} else {
|
||||
psync_error = PERROR_NO_HOMEDIR;
|
||||
|
|
@ -818,7 +819,7 @@ int psync_is_lname_to_ignore(const char *name, size_t namelen) {
|
|||
size_t ilen, off, pl;
|
||||
char buff[120];
|
||||
if (namelen >= sizeof(buff))
|
||||
namelower = (char *)malloc(namelen + 1);
|
||||
namelower = (char *)pmem_malloc(PMEM_SUBSYS_OTHER, namelen + 1);
|
||||
else
|
||||
namelower = buff;
|
||||
memcpy(namelower, name, namelen);
|
||||
|
|
@ -847,13 +848,13 @@ int psync_is_lname_to_ignore(const char *name, size_t namelen) {
|
|||
pl--;
|
||||
if (psync_match_pattern(namelower, pt, pl)) {
|
||||
if (namelower != buff)
|
||||
free(namelower);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, namelower);
|
||||
pdbg_logf(D_NOTICE, "ignoring file/folder %s", name);
|
||||
return 1;
|
||||
}
|
||||
} while (sc);
|
||||
if (namelower != buff)
|
||||
free(namelower);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, namelower);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -912,7 +913,7 @@ static int do_run_command_get_res(const char *cmd, size_t cmdlen,
|
|||
psync_process_api_error(result);
|
||||
}
|
||||
if (result)
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
else
|
||||
*pres = res;
|
||||
return (int)result;
|
||||
|
|
@ -961,7 +962,7 @@ int psync_register(const char *email, const char *password, int termsaccepted,
|
|||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
}
|
||||
psock_close(sock);
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -993,12 +994,12 @@ int psync_change_password(const char *currentpass, const char *newpass,
|
|||
PAPI_BOOL("regetauth", 1)};
|
||||
ret = run_command_get_res("changepassword", params, err, &res);
|
||||
}
|
||||
free(device);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, device);
|
||||
if (ret)
|
||||
return ret;
|
||||
putil_strlcpy(psync_my_auth, papi_find_result2(res, "auth", PARAM_STR)->str,
|
||||
sizeof(psync_my_auth));
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1011,7 +1012,7 @@ int psync_create_remote_folder_by_path(const char *path, char **err) {
|
|||
if (ret)
|
||||
return ret;
|
||||
pfileops_create_fldr(papi_find_result2(res, "metadata", PARAM_HASH));
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
pdiff_wake();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1027,7 +1028,7 @@ int psync_create_remote_folder(psync_folderid_t parentfolderid,
|
|||
if (ret)
|
||||
return ret;
|
||||
pfileops_create_fldr(papi_find_result2(res, "metadata", PARAM_HASH));
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
pdiff_wake();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1450,9 +1451,9 @@ int psync_remove_share(psync_shareid_t shareid, char **err) {
|
|||
result = psync_account_stopshare(shareid, &err1);
|
||||
if (result == 2075) {
|
||||
result = 2025;
|
||||
free(err1);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, err1);
|
||||
} else {
|
||||
free(*err);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, *err);
|
||||
*err = err1;
|
||||
}
|
||||
pdbg_logf(D_NOTICE, "erroris %s", *err);
|
||||
|
|
@ -1482,9 +1483,9 @@ int psync_modify_share(psync_shareid_t shareid, uint32_t permissions,
|
|||
psync_account_modifyshare(shareid, convert_perms(permissions), &err1);
|
||||
if (result == 2075) {
|
||||
result = 2025;
|
||||
free(err1);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, err1);
|
||||
} else {
|
||||
free(*err);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, *err);
|
||||
*err = err1;
|
||||
}
|
||||
pdbg_logf(D_NOTICE, "erroris %s", *err);
|
||||
|
|
@ -1502,7 +1503,7 @@ static void psync_del_all_except(void *ptr, ppath_fast_stat *st) {
|
|||
pdbg_logf(D_NOTICE, "deleting old update file %s", fp);
|
||||
if (pfile_delete(fp))
|
||||
pdbg_logf(D_WARNING, "could not delete %s", fp);
|
||||
free(fp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, fp);
|
||||
}
|
||||
|
||||
static char *psync_filename_from_res(const binresult *res) {
|
||||
|
|
@ -1520,8 +1521,8 @@ static char *psync_filename_from_res(const binresult *res) {
|
|||
nmarr[1] = nmd;
|
||||
ppath_ls_fast(path, psync_del_all_except, (void *)nmarr);
|
||||
ret = putil_strcat(path, "/", nmd, NULL);
|
||||
free(nmd);
|
||||
free(path);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, nmd);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1532,13 +1533,13 @@ static int psync_upload_result(binresult *res, psync_fileid_t *fileid) {
|
|||
const binresult *meta =
|
||||
papi_find_result2(res, "metadata", PARAM_ARRAY)->array[0];
|
||||
*fileid = papi_find_result2(meta, "fileid", PARAM_NUM)->num;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
pdiff_wake();
|
||||
return 0;
|
||||
} else {
|
||||
pdbg_logf(D_WARNING, "uploadfile returned error %u: %s", (unsigned)result,
|
||||
papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
psync_process_api_error(result);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1603,7 +1604,7 @@ static int psync_load_file(const char *local_path, char **data,
|
|||
if (fstat(fd, &st1))
|
||||
goto err1;
|
||||
len = pfile_stat_size(&st1);
|
||||
buff = malloc(len);
|
||||
buff = pmem_malloc(PMEM_SUBSYS_OTHER, len);
|
||||
if (!buff)
|
||||
goto err1;
|
||||
off = 0;
|
||||
|
|
@ -1621,7 +1622,7 @@ static int psync_load_file(const char *local_path, char **data,
|
|||
*length = len;
|
||||
return 0;
|
||||
}
|
||||
free(buff);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, buff);
|
||||
}
|
||||
return -1;
|
||||
err1:
|
||||
|
|
@ -1638,7 +1639,7 @@ int psync_upload_file(psync_folderid_t folderid, const char *remote_filename,
|
|||
if (psync_load_file(local_path, &data, &length))
|
||||
return -2;
|
||||
ret = psync_upload_data(folderid, remote_filename, data, length, fileid);
|
||||
free(data);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1651,7 +1652,7 @@ int psync_upload_file_as(const char *remote_path, const char *remote_filename,
|
|||
return -2;
|
||||
ret =
|
||||
psync_upload_data_as(remote_path, remote_filename, data, length, fileid);
|
||||
free(data);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1759,7 +1760,7 @@ psync_folderid_t *psync_crypto_folderids() {
|
|||
size_t alloc, l;
|
||||
alloc = 2;
|
||||
l = 0;
|
||||
ret = malloc(sizeof(psync_folderid_t) * alloc);
|
||||
ret = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_folderid_t) * alloc);
|
||||
res = psql_query_rdlock(
|
||||
"SELECT f1.id FROM folder f1, folder f2 WHERE f1.parentfolderid=f2.id "
|
||||
"AND "
|
||||
|
|
@ -1814,7 +1815,7 @@ int psync_crypto_change_crypto_pass(const char *oldpass, const char *newpass,
|
|||
}
|
||||
}
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
if (result != 0)
|
||||
pdbg_logf(D_WARNING, "crypto_changeuserprivate returned %u",
|
||||
(unsigned)result);
|
||||
|
|
@ -1861,7 +1862,7 @@ int psync_crypto_change_crypto_pass_unlocked(const char *newpass,
|
|||
}
|
||||
}
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
if (result != 0)
|
||||
pdbg_logf(D_WARNING, "crypto_changeuserprivate returned %u",
|
||||
(unsigned)result);
|
||||
|
|
@ -1890,7 +1891,7 @@ int psync_crypto_crypto_send_change_user_private() {
|
|||
psync_apipool_release(api);
|
||||
}
|
||||
result = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
if (result != 0)
|
||||
pdbg_logf(D_WARNING, "crypto_sendchangeuserprivate returned %u",
|
||||
(unsigned)result);
|
||||
|
|
@ -2129,12 +2130,12 @@ int psync_get_promo(char **url, uint64_t *width, uint64_t *height) {
|
|||
|
||||
if (result) {
|
||||
pdbg_logf(D_WARNING, "getpromourl returned %d", (int)result);
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!papi_find_result2(res, "haspromo", PARAM_BOOL)->num) {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2144,7 +2145,7 @@ int psync_get_promo(char **url, uint64_t *width, uint64_t *height) {
|
|||
if (!papi_find_result2(res, "width", PARAM_NUM)->num) {
|
||||
pdbg_logf(D_NOTICE, "Parameter width not found.");
|
||||
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -2154,14 +2155,14 @@ int psync_get_promo(char **url, uint64_t *width, uint64_t *height) {
|
|||
if (!papi_find_result2(res, "height", PARAM_NUM)->num) {
|
||||
pdbg_logf(D_NOTICE, "Parameter height not found.");
|
||||
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return result;
|
||||
}
|
||||
|
||||
*height = papi_find_result2(res, "height", PARAM_NUM)->num;
|
||||
pdbg_logf(D_NOTICE, "Promo window Height: [%lu]", *height);
|
||||
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2269,12 +2270,12 @@ int psync_is_folder_syncable(char *localPath, char **errMsg) {
|
|||
if (!memcmp(syncmp, localPath, len) &&
|
||||
(localPath[len] == 0 || localPath[len] == '/' ||
|
||||
localPath[len] == '\\')) {
|
||||
free(syncmp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, syncmp);
|
||||
|
||||
*errMsg = putil_strdup("Folder is located on pCloud drive.");
|
||||
return PERROR_LOCAL_IS_ON_PDRIVE;
|
||||
}
|
||||
free(syncmp);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, syncmp);
|
||||
}
|
||||
|
||||
// Check if folder is not a child of an igrnored folder
|
||||
|
|
@ -2309,7 +2310,7 @@ psync_folderid_t create_bup_mach_folder(char **msgErr) {
|
|||
tmpBuff = get_pc_name();
|
||||
putil_strlcpy(bRootFoName, tmpBuff, 64);
|
||||
|
||||
free(tmpBuff);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, tmpBuff);
|
||||
|
||||
eventParams requiredParams = {3, // Number of parameters we are passing below.
|
||||
{PAPI_STR("auth", psync_my_auth),
|
||||
|
|
@ -2332,7 +2333,7 @@ psync_folderid_t create_bup_mach_folder(char **msgErr) {
|
|||
psql_bind_uint(sql, 1, rootFolIdObj->num);
|
||||
psql_run_free(sql);
|
||||
|
||||
free(retData);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, retData);
|
||||
}
|
||||
if (rootFolIdObj) {
|
||||
return rootFolIdObj->num;
|
||||
|
|
@ -2406,7 +2407,7 @@ int psync_create_backup(char *path, char **errMsg) {
|
|||
|
||||
syncFId = pfolder_add_sync(path, folId->num, PSYNC_BACKUPS);
|
||||
|
||||
free(retData);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, retData);
|
||||
|
||||
if (syncFId < 0) {
|
||||
*errMsg = putil_strdup("Error creating backup.");
|
||||
|
|
@ -2617,12 +2618,12 @@ userinfo_t *psync_get_userinfo() {
|
|||
PAPI_STR("timeformat", "timestamp")};
|
||||
res = psync_api_run_command("userinfo", params);
|
||||
if (!res) {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return NULL;
|
||||
}
|
||||
err = papi_find_result2(res, "result", PARAM_NUM)->num;
|
||||
if (err) {
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -2637,7 +2638,7 @@ userinfo_t *psync_get_userinfo() {
|
|||
language = cres->str;
|
||||
llanguage =
|
||||
(cres->length + sizeof(void *)) / sizeof(void *) * sizeof(void *);
|
||||
info = (userinfo_t *)malloc(sizeof(userinfo_t) + lemail + lcurrency +
|
||||
info = (userinfo_t *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(userinfo_t) + lemail + lcurrency +
|
||||
llanguage);
|
||||
ptr = (char *)(info + 1);
|
||||
memcpy(ptr, email, lemail);
|
||||
|
|
@ -2685,7 +2686,7 @@ userinfo_t *psync_get_userinfo() {
|
|||
info->usedquota = papi_find_result2(res, "usedquota", PARAM_NUM)->num;
|
||||
info->freequota = papi_find_result2(res, "freequota", PARAM_NUM)->num;
|
||||
info->registered = papi_find_result2(res, "registered", PARAM_NUM)->num;
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void psys_init() {
|
|||
psync_uid = getuid();
|
||||
psync_gid = getgid();
|
||||
psync_gids_cnt = getgroups(0, NULL);
|
||||
psync_gids = malloc(sizeof(gid_t) * psync_gids_cnt);
|
||||
psync_gids = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(gid_t) * 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));
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "pdownload.h"
|
||||
#include "pfile.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "pnetlibs.h"
|
||||
#include "ppathstatus.h"
|
||||
#include "prun.h"
|
||||
|
|
@ -272,8 +273,8 @@ static int download_send_error(stream_t *s, async_params_t *prms,
|
|||
pdbg_logf(D_NOTICE, "closing stream %u", (unsigned)s->streamid);
|
||||
ptree_del(&prms->streams, &s->tree);
|
||||
if (s->free)
|
||||
s->free(s, error);
|
||||
free(s);
|
||||
s->pmem_free(PMEM_SUBSYS_OTHER, s, error);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -618,7 +619,7 @@ static void proc_async_transfer(void *ptr) {
|
|||
pdeflate_destroy(prms->dec);
|
||||
ptree_for_each_element_call_safe(prms->streams, stream_t, tree,
|
||||
stream_destroy);
|
||||
free(prms);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, prms);
|
||||
}
|
||||
|
||||
static int proc_start_async_transfer() {
|
||||
|
|
@ -655,11 +656,11 @@ static int proc_start_async_transfer() {
|
|||
(int)papi_find_result2(res, "result", PARAM_NUM)->num,
|
||||
papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
psync_process_api_error(papi_find_result2(res, "result", PARAM_NUM)->num);
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
psync_apipool_release(api);
|
||||
goto err0;
|
||||
}
|
||||
free(res);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, res);
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair)) {
|
||||
pdbg_logf(D_NOTICE, "socketpair() failed");
|
||||
goto err1;
|
||||
|
|
@ -674,7 +675,7 @@ static int proc_start_async_transfer() {
|
|||
pdbg_logf(D_NOTICE, "pdeflate_init() failed");
|
||||
goto err3;
|
||||
}
|
||||
tparams = malloc(sizeof(async_params_t));
|
||||
tparams = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(async_params_t));
|
||||
memset(tparams, 0, sizeof(async_params_t));
|
||||
tparams->enc = enc;
|
||||
tparams->dec = dec;
|
||||
|
|
@ -742,7 +743,7 @@ static int sock_writeall(int sock, const void *buff, size_t len) {
|
|||
static stream_t *stream_create(async_params_t *prms, size_t addsize) {
|
||||
psync_tree *parent;
|
||||
stream_t *ret;
|
||||
ret = (stream_t *)malloc(sizeof(stream_t) + addsize);
|
||||
ret = (stream_t *)pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(stream_t) + addsize);
|
||||
ret->streamid = ++prms->laststreamid;
|
||||
ret->flags = 0;
|
||||
ret->free = NULL;
|
||||
|
|
@ -765,8 +766,8 @@ static void stream_destroy(stream_t *s) {
|
|||
s->cb(s->cbext, &ar);
|
||||
}
|
||||
if (s->free)
|
||||
s->free(s, PSYNC_ASYNC_ERROR_NET);
|
||||
free(s);
|
||||
s->pmem_free(PMEM_SUBSYS_OTHER, s, PSYNC_ASYNC_ERROR_NET);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, s);
|
||||
}
|
||||
|
||||
static int stream_process_data(async_params_t *prms) {
|
||||
|
|
@ -849,7 +850,7 @@ static void psync_task_destroy(psync_task_manager_t tm) {
|
|||
for (i = 0; i < tm->taskcnt; i++)
|
||||
pthread_cond_destroy(&tm->tasks[i].cond);
|
||||
pthread_mutex_destroy(&tm->mutex);
|
||||
free(tm);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, tm);
|
||||
}
|
||||
|
||||
static void psync_task_dec_refcnt(psync_task_manager_t tm) {
|
||||
|
|
@ -1113,8 +1114,8 @@ void ptask_cfldr_save_fldrkey(void *ptr) {
|
|||
psql_bind_uint(res, 1, t->id);
|
||||
psql_bind_blob(res, 2, (const char *)t->key->data, t->key->datalen);
|
||||
psql_run_free(res);
|
||||
free(t->key);
|
||||
free(t);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, t->key);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, t);
|
||||
}
|
||||
|
||||
void ptask_cfldr_save_filekey(void *ptr) {
|
||||
|
|
@ -1127,8 +1128,8 @@ void ptask_cfldr_save_filekey(void *ptr) {
|
|||
psql_bind_uint(res, 2, t->hash);
|
||||
psql_bind_blob(res, 3, (const char *)t->key->data, t->key->datalen);
|
||||
psql_run_free(res);
|
||||
free(t->key);
|
||||
free(t);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, t->key);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, t);
|
||||
}
|
||||
|
||||
// from plibs.c
|
||||
|
|
@ -1137,7 +1138,7 @@ psync_task_manager_t psync_task_run_tasks(psync_task_callback_t const *callbacks
|
|||
psync_task_manager_t ret;
|
||||
struct psync_task_t_ *t;
|
||||
int i;
|
||||
ret = (psync_task_manager_t)malloc(
|
||||
ret = (psync_task_manager_t)pmem_malloc(PMEM_SUBSYS_OTHER,
|
||||
offsetof(struct psync_task_manager_t_, tasks) +
|
||||
sizeof(struct psync_task_t_) * cnt);
|
||||
pthread_mutex_init(&ret->mutex, NULL);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ static void proc_send_data_event(void *ptr) {
|
|||
}
|
||||
pthread_mutex_unlock(&data_event_fptr_mutex);
|
||||
|
||||
free((void *)data->str1);
|
||||
free((void *)data->str2);
|
||||
free(ptr);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, (void *)data->str1);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, (void *)data->str2);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ptr);
|
||||
}
|
||||
|
||||
void ptevent_init(void *ptr) {
|
||||
|
|
@ -41,7 +41,7 @@ void ptevent_process(event_data_struct *data) {
|
|||
pthread_mutex_unlock(&data_event_fptr_mutex);
|
||||
|
||||
if (has_callback) {
|
||||
event_data = malloc(sizeof(event_data_struct));
|
||||
event_data = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(event_data_struct));
|
||||
event_data->eventid = data->eventid;
|
||||
event_data->uint1 = data->uint1;
|
||||
event_data->uint2 = data->uint2;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "pcache.h"
|
||||
#include "pcompiler.h"
|
||||
#include "plibs.h"
|
||||
#include "pmem.h"
|
||||
#include "prun.h"
|
||||
#include "psys.h"
|
||||
#include "ptimer.h"
|
||||
|
|
@ -200,7 +201,7 @@ psync_timer_t ptimer_register(psync_timer_callback func, time_t numsec,
|
|||
psync_timer_t timer;
|
||||
uint32_t i;
|
||||
time_t n;
|
||||
timer = malloc(sizeof(psync_timer_structure_t));
|
||||
timer = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(psync_timer_structure_t));
|
||||
timer->call = func;
|
||||
timer->param = param;
|
||||
n = TIMER_ARRAY_SIZE;
|
||||
|
|
@ -241,7 +242,7 @@ int ptimer_stop(psync_timer_t timer) {
|
|||
}
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
if (needfree) {
|
||||
free(timer);
|
||||
pmem_free(PMEM_SUBSYS_OTHER, timer);
|
||||
return 0;
|
||||
} else
|
||||
return 1;
|
||||
|
|
@ -249,7 +250,7 @@ int ptimer_stop(psync_timer_t timer) {
|
|||
|
||||
void ptimer_exception_handler(psync_exception_callback func) {
|
||||
struct exception_list *t;
|
||||
t = malloc(sizeof(struct exception_list));
|
||||
t = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(struct exception_list));
|
||||
t->next = NULL;
|
||||
t->func = func;
|
||||
t->threadid = pthread_self();
|
||||
|
|
@ -261,7 +262,7 @@ void ptimer_exception_handler(psync_exception_callback func) {
|
|||
|
||||
void ptimer_sleep_handler(psync_exception_callback func) {
|
||||
struct exception_list *t;
|
||||
t = malloc(sizeof(struct exception_list));
|
||||
t = pmem_malloc(PMEM_SUBSYS_OTHER, sizeof(struct exception_list));
|
||||
t->next = NULL;
|
||||
t->func = func;
|
||||
t->threadid = pthread_self();
|
||||
|
|
|
|||
Loading…
Reference in New Issue