static void process_get_block (CcnetProcessor *processor, char *content, int clen) { char *space, *block_id; USE_PRIV; if (content[clen-1] != '\0') { ccnet_processor_send_response (processor, SC_BAD_BLK_REQ, SS_BAD_BLK_REQ, NULL, 0); ccnet_processor_done (processor, FALSE); return; } space = strchr (content, ' '); if (!space) { ccnet_processor_send_response (processor, SC_BAD_BLK_REQ, SS_BAD_BLK_REQ, NULL, 0); ccnet_processor_done (processor, FALSE); return; } *space = '\0'; block_id = space + 1; BlockRequest req; req.block_idx = atoi(content); memcpy (req.block_id, block_id, 41); if (pipewriten (priv->tdata->task_pipe[1], &req, sizeof(BlockRequest)) < 0) { g_warning ("[put block] failed to write task pipe.\n"); ccnet_processor_done (processor, FALSE); } }
int seafile_sendblock_v2_proc_send_block (SeafileSendblockV2Proc *proc, int block_idx) { CcnetProcessor *processor = (CcnetProcessor *)proc; BlockList *bl = proc->tx_task->block_list; char *block_id; USE_PRIV; if (block_idx < 0 || block_idx >= bl->n_blocks) return -1; block_id = g_ptr_array_index (bl->block_ids, block_idx); BlockRequest blk_req; memcpy (blk_req.block_id, block_id, 41); blk_req.block_idx = block_idx; if (pipewriten (priv->tdata->task_pipe[1], &blk_req, sizeof(blk_req)) < 0) { g_warning ("failed to write task pipe.\n"); return -1; } ++(proc->pending_blocks); BitfieldAdd (&proc->active, block_idx); return 0; }
int seaf_wt_monitor_refresh_repo (SeafWTMonitor *monitor, const char *repo_id) { WatchCommand cmd; int res; memset (&cmd, 0, sizeof(cmd)); memcpy (cmd.repo_id, repo_id, 37); cmd.type = CMD_REFRESH_WATCH; int n = pipewriten (monitor->cmd_pipe[1], &cmd, sizeof(cmd)); if (n != sizeof(cmd)) { seaf_warning ("[wt mon] fail to write command pipe.\n"); return -1; } seaf_debug ("send a refresh command, repo %s\n", repo_id); n = pipereadn (monitor->res_pipe[0], &res, sizeof(int)); if (n != sizeof(int)) { seaf_warning ("[wt mon] fail to read result pipe.\n"); return -1; } return res; }
int seaf_wt_monitor_watch_repo (SeafWTMonitor *monitor, const char *repo_id, const char *worktree) { WatchCommand cmd; int res; memset (&cmd, 0, sizeof(cmd)); memcpy (cmd.repo_id, repo_id, 37); cmd.type = CMD_ADD_WATCH; g_strlcpy (cmd.worktree, worktree, SEAF_PATH_MAX); int n = pipewriten (monitor->cmd_pipe[1], &cmd, sizeof(cmd)); if (n != sizeof(cmd)) { seaf_warning ("[wt mon] fail to write command pipe.\n"); return -1; } seaf_debug ("send a watch command, repo %s\n", repo_id); n = pipereadn (monitor->res_pipe[0], &res, sizeof(int)); if (n != sizeof(int)) { seaf_warning ("[wt mon] fail to read result pipe.\n"); return -1; } return res; }
static void reply_watch_command (SeafWTMonitor *monitor, int result) { int n; n = pipewriten (monitor->res_pipe[1], &result, sizeof(int)); if (n != sizeof(int)) seaf_warning ("[wt mon] fail to write command result.\n"); }
static void job_thread_wrapper (void *vdata, void *unused) { CcnetJob *job = vdata; job->result = job->thread_func (job->data); if (pipewriten (job->pipefd[1], "a", 1) != 1) { /* g_warning ("[Job Manager] write to pipe error: %s\n", strerror(errno)); */ } }