mscp_prepare() scans source paths in a thread.

This commit runs mscp_prepare() in a pthread. mscp copy threads
run aysnchronously with mscp_prepare(). So, when mscp_prepare()
has not finished yet (due to too many source files), we can start
to copy files.
This commit is contained in:
Ryo Nakamura
2023-03-13 22:35:51 +09:00
parent ceb9ebd5a8
commit 5f9f20f150
5 changed files with 130 additions and 46 deletions

View File

@@ -155,7 +155,7 @@ int mscp_set_dst_path(struct mscp *m, const char *dst_path);
/**
* @brief Prepare for file transfer. This function checks all source
* files (recursively), resolve paths on the destination side, and
* calculate file chunks.
* calculate file chunks. This function is non-blocking.
*
* @param m mscp instance.
*
@@ -164,6 +164,17 @@ int mscp_set_dst_path(struct mscp *m, const char *dst_path);
*/
int mscp_prepare(struct mscp *m);
/**
* @brief Join prepare thread invoked by mscp_prepare(). mscp_join()
* involves this, so that mscp_prepare_join() should be called when
* mscp_prepare() is called by mscp_start() is not.
*
* @param m mscp instance.
* @return 0 on success, < 0 if an error occured.
* mscp_get_error() can be used to retrieve error message.
*/
int mscp_prepare_join(struct mscp *m);
/**
* @brief Start to copy files. mscp_start() returns immediately. You
* can get statistics via mscp_get_stats() or messages via pipe set by