Exemplo n.º 1
0
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);
    }
}
Exemplo n.º 2
0
static int s_send_response (void *client, const char *buf)
{
    int *rfd = client;
    return dputline (*rfd, buf);
}