コード例 #1
0
ファイル: putblock-v2-proc.c プロジェクト: Jack-Tsue/seafile
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);
    }
}
コード例 #2
0
ファイル: sendblock-v2-proc.c プロジェクト: 9thsector/seafile
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;
}
コード例 #3
0
ファイル: wt-monitor.c プロジェクト: 285452612/seafile
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;
}
コード例 #4
0
ファイル: wt-monitor.c プロジェクト: 285452612/seafile
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;
}
コード例 #5
0
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");
}
コード例 #6
0
ファイル: job-mgr.c プロジェクト: haiwen/ccnet
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)); */
    }
}