void np_conn_respond(Npreq *req) { int n; Npconn *conn = req->conn; Npsrv *srv = conn->srv; Npfcall *rc = req->rcall; _debug_trace (srv, rc); xpthread_mutex_lock(&conn->wlock); n = np_trans_send(conn->trans, rc); xpthread_mutex_unlock(&conn->wlock); if (n < 0) np_logerr (srv, "send to '%s'", conn->client_id); }
static int npc_rpc(Npcfsys *fs, Npfcall *tc, Npfcall **rcp) { Npfcall *rc = NULL; u16 tag = P9_NOTAG; int n, ret = -1; if (!fs->trans) { np_uerror(ECONNABORTED); goto done; } if (tc->type != P9_TVERSION) tag = npc_get_id(fs->tagpool); np_set_tag(tc, tag); xpthread_mutex_lock(&fs->lock); n = np_trans_send (fs->trans, tc); if (n >= 0) n = np_trans_recv(fs->trans, &rc, fs->msize); xpthread_mutex_unlock(&fs->lock); if (n < 0) goto done; if (rc == NULL) { np_uerror (EPROTO); /* premature EOF */ goto done; } if (tc->tag != rc->tag) { np_uerror (EPROTO); /* unmatched response */ goto done; } if (rc->type == P9_RLERROR) { np_uerror (rc->u.rlerror.ecode); goto done; } *rcp = rc; ret = 0; done: if (tag != P9_NOTAG) npc_put_id(fs->tagpool, tag); if (ret < 0 && rc != NULL) free (rc); return ret; }