static int posix_prepare_wait(struct xseg *xseg, uint32_t portno)
{
struct xseg_port *port = xseg_get_port(xseg, portno);
- if (!port)
+ if (!port)
return -1;
struct posix_signal_desc *psd = xseg_get_signal_desc(xseg, port);
if (!psd)
static int posix_cancel_wait(struct xseg *xseg, uint32_t portno)
{
struct xseg_port *port = xseg_get_port(xseg, portno);
- if (!port)
+ if (!port)
return -1;
struct posix_signal_desc *psd = xseg_get_signal_desc(xseg, port);
if (!psd)
static int posix_signal(struct xseg *xseg, uint32_t portno)
{
struct xseg_port *port = xseg_get_port(xseg, portno);
- if (!port)
+ if (!port)
return -1;
struct posix_signal_desc *psd = xseg_get_signal_desc(xseg, port);
if (!psd)
return -1;
pid_t cue = (pid_t)psd->waitcue;
if (!cue)
- return 0;
+ //HACKY!
+ return -2;
/* FIXME: Make calls to xseg_signal() check for errors */
return syscall(SYS_tkill, cue, SIGIO);
void * posix_alloc_data(struct xseg *xseg)
{
- struct xobject_h *sd_h = xseg_get_objh(xseg, MAGIC_POSIX_SD,
+ struct xobject_h *sd_h = xseg_get_objh(xseg, MAGIC_POSIX_SD,
sizeof(struct posix_signal_desc));
return sd_h;
}
}
timer_stop(prefs, prefs->sub_tm, NULL);
- //Send SIGIO to the process that has binded this port to inform that
+ //Send SIGIO to the process that has bound this port to inform that
//IO is possible
r = xseg_signal(xseg, p);
- if (r == -1)
- XSEGLOG2(&lc, W, "Could not associate destination peer\n");
- else if (r == -2)
- XSEGLOG2(&lc, W, "Could signal destination peer\n");
+ if (r < 0)
+ XSEGLOG2(&lc, W, "Cannot signal destination peer (reason %d)\n", r);
return 0;
send_request:
while (CAN_SEND_REQUEST(prefs)) {
xseg_cancel_wait(xseg, peer->portno_start);
- XSEGLOG2(&lc, D, "Because %lu < %lu && %lu < %lu\n",
+ XSEGLOG2(&lc, D, "...because %lu < %lu && %lu < %lu\n",
prefs->sub_tm->completed - prefs->rec_tm->completed,
prefs->iodepth, prefs->sub_tm->completed,
prefs->max_requests);
}
//Heart of peerd_loop. This loop is common for everyone.
for (loops = threshold; loops > 0; loops--) {
+ if (loops == 1)
+ xseg_prepare_wait(xseg, peer->portno_start);
+
if (check_ports(peer)) {
//If an old request has just been acked, the most sensible
//thing to do is to immediately send a new one
return 0;
}
}
- XSEGLOG2(&lc, I, "%s goes to sleep\n",id);
- xseg_prepare_wait(xseg, peer->portno_start);
+ //struct xseg_port *port = xseg_get_port(xseg, portno_start);
+ //struct xq *q;
+ //q = XPTR_TAKE(port->request_queue, xseg->segment);
+ //XSEGLOG2(&lc, I, "%s goes to sleep with %u requests pending\n",
+ // id, xq_count(q));
+ XSEGLOG2(&lc, I, "%s goes to sleep\n", id);
#ifdef ST_THREADS
if (ta){
st_sleep(0);
{
struct xseg_request *req = pr->req;
uint32_t p;
+ int r;
+
req->state |= XS_SERVED;
//xseg_set_req_data(peer->xseg, pr->req, NULL);
//gettimeofday(&resp_start, NULL);
//timersub(&resp_end, &resp_start, &resp_end);
//timeradd(&resp_end, &resp_accum, &resp_accum);
//printf("xseg_signal: %u\n", p);
- xseg_signal(peer->xseg, p);
+ r = xseg_signal(peer->xseg, p);
+ if (r < 0)
+ XSEGLOG2(&lc, W, "Cannot signal destination peer (reason %d)\n", r);
free_peer_req(peer, pr);
#ifdef MT
wake_up_next_thread(peer);
#endif
//Heart of peerd_loop. This loop is common for everyone.
for(loops = threshold; loops > 0; loops--) {
+ if (loops == 1)
+ xseg_prepare_wait(xseg, peer->portno_start);
if (check_ports(peer))
loops = threshold;
}
- xseg_prepare_wait(xseg, peer->portno_start);
#ifdef ST_THREADS
if (ta){
st_sleep(0);