예제 #1
0
파일: simple.c 프로젝트: cigolabs/flux-core
static void s_io_cb (flux_reactor_t *r, flux_watcher_t *w,
                     int revents, void *arg)
{
    struct context *ctx = arg;
    int *rfd, fd = flux_fd_watcher_get_fd (w);
    char *resp;
    int rc;

    if (dgetline (fd, ctx->buf, ctx->buflen) < 0) {
        diag ("dgetline: %s", strerror (errno));
        flux_reactor_stop_error (r);
        return;
    }
    rc = pmi_simple_server_request (ctx->pmi, ctx->buf, &ctx->fds[1]);
    if (rc < 0) {
        diag ("pmi_simple_server_request: %s", strerror (errno));
        flux_reactor_stop_error (r);
        return;
    }
    while (pmi_simple_server_response (ctx->pmi, &resp, &rfd) == 0) {
        if (dputline (*rfd, resp) < 0) {
            diag ("dputline: %s", strerror (errno));
            flux_reactor_stop_error (r);
            return;
        }
        free (resp);
    }
    if (rc == 1) {
        close (fd);
        flux_watcher_stop (w);
    }
}
예제 #2
0
static void s_io_cb (flux_reactor_t *r, flux_watcher_t *w,
                     int revents, void *arg)
{
    struct context *ctx = arg;
    int fd = flux_fd_watcher_get_fd (w);
    int rc;

    if (dgetline (fd, ctx->buf, sizeof (ctx->buf)) < 0) {
        diag ("dgetline: %s", strerror (errno));
        flux_reactor_stop_error (r);
        return;
    }
    rc = pmi_simple_server_request (ctx->pmi, ctx->buf, &ctx->fds[1]);
    if (rc < 0) {
        diag ("pmi_simple_server_request: %s", strerror (errno));
        flux_reactor_stop_error (r);
        return;
    }
    if (rc == 1) {
        close (fd);
        flux_watcher_stop (w);
    }
}