Trace browser state, transfer I/O and daemon PID
This commit is contained in:
1 parent
aca10e8268
commit
0706ccce8a
3 files changed
+39
-4
No files matched your search
@@ -63,6 +63,8 @@ static void transfer_finish(struct mf_transfer* t, int status) {
|
||||
|
||||
static void transfer_work(void* arg) {
|
||||
struct mf_transfer* t = arg;
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_DEBUG, "member_files: local I/O start transfer=%llu work=%d fd=%d offset=%llu bytes=%u",
|
||||
(unsigned long long)t->request.id, t->work, t->fd, (unsigned long long)t->offset, t->bytes);
|
||||
t->work_status = MF_OK;
|
||||
if (t->work == TRANSFER_PREPARE) {
|
||||
if (t->request.upload) {
|
||||
@@ -113,6 +115,8 @@ static void transfer_release(struct mf_transfer* t) {
|
||||
|
||||
static void transfer_done(void* arg, int error) {
|
||||
struct mf_transfer* t = arg; t->busy = 0;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: local I/O done transfer=%llu work=%d status=%s error=%d cancelled=%d",
|
||||
(unsigned long long)t->request.id, t->work, mf_status_text(t->work_status), error, t->cancelled);
|
||||
int status = error ? MF_CANCELLED : t->work_status;
|
||||
if (t->work == TRANSFER_FINISH) {
|
||||
/* При destroy work могла быть завершена, а completion отменён. fd уже закрыт. */
|
||||
@@ -143,6 +147,9 @@ static void transfer_submit(struct mf_transfer* t, enum transfer_work work) {
|
||||
|
||||
static void transfer_response(void* arg, const struct mf_message* r) {
|
||||
struct mf_transfer* t = arg; t->pending = NULL;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: transfer response transfer=%llu request=%llu cmd=%s status=%s offset=%llu bytes=%u",
|
||||
(unsigned long long)t->request.id, (unsigned long long)r->request_id, mf_command_text(r->command), mf_status_text(r->status),
|
||||
(unsigned long long)r->offset, r->data_len);
|
||||
if (t->cancelled || t->files->closing || r->status) { transfer_finish(t, r->status ? r->status : MF_CANCELLED); return; }
|
||||
if (r->command == MF_STAT) {
|
||||
if (r->type != MF_FILE || r->size > INT64_MAX || mf_zero(r->version, 16)) { transfer_finish(t, MF_INVALID_RANGE); return; }
|
||||
@@ -180,7 +187,7 @@ static void transfer_send(struct mf_transfer* t, uint8_t command) {
|
||||
static void transfer_connected(struct CONN_MGR_HANDLE* h, uint64_t peer, uint64_t group, enum conn_mgr_event event, void* arg) {
|
||||
(void)h; (void)peer; (void)group;
|
||||
struct mf_transfer* t = arg;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: transfer CM id=%llu event=%d", (unsigned long long)t->request.id, event);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: transfer CM id=%llu event=%d", (unsigned long long)t->request.id, event);
|
||||
}
|
||||
|
||||
void member_files_gui_transfer(void* arg) {
|
||||
@@ -215,6 +222,8 @@ void member_files_gui_transfer(void* arg) {
|
||||
static void transfer_cancel(struct mf_transfer* t) {
|
||||
if (t->cancelled || t->work == TRANSFER_FINISH) return;
|
||||
t->cancelled = 1; t->status = MF_CANCELLED;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: transfer cancel id=%llu busy=%d pending=%p work=%d",
|
||||
(unsigned long long)t->request.id, t->busy, (void*)t->pending, t->work);
|
||||
if (t->pending) member_files_cancel(t->pending);
|
||||
else if (!t->busy) transfer_finish(t, MF_CANCELLED);
|
||||
}
|
||||
|
||||
@@ -415,6 +415,8 @@ int main(int argc, char *argv[]) {
|
||||
uasync_destroy(ua, 0); main_ua = NULL;
|
||||
return 1;
|
||||
}
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files startup: core initialized pid=%ld foreground=%d ua=%p files=%p",
|
||||
(long)getpid(), args.foreground, (void*)ua, (void*)instance->member_files);
|
||||
|
||||
// Note: TUN socket is registered in tun_init(), ETCP sockets in init_connections()
|
||||
|
||||
|
||||
@@ -140,11 +140,18 @@ void MemberFileBrowser::updateActions() {
|
||||
}
|
||||
|
||||
bool MemberFileBrowser::post(mf_message& message) {
|
||||
if (!m_group || !server() || !gui_bridge_is_uasync_ready()) return false;
|
||||
if (!m_group || !server() || !gui_bridge_is_uasync_ready()) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI post rejected cmd=%s group=%llx server=%llx ready=%d",
|
||||
mf_command_text(message.command), (unsigned long long)m_group, (unsigned long long)server(), gui_bridge_is_uasync_ready());
|
||||
return false;
|
||||
}
|
||||
auto* q = (mf_gui_request*)u_calloc(1, sizeof(mf_gui_request));
|
||||
if (!q) { DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "file browser: request allocation failed"); return false; }
|
||||
message.request_id = requestId(); message.kind = MF_REQUEST;
|
||||
q->inst = gui_bridge_get_inst(); q->group = m_group; q->server = server(); q->message = message;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI post id=%llu cmd=%s group=%llx server=%llx owner=%llx path=%s",
|
||||
(unsigned long long)message.request_id, mf_command_text(message.command), (unsigned long long)m_group,
|
||||
(unsigned long long)server(), (unsigned long long)message.owner, message.path);
|
||||
gui_bridge_post_uasync_fn(member_files_gui_request, q); return true;
|
||||
}
|
||||
|
||||
@@ -156,6 +163,8 @@ void MemberFileBrowser::cancelRequest(quint64 id) {
|
||||
}
|
||||
|
||||
void MemberFileBrowser::refresh() {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI refresh old_id=%llu group=%llx server=%llx owner=%llx path=%s",
|
||||
(unsigned long long)m_listId, (unsigned long long)m_group, (unsigned long long)server(), (unsigned long long)owner(), qPrintable(m_path));
|
||||
cancelRequest(m_listId); m_listId = 0; m_entries->clear(); m_location->setText(m_path); updateActions();
|
||||
if (!server()) { m_status->setText(text("No media server in this group")); return; }
|
||||
mf_message q{}; q.command = MF_LIST; q.owner = owner();
|
||||
@@ -180,8 +189,17 @@ void MemberFileBrowser::enter(QTreeWidgetItem* item) {
|
||||
}
|
||||
|
||||
void MemberFileBrowser::onResponse(const uint8_t* data, int length) {
|
||||
if (length < 16 || mf_get64(data) != m_group || mf_get64(data + 8) != server()) return;
|
||||
if (!data || length < 16) { DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI short response bytes=%d", length); return; }
|
||||
if (mf_get64(data) != m_group || mf_get64(data + 8) != server()) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI response ignored context group=%llx/%llx server=%llx/%llx",
|
||||
(unsigned long long)mf_get64(data), (unsigned long long)m_group,
|
||||
(unsigned long long)mf_get64(data + 8), (unsigned long long)server());
|
||||
return;
|
||||
}
|
||||
mf_message r{}; if (mf_decode(data + 16, (size_t)length - 16, &r)) return;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI response id=%llu list_id=%llu cmd=%s status=%s bytes=%u owner=%llx/%llx path=%s",
|
||||
(unsigned long long)r.request_id, (unsigned long long)m_listId, mf_command_text(r.command), mf_status_text(r.status), r.data_len,
|
||||
(unsigned long long)r.owner, (unsigned long long)owner(), r.path);
|
||||
if (r.request_id == m_listId && r.owner == owner() && QString::fromUtf8(r.path) == m_path) {
|
||||
if (r.status) {
|
||||
m_listId = 0;
|
||||
@@ -211,10 +229,16 @@ void MemberFileBrowser::onResponse(const uint8_t* data, int length) {
|
||||
} else {
|
||||
m_listId = 0; m_entries->setSortingEnabled(true); m_entries->sortItems(0, Qt::AscendingOrder);
|
||||
m_status->setText(text("%1 entries").arg(m_entries->topLevelItemCount())); updateActions();
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI directory ready id=%llu entries=%d",
|
||||
(unsigned long long)r.request_id, m_entries->topLevelItemCount());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!m_actions.contains(r.request_id)) return;
|
||||
if (!m_actions.contains(r.request_id)) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI response ignored stale id=%llu cmd=%s",
|
||||
(unsigned long long)r.request_id, mf_command_text(r.command));
|
||||
return;
|
||||
}
|
||||
uint8_t command = m_actions.take(r.request_id);
|
||||
if (r.status && r.status != MF_CANCELLED) { QMessageBox::warning(this, text("Group files"), QString::fromUtf8(mf_status_text(r.status))); return; }
|
||||
if (command == MF_STAT && !r.status) {
|
||||
|
||||
Reference in new issue
Block a user