Esempio n. 1
0
File: devsrv.c Progetto: 8l/inferno
static void
srvcancelreqs(SrvFile *sf)
{
	Pending *w, *ws;
	Sys_Rread rreply;
	Sys_Rwrite wreply;

	acquire();
	ws = &sf->waitlist;
	while((w = ws->next) != ws){
		delwaiting(w);
		if(waserror() == 0){
			if(w->rc != nil){
				rreply.t0 = H;
				rreply.t1 = c2string(Ehungup, strlen(Ehungup));
				csend(w->rc, &rreply);
			}
			if(w->wc != nil){
				wreply.t0 = 0;
				wreply.t1 = c2string(Ehungup, strlen(Ehungup));
				csend(w->wc, &wreply);
			}
			poperror();
		}
	}
	release();
}
Esempio n. 2
0
int md_wrap_write(void *buf, int bytes, int dest, int type, int *flag)

/*******************************************************************************

  Machine dependent wrapped message-sending communication routine for the
  Intel.  This routine is exactly the same as md_write.

  Author:          Scott A. Hutchinson, SNL, 9221
  =======

  Return code:     int
  ============

  Parameter list:
  ===============

  buf:             Beginning address of data to be sent.

  bytes:           Length of message in bytes.

  dest:            Destination processor number.

  type:            Message type

  flag:

*******************************************************************************/

{

  int  Me;
  long lflag;

  Me    = mynode();
  lflag = type * CUBESIZ + Me;

  /* dest=0xffff broadcasts to the current process on all of the nodes. */

  if (dest == 0xffff)
    csend(lflag, buf,(long) bytes, -1L, 0L); /* to everyone */
  else
    csend(type, buf, (long) bytes, (long) dest, 0L);

  return 0;

} /* md_wrap_write */
Esempio n. 3
0
void unreduce (double *x, int n)
{
  int nprocs = numnodes(),
      pid    = mynode(),
      k;

  ROOTONLY
    for (k = 1; k < nprocs; k++)
      csend (MSGTAG + k, x, n*sizeof(double), k, 0);
  else
Esempio n. 4
0
// careful here, any csend might clear player[n]!
void pflush(void)
{
	int n,ilen,olen,csize,ret,olow,ohigh;
	unsigned char obuf[OBUFSIZE];
	unsigned long long prof;
	
	for (n=1; n<MAXPLAYER; n++) {
		if (!player[n]) continue;
	
		ilen=player[n]->tptr;

		if (ilen>16) {
			player[n]->zs.next_in=player[n]->tbuf;
			player[n]->zs.avail_in=ilen;
	
			player[n]->zs.next_out=obuf;
			player[n]->zs.avail_out=OBUFSIZE;

                        prof=prof_start(12); ret=deflate(&player[n]->zs,Z_SYNC_FLUSH); prof_stop(12,prof);
			if (ret!=Z_OK) {
				elog("compression failure #1, kicking player %d",n);
				kick_player(n,NULL);
				continue;
			}
	
			if (player[n]->zs.avail_in) {
				elog("compression failure #2, kicking player %d",n);
				kick_player(n,NULL);
				continue;
			 }
	
			csize=OBUFSIZE-player[n]->zs.avail_out;
	
			olen=(csize);
			
			if (olen>63) {			
				ohigh=(olen>>8)|0x80;
				olow=olen&255;
	
				csend(n,(void*)(&ohigh),1);
				csend(n,(void*)(&olow),1);
			} else {
Esempio n. 5
0
int md_write(char *buf, int bytes, int dest, int type, int *flag)

{
  /*
    extern int Me;
     */
  int  Me;
  long lflag;

  Me    = mynode();
  lflag = type * CUBESIZ + Me;

  /* dest=0xffff broadcasts to the current process on all of the nodes. */

  if (dest == 0xffff)
    csend(lflag, buf,(long) bytes, -1L, 0L); /* to everyone */
  else
    csend(type, buf, (long) bytes, (long) dest, 0L);

  return 0;

} /* md_write */
Esempio n. 6
0
void
CQuit (char *text)
{
  static int      n;
  if (quited)
    return;
  quited = 1;
  PUTHEAD (SQUIT);
  strcpy ((char *) (buffer + HEADSIZE), text);
  printf ("Terminating game.\nReason:%s\n", text);
  for (n = 0; n < 5; n++)
    {				/*repeat quiting messages to make sure that
				   all clients received it */
      csend (buffer, strlen (text) + HEADSIZE + 1);
      csendbuffer ();
    }
  SocketClose (sock);
  quited = 1;
  /*exit(0); */
  uninitialize ();
  exit (0);
}
Esempio n. 7
0
File: devsrv.c Progetto: 8l/inferno
static long
srvwrite(Chan *c, void *va, long count, vlong offset)
{
	long l;
	Heap * volatile h;
	SrvFile *sp;
	Channel *wc;
	Channel *wr;
	Pending wait;
	Sys_Rwrite * volatile w;
	Sys_FileIO_write req;

	if(c->qid.type & QTDIR)
		error(Eperm);

	acquire();
	if(waserror()){
		release();
		nexterror();
	}

	sp = c->aux;
	wr = sp->write;
	if(wr == H)
		error(Ehungup);

	wc = cnewc(dev.Rwrite, movtmp, 1);
	ptradd(D2H(wc));
	if(waserror()){
		ptrdel(D2H(wc));
		destroy(wc);
		nexterror();
	}

	req.t0 = offset;
	req.t1 = mem2array(va, count);
	req.t2 = c->fid;
	req.t3 = wc;

	ptradd(D2H(req.t1));

	if(waserror()){
		ptrdel(D2H(req.t1));
		destroy(req.t1);
		nexterror();
	}

	csend(wr, &req);

	poperror();
	ptrdel(D2H(req.t1));
	destroy(req.t1);

	h = heap(dev.Rwrite);
	w = H2D(Sys_Rwrite *, h);
	ptradd(h);

	if(waserror()){
		ptrdel(h);
		destroy(w);
		nexterror();
	}

	wait.fid = c->fid;
	wait.rc = nil;
	wait.wc = wc;
	addwaiting(sp, &wait);
	if(waserror()){
		delwaiting(&wait);
		nexterror();
	}
	crecv(wc, w);
	poperror();
	delwaiting(&wait);

	if(w->t1 != H)
		error(string2c(w->t1));
	poperror();
	ptrdel(h);
	l = w->t0;
	destroy(w);

	poperror();
	ptrdel(D2H(wc));
	destroy(wc);

	poperror();
	release();
	if(l < 0)
		l = 0;
	return l;
}
Esempio n. 8
0
File: devsrv.c Progetto: 8l/inferno
static long
srvread(Chan *c, void *va, long count, vlong offset)
{
	int l;
	Heap * volatile h;
	Array *a;
	SrvFile *sp;
	Channel *rc;
	Channel *rd;
	Pending wait;
	Sys_Rread * volatile r;
	Sys_FileIO_read req;

	if(c->qid.type & QTDIR){
		qlock(&dev.l);
		if(waserror()){
			qunlock(&dev.l);
			nexterror();
		}
		l = devdirread(c, va, count, 0, 0, srvgen);
		poperror();
		qunlock(&dev.l);
		return l;
	}

	sp = c->aux;

	acquire();
	if(waserror()){
		release();
		nexterror();
	}

	rd = sp->read;
	if(rd == H)
		error(Ehungup);

	rc = cnewc(dev.Rread, movtmp, 1);
	ptradd(D2H(rc));
	if(waserror()){
		ptrdel(D2H(rc));
		destroy(rc);
		nexterror();
	}

	req.t0 = offset;
	req.t1 = count;
	req.t2 = c->fid;
	req.t3 = rc;
	csend(rd, &req);

	h = heap(dev.Rread);
	r = H2D(Sys_Rread *, h);
	ptradd(h);
	if(waserror()){
		ptrdel(h);
		destroy(r);
		nexterror();
	}

	wait.fid = c->fid;
	wait.rc = rc;
	wait.wc = nil;
	addwaiting(sp, &wait);
	if(waserror()){
		delwaiting(&wait);
		nexterror();
	}
	crecv(rc, r);
	poperror();
	delwaiting(&wait);

	if(r->t1 != H)
		error(string2c(r->t1));

	a = r->t0;
	l = 0;
	if(a != H){
		l = a->len;
		if(l > count)
			l = count;
		memmove(va, a->data, l);
	}

	poperror();
	ptrdel(h);
	destroy(r);

	poperror();
	ptrdel(D2H(rc));
	destroy(rc);

	poperror();
	release();

	return l;
}