#include <unistd.h>
#include <xseg/xseg.h>
#include <xseg/protocol.h>
-#include <mpeer.h>
+#include <speer.h>
+#include <sched.h>
+#include <sys/syscall.h>
enum io_state_enum {
ACCEPTED = 0,
return 0;
}
vio->err = 0; //reset error state
- vio->mreq = xseg_get_request(peer->xseg, peer->portno,
+ vio->mreq = xseg_get_request(peer->xseg, pr->portno,
vlmc->mportno, X_ALLOC);
if (!vio->mreq)
goto out_err;
case X_READ: vio->mreq->op = X_MAPR; break;
case X_WRITE: vio->mreq->op = X_MAPW; break;
case X_INFO: vio->mreq->op = X_INFO; break;
+ case X_CLOSE: vio->mreq->op = X_CLOSE; break;
default: goto out_put;
}
xseg_set_req_data(peer->xseg, vio->mreq, pr);
__set_vio_state(vio, MAPPING);
- p = xseg_submit(peer->xseg, vio->mreq, peer->portno, X_ALLOC);
+ p = xseg_submit(peer->xseg, vio->mreq, pr->portno, X_ALLOC);
if (p == NoPort)
goto out_unset;
r = xseg_signal(peer->xseg, p);
out_unset:
xseg_get_req_data(peer->xseg, vio->mreq, &dummy);
out_put:
- xseg_put_request(peer->xseg, vio->mreq, peer->portno);
+ xseg_put_request(peer->xseg, vio->mreq, pr->portno);
out_err:
__set_vio_state(vio, CONCLUDED);
fail(peer, pr);
/* FIXME shouldn's XS_FAILED be sufficient ?? */
if (vio->mreq->state & XS_FAILED && !(vio->mreq->state & XS_SERVED)){
fprintf(stderr, "req %lx (op: %d) failed\n", vio->mreq, vio->mreq->op);
- xseg_put_request(peer->xseg, vio->mreq, peer->portno);
+ xseg_put_request(peer->xseg, vio->mreq, pr->portno);
vio->mreq = NULL;
__set_vio_state(vio, CONCLUDED);
fail(peer, pr);
} else if (vio->mreq->op == X_INFO) {
struct xseg_reply_info *xinfo = (struct xseg_reply_info *) xseg_get_data(peer->xseg, vio->mreq);
char *data = xseg_get_data(peer->xseg, pr->req);
- *(off_t *)data = xinfo->size;
- xseg_put_request(peer->xseg, vio->mreq, peer->portno);
+ *(uint64_t *)data = xinfo->size;
+ xseg_put_request(peer->xseg, vio->mreq, pr->portno);
+ vio->mreq = NULL;
+ __set_vio_state(vio, CONCLUDED);
+ complete(peer, pr);
+ } else if (vio->mreq->op == X_CLOSE) {
+ xseg_put_request(peer->xseg, vio->mreq, pr->portno);
vio->mreq = NULL;
__set_vio_state(vio, CONCLUDED);
complete(peer, pr);
struct xseg_reply_map *mreply = (struct xseg_reply_map *) xseg_get_data(peer->xseg, vio->mreq);
if (!mreply->cnt){
printf("foo2\n");
- xseg_put_request(peer->xseg, vio->mreq, peer->portno);
+ xseg_put_request(peer->xseg, vio->mreq, pr->portno);
vio->mreq = NULL;
__set_vio_state(vio, CONCLUDED);
fail(peer, pr);
vio->breqs = calloc(vio->breq_len, sizeof(struct xseg_request *));
if (!vio->breqs) {
printf("foo3\n");
- xseg_put_request(peer->xseg, vio->mreq, peer->portno);
+ xseg_put_request(peer->xseg, vio->mreq, pr->portno);
vio->mreq = NULL;
__set_vio_state(vio, CONCLUDED);
fail(peer, pr);
for (i = 0; i < vio->breq_len; i++) {
datalen = mreply->segs[i].size;
offset = mreply->segs[i].offset;
- targetlen = strlen(mreply->segs[i].target);
- breq = xseg_get_request(peer->xseg, peer->portno, vlmc->bportno, X_ALLOC);
+ targetlen = mreply->segs[i].targetlen;
+ breq = xseg_get_request(peer->xseg, pr->portno, vlmc->bportno, X_ALLOC);
if (!breq) {
vio->err = 1;
break;
r = xseg_prep_request(peer->xseg, breq, targetlen, datalen);
if (r < 0) {
vio->err = 1;
- xseg_put_request(peer->xseg, breq, peer->portno);
+ xseg_put_request(peer->xseg, breq, pr->portno);
break;
}
breq->offset = offset;
target = xseg_get_target(peer->xseg, breq);
if (!target) {
vio->err = 1;
- xseg_put_request(peer->xseg, breq, peer->portno);
+ xseg_put_request(peer->xseg, breq, pr->portno);
break;
}
strncpy(target, mreply->segs[i].target, targetlen);
r = xseg_set_req_data(peer->xseg, breq, pr);
if (r<0) {
vio->err = 1;
- xseg_put_request(peer->xseg, breq, peer->portno);
+ xseg_put_request(peer->xseg, breq, pr->portno);
break;
}
// this should work, right ?
breq->data = pr->req->data + pos;
pos += datalen;
- p = xseg_submit(peer->xseg, breq, peer->portno, X_ALLOC);
+ p = xseg_submit(peer->xseg, breq, pr->portno, X_ALLOC);
if (p == NoPort){
void *dummy;
vio->err = 1;
xseg_get_req_data(peer->xseg, breq, &dummy);
- xseg_put_request(peer->xseg, breq, peer->portno);
+ xseg_put_request(peer->xseg, breq, pr->portno);
break;
}
r = xseg_signal(peer->xseg, p);
vio->breqs[i] = breq;
}
vio->breq_cnt = i;
- xseg_put_request(peer->xseg, vio->mreq, peer->portno);
+ xseg_put_request(peer->xseg, vio->mreq, pr->portno);
vio->mreq = NULL;
if (i == 0) {
printf("foo4\n");
//assert breq->serviced == breq->size
__sync_fetch_and_add(&pr->req->serviced, breq->serviced);
}
- xseg_put_request(peer->xseg, breq, peer->portno);
+ xseg_put_request(peer->xseg, breq, pr->portno);
if (!__sync_sub_and_fetch(&vio->breq_cnt, 1)) {
__set_vio_state(vio, CONCLUDED);
return 0;
}
-int dispatch(struct peerd *peer, struct peer_req *pr, struct xseg_request *req)
+int dispatch(struct peerd *peer, struct peer_req *pr, struct xseg_request *req,
+ enum dispatch_reason reason)
{
struct vlmc_io *vio = __get_vlmcio(pr);
struct vlmcd *vlmc = __get_vlmcd(peer);
}
}
+ const struct sched_param param = { .sched_priority = 99 };
+ sched_setscheduler(syscall(SYS_gettid), SCHED_FIFO, ¶m);
+
return 0;
}