示例#1
0
uint4 cmj_iostart(struct CLB *lnk, uint4 operation, unsigned int state)
{
	uint4 status;
	error_def(CMI_DCNINPROG);
	error_def(CMI_LNKNOTIDLE);
	void cmj_ast();

	if (lnk->sta != CM_CLB_IDLE)
		return (lnk->sta == CM_CLB_DISCONNECT) ? CMI_DCNINPROG : CMI_LNKNOTIDLE;
        lnk->sta = (unsigned char)state;
	if (lnk->ast)
	{
                status = sys$qio(EFN$C_ENF, lnk->dch, operation,
			&lnk->ios, cmj_ast, lnk,
			lnk->mbf, lnk->cbl, 0, 0, 0, 0);
	} else
	{
                status = sys$qio(EFN$C_ENF, lnk->dch, operation,
			&lnk->ios, 0, 0, lnk->mbf, lnk->cbl, 0, 0, 0, 0);
		if (1 & status)
		{
			status = sys$synch(EFN$C_ENF, &lnk->ios);
			cmj_fini(lnk);
			if (1 & status)
				status = lnk->ios.status;
		}
	}
	return status;
}
示例#2
0
文件: xedrv.c 项目: Rick33/freevms
XE_StartIO ( struct XE_Interface_Structure * XE_Int)
    {
      signed long I,
      RC;
    struct XERCV_QB_structure * Buff;
	struct xe_arp_structure * ARbuf;
      struct XERCV_structure * rcvhdrs = XE_Int->XEI$rcvhdrs ;
      short XE_chan = XE_Int->xei$io_chan;
	short XAR_chan = XE_Int->xei$arp_io_chan;

// Supply four receive buffers to device controller

    DRV$OPR_FAO ("XEDRV: MPBS = !SL",DRV$MAX_PHYSICAL_BUFSIZE);

    XE_Int->XEI$curhdr = 0;
    for (I=0;I<=(MAX_RCV_BUF-1);I++)
	{	// Get buffer, put on Q and issue IO$_READVBLK function
	Buff = drv$seg_get(DRV$MAX_PHYSICAL_BUFSIZE+(Qhead_len+IOS_len));
	INSQUE ( Buff , XE_Int-> XEI$recv_Qtail  );
	Buff = Buff + XE_hdr_offset;
	RC = sys$qio(ASTEFN,XE_chan,IO$_READVBLK,&Buff->XERCV$vms_code,
		     XE_receive,  XE_Int,
		  &Buff->XERCV$data,
		  DRV$MAX_PHYSICAL_BUFSIZE,
		     0, 0,
		     rcvhdrs[I].XERCV$buf,0);
	if (RC != SS$_NORMAL)
	    {     // Error issuing set receive buffer command
	    XE$ERR(XE_Int,"XE queue read request failure, RC=!XL",RC);
	    return 0;
	    }
	};

// get ARP buffer and issue a receive qio

    ARbuf = drv$seg_get(XE_ARP_LEN);
    XE_Int-> xei$arp_buffer  = ARbuf;
    RC = sys$qio(	ARPEFN, XE_Int-> xei$arp_io_chan ,
		IO$_READVBLK,
		&ARbuf -> ar_ios0 ,
			xe_arprcv, XE_Int,
			ARbuf->ar_data, ARP_MAX_LEN, 0, 0,
			ARbuf->phys$1, 0);
    if (RC != SS$_NORMAL)
	{
	XE$ERR(XE_Int,"XE ARP queued read failure, RC=!XL",RC);
	return 0;
	};

// Indicate that I/O has been started

    XE_Int->XEI$IO_queued = TRUE;
    return -1;
    }
示例#3
0
文件: abc.c 项目: JamesLinus/vsta
/*
 * age_buf()
 *	Find the next available buf header, flush and free it
 *
 * Since this is basically a paging algorithm, it can become arbitrarily
 * complex.  The algorithm here tries to be simple, yet somewhat fair.
 */
static void
age_buf(void)
{
	struct llist *l;
	struct buf *b;

	/*
	 * Pick the oldest buf which isn't locked.
	 */
	for (l = allbufs.l_back; l != &allbufs; l = l->l_back) {
		/*
		 * Only skip if wired or active
		 */
		b = l->l_data;
		if (b->b_locks || BUSY(b)) {
			continue;
		}

		ASSERT_DEBUG(b->b_lock == 0, "age_buf: lock");
		if (!(b->b_flags & B_DIRTY)) {
			/*
			 * Remove from list, update data structures
			 */
			free_buf(b);
			return;
		}

		/*
		 * Sync out data in background
		 */
		qio(b, Q_FLUSHBUF);
	}
	ASSERT_DEBUG(bufsize <= coresec, "age_buf: buffers too large");
}
示例#4
0
/*
**++
**  ROUTINE:	netlib_connect
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_connect (struct CTX **xctx, struct SINDEF *sa,
    	    	    	    	 unsigned int *salen,
    	    	    	    	 struct NETLIBIOSBDEF *iosb,
    	    	    	    	 void (*astadr)(), void *astprm) {
    struct CTX *ctx;
    unsigned int status;
    ITMLST2 sname;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (sa == 0 || salen == 0) return SS$_BADPARAM;
    if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;

    ITMLST2_INIT(sname, 0, *salen, sa);

    if (argc > 4 && astadr != 0) {  
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACCESS, &ior->iosb,
    	    	    	    io_completion, ior, 0, 0, &sname, 0, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACCESS, &myiosb,
    	    	    	    0, 0, 0, 0, &sname, 0, 0, 0);
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    }

    return status;

} /* netlib_connect */
示例#5
0
/*
**++
**  ROUTINE:	netlib_shutdown
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_shutdown (struct CTX **xctx, unsigned int *shuttype,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    unsigned int status;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc > 3 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 4) ? astprm : 0);
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_DEACCESS|IO$M_SHUTDOWN,
    	    	    	    &ior->iosb, io_completion, ior, 0, 0, 0, 
    	    	    	    (shuttype == 0) ? 0 : *shuttype, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	status = sys$qiow(netlib_synch_efn, ctx->chan,
    	    	    	    IO$_DEACCESS|IO$M_SHUTDOWN, &myiosb,
    	    	    	    0, 0, 0, 0, 0,
    	    	    	    (argc > 1 && shuttype != 0) ? *shuttype : 0, 0, 0);
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 2 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    }

    return status;

} /* netlib_shutdown */
示例#6
0
void ccp_exitwm1( ccp_db_header	*db)
{
	sgmnt_addrs	*cs_addrs;
	uint4	status;


	assert(lib$ast_in_prog());

	if ((db->qio_iosb.cond & 1) == 0)
		ccp_signal_cont(db->qio_iosb.cond);	/***** Is this reasonable? *****/

	cs_addrs = db->segment;
	if (db->last_lk_sequence < cs_addrs->ti->lock_sequence)
	{
		status = sys$qio(0, FILE_INFO(db->greg)->fab->fab$l_stv, IO$_WRITEVBLK, &db->qio_iosb, ccp_exitwm1a, db,
				 cs_addrs->lock_addrs[0], db->glob_sec->lock_space_size, LOCK_BLOCK(db->glob_sec) + 1, 0, 0, 0);
		if ((status & 1) == 0)
			ccp_signal_cont(status);	/***** Is this reasonable? *****/
		db->last_lk_sequence = cs_addrs->ti->lock_sequence;
	}
	else
		ccp_exitwm2(db);

	return;
}
示例#7
0
/*
**++
**  ROUTINE:	netlib_listen
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_listen (struct CTX **xctx, unsigned int *backlog,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    unsigned int status;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc > 3 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SETMODE, &ior->iosb,
    	    	    	    io_completion, ior, 0, 0, 0, 
    	    	    	    (backlog == 0) ? 4 : *backlog, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, &myiosb,
    	    	    	    0, 0, 0, 0, 0,
    	    	    	    (argc > 1 && backlog != 0) ? *backlog : 4, 0, 0);
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 2 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    }

    return status;

} /* netlib_listen */
示例#8
0
文件: qio1.c 项目: Rick33/freevms
main(){
struct _iosb myiosb;
int status;
unsigned short int chan;
char mybuf[512];
int efn=0;
$DESCRIPTOR(null,"NLA0");

status=sys$assign(&null,&chan,0,0,0);

printf("status %x chan %x \n", status,chan);

printf("before qio %x\n",time(0));
status=sys$qio(0,chan,IO$_READVBLK,0,myast,0,mybuf,512,0,0,0,0);
printf("after qio %x\n",time(0));

sleep(2);
sleep(2);
sleep(2);
sleep(2);

printf("status %x done %x \n", status,done);

printf("before qiow %x\n",time(0));
status=sys$qiow(efn,chan,IO$_READVBLK,0,myast,0,mybuf,512,0,0,0,0);
printf("after qiow %x\n",time(0));

printf("status %x done %x \n", status,done);

}
示例#9
0
文件: abc.c 项目: JamesLinus/vsta
/*
 * sync()
 *	Write dirty buffers to disk
 *
 * If handle is not NULL, sync all buffers dirtied with this handle.
 * Otherwise sync all dirty buffers.
 */
void
sync_bufs(void *handle)
{
	struct llist *l;
	uint x;

	for (l = LL_NEXT(&allbufs); l != &allbufs; l = LL_NEXT(l)) {
		struct buf *b = l->l_data;

		/*
		 * Not dirty--easy
		 */
		if (!(b->b_flags & B_DIRTY)) {
			continue;
		}

		/*
		 * Interlock
		 */
		get(b);

		/*
		 * Not dirty after interlock--still easy
		 */
		if (!(b->b_flags & B_DIRTY)) {
			continue;
		}

		/* 
		 * No handle, just sync dirty buffers
		 */
		if (!handle) {
			qio(b, Q_FLUSHBUF);
			continue;
		}

		/*
		 * Check for match.
		 */
		for (x = 0; x < b->b_nhandle; ++x) {
			if (b->b_handles[x] == handle) {
				qio(b, Q_FLUSHBUF);
				break;
			}
		}
	}
}
int cmj_mbx_read_start(struct NTD *tsk)
{
        void cmj_mbx_ast();
	int status;

        status = sys$qio(efn_ignore, tsk->mch, IO$_READVBLK, &(tsk->mst),
		&cmj_mbx_ast, tsk, tsk->mbx.dsc$a_pointer, tsk->mbx.dsc$w_length, 0, 0, 0, 0);
	return status;
}
示例#11
0
do_mbx_read() {
  int status;
  status = sys$qio (0, (int) mailbox_channel, IO$_READVBLK, &iosb, mbx_read_ast, 0, mbx_buffer, 256, 0, 0, 0, 0);
#if 0
  if ((status&1)==0) signal(status);
#endif

  return SS$_NORMAL;
}
示例#12
0
/*
**++
**  ROUTINE:	netlib_write
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_write (struct CTX **xctx, struct dsc$descriptor *dsc,
    	    	    	    struct SINDEF *sa, unsigned int *salen,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {
    struct CTX *ctx;
    void *bufptr;
    unsigned int status;
    unsigned short buflen;
    ITMLST2 sname, *snaddr;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    status = lib$analyze_sdesc(dsc, &buflen, &bufptr);
    if (!OK(status)) return status;

    if (argc > 3 && salen != 0) {
    	ITMLST2_INIT(sname, 0, *salen, sa);
    	snaddr = &sname;
    } else snaddr = 0;

    if (argc > 5 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);
    	if (buflen == 0) {
    	    ior->iosb.iosb_w_status = SS$_NORMAL;
    	    ior->iosb.iosb_w_count = 0;
    	    ior->iosb.iosb_l_unused = 0;
    	    status = sys$dclast(io_completion, ior, 0);
    	} else {
    	    status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_WRITEVBLK,
    	    	    	    &ior->iosb,
    	    	    	    io_completion, ior, bufptr, buflen, snaddr,
    	    	    	    0, 0, 0);
    	    if (!OK(status)) FREE_IOR(ior);
    	}
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	if (buflen == 0) {
    	    status = myiosb.iosb_w_status = SS$_NORMAL;
    	    myiosb.iosb_w_count = 0;
    	    myiosb.iosb_l_unused = 0;
    	} else {
    	    status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_WRITEVBLK,
    	    	    	    &myiosb, 0, 0, bufptr, buflen, snaddr,
    	    	    	    0, 0, 0);
    	    if (OK(status)) status = netlib___cvt_status(&myiosb);
    	}
    	if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    }

    return status;

} /* netlib_write */
示例#13
0
/*
**++
**  ROUTINE:	netlib_getsockopt
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_getsockopt (struct CTX **xctx,
    	    	    	    unsigned int *level, unsigned int *option,
    	    	    	    void *value, unsigned int *valsize,
    	    	    	    unsigned int *vallen,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    unsigned int status, lev;
    ITMLST2 optdsc;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 5) return SS$_INSFARG;
    if (option == 0 || value == 0 || valsize == 0) return SS$_BADPARAM;
    if (level == 0) lev = NETLIB_K_LEVEL_SOCKET;
    else lev = *level;


    if (argc > 7 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);
    	ITMLST_INIT(ior->specior.sockopt_get, *option, *valsize,
    	    	    	value, &ior->spec_length);
    	ITMLST2_INIT(optdsc,
    	    (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,
    	    sizeof(ior->specior.sockopt_get), &ior->specior.sockopt_get);
    	ior->spec_retlen = vallen;
    	ior->iorflags = IOR_M_COPY_LENGTH;
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SENSEMODE, &ior->iosb,
    	    	    	    io_completion, ior, 0, 0, 0, 0, 0, &optdsc);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	ITMLST sockopt_get;
    	struct NETLIBIOSBDEF myiosb;
    	unsigned short length;

    	ITMLST_INIT(sockopt_get, *option, *valsize, value, &length);
    	ITMLST2_INIT(optdsc,
    	    (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,
    	    sizeof(sockopt_get), &sockopt_get);
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SENSEMODE,
    	    	    	    &myiosb, 0, 0, 0, 0, 0, 0, 0, &optdsc);
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    	if (OK(status) && argc > 5 && vallen != 0) *vallen = length;
    }

    return status;

} /* netlib_getsockopt */
示例#14
0
/*
**++
**  ROUTINE:	netlib_setsockopt
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_setsockopt (struct CTX **xctx,
    	    	    	    unsigned int *level, unsigned int *option,
    	    	    	    void *value, unsigned int *vallen,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    unsigned int status, lev;
    ITMLST2 optdsc;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 5) return SS$_INSFARG;
    if (option == 0 || value == 0 || vallen == 0) return SS$_BADPARAM;
    if (level == 0) lev = NETLIB_K_LEVEL_SOCKET;
    else lev = *level;

    if (lev == NETLIB_K_LEVEL_SOCKET && *option == NETLIB_K_OPTION_REUSEADDR) {
    	ctx->flags |= CTX_M_USER_SET_REUSEADDR;
    }

    if (argc > 6 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);
    	ITMLST2_INIT(ior->specior.sockopt, *option, *vallen, value);
    	ITMLST2_INIT(optdsc,
    	    (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,
    	    sizeof(ior->specior.sockopt), &ior->specior.sockopt);
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SETMODE, &ior->iosb,
    	    	    	    io_completion, ior, 0, 0, 0, 0, &optdsc, 0);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	ITMLST2 sockopt;
    	ITMLST2_INIT(sockopt, *option, *vallen, value);
    	ITMLST2_INIT(optdsc,
    	    (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,
    	    sizeof(sockopt), &sockopt);
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE,
    	    	    	    &myiosb, 0, 0, 0, 0, 0, 0, &optdsc, 0);
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    }

    return status;

} /* netlib_setsockopt */
示例#15
0
文件: sp_mgr.c 项目: SysMan-One/mmk
/*
**++
**  ROUTINE:	try_to_send
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Tries to send some data to the subprocess, if it is
**  possible to do so.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	try_to_send(SPHANDLE ctx)     (at AST level)
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**  	SS$_NORMAL: 	normal successful completion
**
**  SIDE EFFECTS:   	None.
**
**--
*/
static unsigned int try_to_send (SPHANDLE ctx) {

    struct SPD *spd;
    unsigned int status;

/*
**  Only send something if it's OK (i.e., READATTN AST has fired)
*/
    if (ctx->ok_to_send) {
/*
**  Anything to send?  If so, send it and set up the READATTN AST again.
*/
    	if (queue_remove(ctx->sendque.head, &spd)) {
    	    ctx->ok_to_send = 0;
    	    sys$qio(ctx->inefn, ctx->inchn, IO$_WRITEVBLK, spd->iosb,
    	    	send_completion, spd, spd->buf, spd->len, 0, 0, 0, 0);
    	    sys$qio(0, ctx->inchn, IO$_SETMODE|IO$M_READATTN, 0, 0, 0,
    	    	sp_readattn_ast, ctx, 0, 0, 0, 0);
    	}
    }

    return SS$_NORMAL;

} /* try_to_send */
void ccp_tr_opendb1a( ccp_action_record	*rec)
{
	ccp_db_header	*db;
	uint4	status;


	db = ccp_get_reg_by_fab(rec->v.fab);
	db->segment->hdr = malloc(SIZEOF(sgmnt_data));

	status = sys$qio(0, rec->v.fab->fab$l_stv, IO$_READVBLK, &db->qio_iosb, ccp_opendb1, db,
			 db->segment->hdr, SIZEOF(sgmnt_data), 1, 0, 0, 0);
	if ((status & 1) == 0)
		ccp_signal_cont(status);	/***** Is this reasonable? *****/

	return;
}
示例#17
0
/*
**++
**  ROUTINE:	netlib_bind
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_bind (struct CTX **xctx, struct SINDEF *sa,
    	    	    	    unsigned int *salen, struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    unsigned int status;
    ITMLST2 sockdsc;
    int argc;
    static unsigned int one = 1;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 3) return SS$_INSFARG;
    if (sa == 0 || salen == 0) return SS$_BADPARAM;
    if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;

    if (!(ctx->flags & CTX_M_USER_SET_REUSEADDR)) {
    	ITMLST2 rulst, sockopt;
    	ITMLST2_INIT(rulst, UCX$C_SOCKOPT, sizeof(sockopt), &sockopt);
    	ITMLST2_INIT(sockopt, NETLIB_K_OPTION_REUSEADDR, sizeof(one), &one);
    	sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, 0, 0, 0,
    	    	    0, 0, 0, 0, &rulst, 0);
    }

    ITMLST2_INIT(sockdsc, 0, *salen, sa);

    if (argc > 4 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SETMODE, &ior->iosb,
    	    	    	    io_completion, ior, 0, 0, &sockdsc, 0, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, &myiosb,
    	    	    	    0, 0, 0, 0, &sockdsc, 0, 0, 0);
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    }

    return status;

} /* netlib_bind */
示例#18
0
/*
** Name: cpres_q_read_io	- queue a read I/O on our CP mailbox
**
** Description:
**	This subroutine queues an I/O on this process's CPRES mailbox.
**
** Inputs:
**	None
**
** Outputs:
**	None
**
** Returns:
**	void
**
** History:
**	Summer, 1992 (bryanp)
**	    Working on the new portable logging and locking system.
**	18-oct-1993 (rachael)
**	    Call lib$signal(SS$_DEBUG) only when compiled with xDEBUG flag.
**	    Modified TRdisplay statement to reflect calling function.
**	04-Apr-2008 (jonj)
**	    Use EFN to assure thread-safeness rather than defaulting
**	    to EFN zero.
*/
static void
cpres_q_read_io(void)
{
    i4			vms_status;

    vms_status = sys$qio(EFN$C_ENF, cpres_mbx_chan, IO$_READVBLK, &cpres_iosb,
	    cpres_mbx_read_complete, (__int64)&cpres_iosb, &cpres_msg_buffer,
	    sizeof(CS_CP_WAKEUP_MSG), 0, 0, 0, 0);

    if ( vms_status != SS$_NORMAL )
    {
	TRdisplay("cpres_q_read_io QIO failed, status %x\n", vms_status);
#ifdef xDEBUG
	lib$signal(SS$_DEBUG);
#endif
	PCexit(FAIL);
    }
    return;
}
示例#19
0
/*
**++
**  ROUTINE:	netlib_getpeername
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_getpeername (struct CTX **xctx, struct SINDEF *sa,
    	    	    	    	 unsigned int *sasize, unsigned int *salen,
    	    	    	    	 struct NETLIBIOSBDEF *iosb,
    	    	    	    	 void (*astadr)(), void *astprm) {
    struct CTX *ctx;
    ITMLST slst;
    unsigned int status;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 3) return SS$_INSFARG;
    if (sa == 0 || sasize == 0) return SS$_BADPARAM;

    if (argc > 5 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);
    	ITMLST_INIT(slst, 0, *sasize, sa, &ior->spec_length);
    	ior->spec_length = *sasize;
    	ior->spec_retlen = salen;
    	ior->iorflags = IOR_M_COPY_LENGTH;
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SENSEMODE, &ior->iosb,
    	    	    	    io_completion, ior, 0, 0, 0, &slst, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	unsigned short length;
    	ITMLST_INIT(slst, 0, *sasize, sa, &length);
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SENSEMODE,
    	    	    	    &myiosb, 0, 0, 0, 0, 0, &slst, 0, 0);
    	if (argc > 3 && salen != 0) *salen = length;
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    }

    return status;

} /* netlib_getpeername */
示例#20
0
void	ccp_tr_opendb3(ccp_action_record *rec)
{
	ccp_db_header		*db;
	sgmnt_addrs		*csa;
	sgmnt_data		*csd;
	jnl_private_control	*jpc;
	uint4		status;


	db = rec->v.h;
	db->master_map_start_tn = 0;

	csa = db->segment;
	csd = db->glob_sec
	    = csa->hdr
	    = csa->db_addrs[0];

	adawi(1, &csa->nl->ref_cnt);	/* GT.M process that sent open request */
	csa->lock_addrs[0] = (unsigned char *)csd + (LOCK_BLOCK(csd) * DISK_BLOCK_SIZE);
	csa->lock_addrs[1] = csa->lock_addrs[0] + csd->lock_space_size;

	if (JNL_ENABLED(csd))
	{
		jpc = csa->jnl
		    = malloc(SIZEOF(jnl_private_control));
		memset(jpc, 0, SIZEOF(jnl_private_control));

		jpc->region = db->greg;
		jpc->jnl_buff = csa->lock_addrs[1] + CACHE_CONTROL_SIZE(csd) + JNL_NAME_EXP_SIZE;

		FILE_INFO(db->greg)->s_addrs.jnl->jnllsb->lockid = 0;

		if (db->wm_iosb.valblk[CCP_VALBLK_JNL_ADDR] == 0)
		{
			/* Open jnl file based on data in file header, first machine to open */
			jnl_file_open(db->greg, FALSE, ccp_closejnl_ast);
			if (jpc->channel == 0)
			{
				/* Open failed */
				ccp_close1(db);
				ccp_signal_cont(ERR_CCPJNLOPNERR);	/***** Is this reasonable? *****/
				return;
			}

			/* Write out file id for other machines */
			csd->trans_hist.ccp_jnl_filesize = jpc->jnl_buff->filesize;
			csd->ccp_jnl_before = jpc->jnl_buff->before_images;

			status = sys$qio(0, FILE_INFO(db->greg)->fab->fab$l_stv, IO$_WRITEVBLK, &db->qio_iosb, ccp_opendb3a, db,
					 csd, (MM_BLOCK - 1) * OS_PAGELET_SIZE, 1, 0, 0, 0);
		}
		else
		{
/* ??? --> */		/* Open jnl file based on id in header.  Read in header to make sure get file id from first machine */

			status = sys$qio(0, FILE_INFO(db->greg)->fab->fab$l_stv, IO$_READVBLK, &db->qio_iosb, ccp_opendb3a, db,
					 csd, (MM_BLOCK - 1) * OS_PAGELET_SIZE, 1, 0, 0, 0);
		}

		if (status != SS$_NORMAL)
		{
			ccp_signal_cont(status);	/***** Is this reasonable? *****/
			ccp_close1(db);
		}
	}
	else
		ccp_opendb3b(db);

}
示例#21
0
void NamedEventImpl::setImpl()
{
	char buffer = 0xFF;
	if (sys$qio(0, _mbxChan, IO$_WRITEVBLK, 0, 0, 0, &buffer, sizeof(buffer), 0, 0, 0, 0) != 1)
		throw SystemException("cannot set named event", _name);
}
示例#22
0
void ccp_reqwm_interrupt(ccp_db_header **pdb)
{
	ccp_db_header	*db;
	sgmnt_addrs	*csa;
	uint4	status;


	assert(lib$ast_in_prog());

	db = *pdb;

	csa = db->segment;
	if (csa == NULL  ||  csa->nl->ccp_state == CCST_CLOSED)
		return;

	switch (db->wm_iosb.cond)
	{
	case SS$_DEADLOCK:
		ccp_signal_cont(SS$_DEADLOCK);
		/* Just try again */
		ccp_request_write_mode(db);
		return;

	case SS$_CANCEL:
		/* Lock cancelled by close */
		return;

	case SS$_VALNOTVALID:
		/* Force reads from disk */
		db->wm_iosb.valblk[CCP_VALBLK_TRANS_HIST] = 0;
		db->last_lk_sequence = db->master_map_start_tn
				     = 0;
		/* Drop through ... */

	case SS$_NORMAL:
		if (db->wm_iosb.valblk[CCP_VALBLK_TRANS_HIST] == csa->ti->curr_tn + csa->ti->lock_sequence)
		{
			/* No change to current tn, do not need to update header */
			if (csa->now_crit)
			{
				assert (csa->nl->in_crit == process_id);
				csa->nl->in_crit = 0;
				(void)mutex_unlockw(csa->critical, csa->critical->crashcnt, &csa->now_crit);
				/***** Check error status here? *****/
			}
			ccp_writedb5(db);
		}
		else
		{
			if (csa->nl->in_crit == 0)
			{
				if (mutex_lockwim(csa->critical, csa->critical->crashcnt, &csa->now_crit) == cdb_sc_normal)
					csa->nl->in_crit = process_id;		/* now_crit was set by mutex_lockwim */
				else
					if (csa->nl->in_crit == 0)		/***** Why is this re-tested? *****/
					{
						status = sys$setimr(0, delta_100_msec, ccp_reqwm_interrupt, &db->wmcrit_timer_id,
								    0);
						if (status != SS$_NORMAL)
							ccp_signal_cont(status);	/***** Is this reasonable? *****/
						return;
					}
			}
			status = sys$qio(0, FILE_INFO(db->greg)->fab->fab$l_stv, IO$_READVBLK, &db->qio_iosb, ccp_writedb2, db,
					 &db->glob_sec->trans_hist, BT_SIZE(csa->hdr) + SIZEOF(th_index), TH_BLOCK, 0, 0, 0);
			if (status != SS$_NORMAL)
				ccp_signal_cont(status);	/***** Is this reasonable? *****/
		}
		return;

	default:
		ccp_signal_cont(db->wm_iosb.cond);		/***** Is this reasonable? *****/
		return;
	}
}
示例#23
0
void cmj_mbx_ast(struct NTD *tsk)
{
	struct CLB *cmu_makclb();
	struct dsc$descriptor_s ncb_desc;
	uint4 status, unit;
	cm_mbx *mp;
	struct CLB *lnk;
	bool newclb;
	void cmj_ast();

	status = 0;
	mp = tsk->mbx.dsc$a_pointer;
	assert(mp->netnum == 3 && mp->netnam[0] == 'N' && mp->netnam[1] == 'E' && mp->netnam[2] == 'T');
	switch(mp->msg)
	{
	case MSG$_CONNECT:
		lnk = cmj_unit2clb(tsk, mp->unit);
		if (lnk == 0)
		{
			newclb = TRUE;
			lnk = cmu_makclb();
			lnk->dch = tsk->dch;
			lnk->ntd = tsk;
		}else
		{
			newclb = FALSE;
			assert(lnk->sta == CM_CLB_IDLE);
		}
		ncb_desc.dsc$w_length = mp->len;
		ncb_desc.dsc$b_dtype = DSC$K_DTYPE_T;
		ncb_desc.dsc$b_class = DSC$K_CLASS_S;
		ncb_desc.dsc$a_pointer = mp->text;
		lnk->mbf = 0;
	/* the statement below and the 3 qio's emulate cmj_iostart which could be used if lnk->clb were a int4 */
		lnk->sta = CM_CLB_WRITE;
		if (tsk->crq == 0)
		{
			lnk->ast = cmj_reject_ast;
                        status = sys$qio(efn_ignore, lnk->dch, IO$_ACCESS | IO$M_ABORT,
				&lnk->ios, cmj_ast, lnk,
				lnk->mbf, &ncb_desc, 0, 0, 0, 0);
		} else
		{	if (tsk->acc && !(*tsk->acc)(lnk))
			{
				lnk->ast = cmj_reject_ast;
                                status = sys$qio(efn_ignore, lnk->dch, IO$_ACCESS | IO$M_ABORT,
					&lnk->ios, cmj_ast, lnk,
					lnk->mbf, &ncb_desc, 0, 0, 0, 0);
			}else
			{
				status = sys$assign(&cm_netname, &lnk->dch, 0, &tsk->mnm);
				if (status & 1)
				{
					status = lib$getdvi(&DVI$_UNIT, &lnk->dch, 0, &unit, 0, 0);
					if (status & 1)
					{
						lnk->mun = (unsigned short)unit;
						lnk->ast = cmj_accept_ast;
                                                status = sys$qio(efn_ignore, lnk->dch, IO$_ACCESS,
							&lnk->ios, cmj_ast, lnk,
							lnk->mbf, &ncb_desc, 0, 0, 0, 0);
					}
				}
			}
		}
		if ((status & 1) == 0)
		{
			if (newclb)
			{
				lib$free_vm(&SIZEOF(*lnk), &lnk, 0);
				lnk = 0;
			}
			cmj_mbx_err(status, tsk, lnk);
			break;
		}
		return;

	case MSG$_INTMSG:
		if (tsk->mbx_ast != 0)
		{	(*tsk->mbx_ast)(tsk);
			break;
		}
	/* CAUTION:  FALLTHROUGH */
	case MSG$_DISCON:
	case MSG$_ABORT:
	case MSG$_EXIT:
	case MSG$_PATHLOST:
	case MSG$_PROTOCOL:
	case MSG$_THIRDPARTY:
	case MSG$_TIMEOUT:
	case MSG$_NETSHUT:
	case MSG$_REJECT:
	case MSG$_CONFIRM:
		if (tsk->err)
		{
			lnk = cmj_unit2clb(tsk, mp->unit);
			(*tsk->err)(tsk, lnk, mp->msg);
		}else
			rts_error(CMI_NETFAIL,0,status);	/* condition handler would need to close the connection */
	/* CAUTION:  FALLTHROUGH */
	default:
		break;
	}

	status = cmj_mbx_read_start(tsk);
	if ((status & 1) == 0)
	{
		lnk = cmj_unit2clb(tsk, mp->unit);
		cmj_mbx_err(status, tsk, lnk);
	}
}
示例#24
0
/*
** Name: CScp_resume	- Resume (a thread in) a process
**
** Description:
**	This routine resumes the indicated thread in the indicated process.
**
**	If the indicated process is this process, then this is a simple
**	CSresume operation. If the indicated process is another process, then
**	that process must be notified that it should CSresume the indicated
**	thread.
**
** Inputs:
**	cpid		pointer to CS_CPID with
**	   .pid		- the indicated process
**	   .sid		- the indicated session
**	   .iosb	- a thread-safe IOSB
**	   .data	- where we'll place a pointer
**			  to the CPchan written to.
**
** Outputs:
**	None
**
** Returns:
**	void
**
** History:
**	Summer, 1992 (bryanp)
**	    Working on the new portable logging and locking system.
**	9-oct-1992 (bryanp)
**	    Use global IOSB, not stack IOSB, so that when QIO completes
**	    some time from now it will not overwrite arbitrary stack stuff.
**	19-oct-1992 (bryanp)
**	    CSresume expects to be called at AST level. Oblige it by invoking it
**	    via sys$dclast().
**	20-oct-1992 (bryanp)
**	    Back out the DCLAST change; CSresume can now be called at normal
**	    level.
**	14-dec-1992 (bryanp)
**	    ERsend() calls should be ERlog() calls.
**	29-sep-1993 (walt)
**	    Get an event flag number from lib$get_ef rather than use event flag
**	    zero in the sys$qio call.  
**	18-oct-1993 (rachael)
**	    Call lib$signal(SS$_DEBUG) only when compiled with xDEBUG flag.
**	16-Nov-1998 (jenjo02)
**	    Prototype changed to pass CS_CPID * instead of PID, SID.
**	08-Nov-2007 (jonj)
**	    Write with IO$M_NOW and IO$M_READERCHECK, check for dead reader
**	    process (NOREADER), mark this PID/channel as dead for subsequent
**	    resumers to ignore. IO$M_NOW does not wait for the reader to
**	    read.
**	04-Apr-2008 (jonj)
**	    Embed IOSB in CS_CPID and reinstate lib$get_ef() to assure
**	    thread-safeness.
**	    Disable/reenable ASTs to prevent seen duplicate reads on the
**	    other end.
**	    Supply cpres_mbx_write_complete() AST to check IOSB status
**	    for NOREADER.
*/
void
CScp_resume( CS_CPID *cpid )
{
    i4		    	vms_status;
    CS_CP_WAKEUP_MSG	wakeup_msg;
    i4		    	mbox_chan;
    char		msg_buf[100];
    CL_ERR_DESC		local_sys_err;
    CP_CHANNEL		*CPchan;
    II_VMS_EF_NUMBER	efn;
    i4			ReenableASTs;

    if (cpid->pid == Cs_srv_block.cs_pid)
    {
	CSresume(cpid->sid);
    }
    else
    {
	/* Disable AST delivery */
	ReenableASTs = (sys$setast(0) == SS$_WASSET);

	/* Initialize to success */
	vms_status = SS$_NORMAL;

	if ( cpres_mbx_assign(cpid->pid, &CPchan) == OK )
	{
	    /* If reader is not alive, do nothing */
	    if ( CPchan->state == CPchanIsAlive )
	    {
		/* The SID of the session to resume */
		wakeup_msg.wakeup_sid = cpid->sid;

		/* horda03 - Fill in details to help track Cross-Process
		**           ACCVIO problem.
		*/
		wakeup_msg.wakeup_pid    = cpid->pid;
		wakeup_msg.from_pid      = Cs_srv_block.cs_pid;

		/* If from AST, "from_sid" is meaningless */
		if ( (wakeup_msg.sender_in_ast = lib$ast_in_prog()) )
		    wakeup_msg.from_sid = 0;
		else
		    wakeup_msg.from_sid = (CS_SID)Cs_srv_block.cs_current;

		/*
		** Plunk message, don't wait for reader to read it.
		**
		** Use IOSB embedded in CS_CPID, pass CS_CPID* to
		** AST completion.
		*/

		/* Set CPchan in the CS_CPID for AST's use */
		cpid->data = (PTR)CPchan;

		vms_status = sys$qio(EFN$C_ENF, CPchan->chan, 
				    IO$_WRITEVBLK | IO$M_NOW | IO$M_READERCHECK,
				    &cpid->iosb,
				    cpres_mbx_write_complete, 
				    cpid, 
				    &wakeup_msg, sizeof(wakeup_msg),
				    0, 0, 0, 0);

		if ( vms_status != SS$_NORMAL )
		{
		    STprintf(msg_buf, "[%x.%x] Error (%x) queueing write to %x on channel %d",
			    wakeup_msg.from_pid,
			    wakeup_msg.from_sid,
			    vms_status, CPchan->pid, CPchan->chan);
		    ERlog(msg_buf, STlength(msg_buf), &local_sys_err);
		}
	    }
	}
	else
	{
	    STprintf(msg_buf, "Unable to assign channel to %x", cpid->pid);
	    ERlog(msg_buf, STlength(msg_buf), &local_sys_err);

	    STprintf(msg_buf, "Ignoring error in assigning mailbox for PID %x", 
			cpid->pid);
	    ERlog(msg_buf, STlength(msg_buf), &local_sys_err);
	    /*
	    ** The process we were going to send this message to will probably
	    ** "hang", which at least allows some sort of diagnosis. Killing
	    ** ourselves at this point is less useful, since it tends to crash
	    ** the entire installation.
	    */
	}
	
	if ( vms_status != SS$_NORMAL )
	{
	    STprintf(msg_buf, "CScp_resume QIO to %x failed with status %x",
		    cpid->pid, vms_status);
	    ERlog(msg_buf, STlength(msg_buf), &local_sys_err);
#ifdef xDEBUG
	    lib$signal(SS$_DEBUG);
#endif
	    PCexit(FAIL);
	}

	if ( ReenableASTs )
	    sys$setast(1);
    }
    return;
}
示例#25
0
文件: abc.c 项目: JamesLinus/vsta
/*
 * find_buf()
 *	Given starting sector #, return pointer to buf
 */
struct buf *
find_buf(daddr_t d, uint nsec, int flags)
{
	struct buf *b;

	ASSERT_DEBUG(nsec > 0, "find_buf: zero");
	ASSERT_DEBUG(nsec <= EXTSIZ, "find_buf: too big");

	/*
	 * If we can find it, this is easy
	 */
	b = hash_lookup(bufpool, d);
	if (b) {
		return(b);
	}

	/*
	 * Get a buf struct
	 */
	b = malloc(sizeof(struct buf));
	if (b == 0) {
		return(0);
	}

	/*
	 * Make room in our buffer cache if needed
	 */
	while ((bufsize+nsec) > coresec) {
		age_buf();
	}

	/*
	 * Get the buffer space
	 */
	b->b_data = malloc(stob(nsec));
	if (b->b_data == 0) {
		free(b);
		return(0);
	}

	/*
	 * Add us to pool, and mark us very new
	 */
	b->b_list = ll_insert(&allbufs, b);
	if (b->b_list == 0) {
		free(b->b_data);
		free(b);
		return(0);
	}
	if (hash_insert(bufpool, d, b)) {
		ll_delete(b->b_list);
		free(b->b_data);
		free(b);
		return(0);
	}

	/*
	 * Fill in the rest & return
	 */
	init_lock(&b->b_lock);
	b->b_start = d;
	b->b_nsec = nsec;
	b->b_locks = 0;
	b->b_handles = 0;
	b->b_nhandle = 0;
	if (flags & ABC_FILL) {
		b->b_flags = 0;
	} else {
		b->b_flags = B_SEC0 | B_SECS;
	}
	bufsize += nsec;

	/*
	 * If ABC_BG, initiate fill now
	 */
	if (flags & ABC_BG) {
		qio(b, Q_FILLBUF);
	}

	return(b);
}
示例#26
0
/*
**++
**  ROUTINE:	netlib_accept
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_accept (struct CTX **xctx, struct CTX **xnewctx,
    	    	    	    struct SINDEF *sa, unsigned int *sasize,
    	    	    	    unsigned int *salen, struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {
    struct CTX *ctx, *newctx;
    ITMLST sname;
    unsigned int status;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 2) return SS$_INSFARG;
    if (xnewctx == 0) return SS$_BADPARAM;
    status = netlib___alloc_ctx(&newctx, SPECCTX_SIZE);
    if (!OK(status)) return status;

    status = sys$assign(&inetdevice_v5, &newctx->chan, 0, 0);
    if (!OK(status)) {
    	status = sys$assign(&inetdevice, &newctx->chan, 0, 0);
    }
    if (!OK(status)) {
    	netlib___free_ctx(newctx);
    	return status;
    }

    if (argc > 6 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);
    	ior->spec_userfrom = (sasize == 0) ? 0 : sa;
    	ior->spec_length = (sasize == 0) ? 0 : *sasize;
    	ior->spec_retlen = salen;
    	ior->spec_xnewctx = xnewctx;
    	ior->spec_newctx = newctx;
    	ITMLST_INIT(sname, 0, sizeof(struct SINDEF),
    	    	&ior->specior.from, &ior->specior.fromlen);
    	ior->iorflags = IOR_M_COPY_FROM|IOR_M_NEW_CONTEXT;
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACCESS|IO$M_ACCEPT,
    	    	    	    &ior->iosb, io_completion, ior,
    	    	    	    0, 0, &sname, &newctx->chan, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    } else {
    	struct SINDEF from;
    	struct NETLIBIOSBDEF myiosb;
    	unsigned short fromlen;

    	ITMLST_INIT(sname, 0, sizeof(struct SINDEF),
    	    	&from, &fromlen);
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACCESS|IO$M_ACCEPT,
    	    	    	    &myiosb, 0, 0, 0, 0,
    	    	    	    &sname, &newctx->chan, 0, 0);
    	if (OK(status)) status = netlib___cvt_status(&myiosb);
    	if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    	if (OK(status)) {
    	    *xnewctx = newctx;
    	    if (argc > 3 && sa != 0 && sasize != 0) {
    	    	unsigned int len;
    	    	len = fromlen;
    	    	if (len > *sasize) len = *sasize;
    	    	memcpy(sa, &from, len);
    	    	if (argc > 4 && salen != 0) *salen = len;
    	    }
    	}
    }

    return status;

} /* netlib_accept */
示例#27
0
/*
**++
**  ROUTINE:	netlib_name_to_address
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Uses the UCX IO$_ACPCONTROL $QIO function to translate a host
**  name into one or more IP addresses.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	NETLIB_NAME_TO_ADDRESS  ctx, which, namdsc, addrlist, listsize [,count] [,iosb] [,astadr] [,astprm]
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_name_to_address (struct CTX **xctx, unsigned int *whichp,
    	    	    	    struct dsc$descriptor *namdsc,
    	    	    	    struct INADDRDEF *addrlist,
    	    	    	    unsigned int *listsize, unsigned int *count,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    struct INADDRDEF addr;
    struct NETLIBIOSBDEF myiosb;
    struct HOSTENT hostent;
    unsigned int status, subfunction;
    ITMLST2 subfdsc;
    ITMLST2 entdsc;
    unsigned short helen;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 5) return SS$_INSFARG;

    if (namdsc == 0 || addrlist == 0 || listsize == 0) return SS$_BADPARAM;

    if (OK(netlib_strtoaddr(namdsc, &addr))) {
    	addrlist[0] = addr;
    	if (argc > 5 && count != 0) *count = 1;
    	if (argc > 6 && iosb != 0) {
    	    iosb->iosb_w_status = SS$_NORMAL;
    	    iosb->iosb_w_count = 1;
    	    iosb->iosb_l_unused = 0;
    	}
    	if (argc > 7 && astadr != 0) {
    	    return sys$dclast(astadr, (argc > 8) ? astprm : 0, 0);
    	} else {
    	    return SS$_NORMAL;
    	}
    }

    if (argc > 7 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);
    	status = lib$get_vm(&hostent_size, &ior->spec_hostent);
    	if (!OK(status)) {
    	    FREE_IOR(ior);
    	    return status;
    	}
    	ior->specior.subfunction =
    	    (INETACP$C_HOSTENT_OFFSET << 8) | INETACP_FUNC$C_GETHOSTBYNAME;

    	ITMLST2_INIT(subfdsc, 0, sizeof(ior->specior.subfunction),
    	    	    &ior->specior.subfunction);
    	ITMLST2_INIT(entdsc, 0, hostent_size, ior->spec_hostent);
    	
    	ior->spec_useralist = addrlist;
    	ior->spec_length = *listsize;
    	ior->spec_retlen = count;
    	ior->iorflags = IOR_M_COPY_ADDRS;
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACPCONTROL, &ior->iosb,
    	    	    	    io_completion, ior, &subfdsc, namdsc,
    	    	    	    &ior->specior.fromlen, &entdsc, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    	return status;
    }

    subfunction =
    	    (INETACP$C_HOSTENT_OFFSET << 8) | INETACP_FUNC$C_GETHOSTBYNAME;

    ITMLST2_INIT(subfdsc, 0, sizeof(subfunction), &subfunction);
    ITMLST2_INIT(entdsc, 0, hostent_size, &hostent);
    status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACPCONTROL, &myiosb,
    	    	    	0, 0, &subfdsc, namdsc, &helen, &entdsc, 0, 0);
    if (OK(status)) status = netlib___cvt_status(&myiosb);
    if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    if (OK(status)) {
    	char *base;
    	unsigned int *offlst;
    	int i;
    	base = (char *) &hostent;
    	i = 0;
    	if (hostent.addrlist_offset != 0) {
    	    offlst = (unsigned int *) (base+hostent.addrlist_offset);
    	    while (i < *listsize && offlst[i] != 0) {
    	    	addrlist[i] = *(struct INADDRDEF *) (base + offlst[i]);
    	    	i++;
    	    }
    	}
    	if (argc > 5 && count != 0) *count = i;
    }

    return status;
    
} /* netlib_name_to_address */
示例#28
0
/*
**++
**  ROUTINE:	netlib_address_to_name
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Uses the UCX IO$_ACPCONTROL $QIO function to translate an
**  IP address into a host name.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	NETLIB_ADDRESS_TO_NAME  ctx, which, addr, addrsize, namdsc [,retlen] [,iosb] [,astadr] [,astprm]
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_address_to_name (struct CTX **xctx, unsigned int *whichp,
    	    	    	    struct INADDRDEF *addr,
    	    	    	    unsigned int *addrsize,
    	    	    	    struct dsc$descriptor *namdsc,
    	    	    	    unsigned short *retlen,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {

    struct CTX *ctx;
    struct NETLIBIOSBDEF myiosb;
    ITMLST2 subfdsc, entdsc, adrdsc;
    unsigned int status, subfunction;
    char buf[1024];
#ifdef TCPWARE
    char tmp[64];
    struct dsc$descriptor tmpdsc;
#endif /* TCPWARE */
    unsigned short length;
    int argc;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (argc < 5) return SS$_INSFARG;

    if (addr == 0 || addrsize == 0 || namdsc == 0) return SS$_BADPARAM;
    if (*addrsize != sizeof(struct INADDRDEF)) return SS$_BADPARAM;

#ifdef TCPWARE
    INIT_SDESC (tmpdsc, sizeof(tmp), tmp);
    status = netlib_addrtostr(addr, &tmpdsc, &tmpdsc.dsc$w_length);
    if (!OK(status)) return status;
#else
    ITMLST2_INIT(adrdsc, 0, *addrsize, addr);
#endif /* TCPWARE */
    if (argc > 7 && astadr != 0) {
    	struct IOR *ior;
    	struct HOSTENT *h;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);
    	status = lib$get_vm(&hostent_size, &h);
    	if (!OK(status)) {
    	    FREE_IOR(ior);
    	    return status;
    	}
    	ior->spec_usrdsc = namdsc;
    	ior->spec_retlen = retlen;
    	ior->specior.subfunction =
#ifndef TCPWARE
    	    (INETACP$C_TRANS << 8) |
#endif /* not TCPWARE */
    	    INETACP_FUNC$C_GETHOSTBYADDR;

    	ITMLST2_INIT(subfdsc, 0, sizeof(ior->specior.subfunction),
    	    	    	    &ior->specior.subfunction);
    	ITMLST2_INIT(entdsc, 0, sizeof(h->buffer), h->buffer);
    	ior->spec_hostent = h;
    	ior->iorflags = IOR_M_COPY_HOSTNAME;
    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACPCONTROL, &ior->iosb,
    	    	    	    io_completion, ior, &subfdsc,
#ifdef TCPWARE
    	    	    	    &tmpdsc,
#else
    	    	    	    &adrdsc,
#endif /* TCPWARE */
    	    	    	    &ior->specior.fromlen, &entdsc, 0, 0);
    	if (!OK(status)) FREE_IOR(ior);
    	return status;
    }

    subfunction =
#ifndef TCPWARE
    	    	  (INETACP$C_TRANS << 8) |
#endif
    	    	  INETACP_FUNC$C_GETHOSTBYADDR;

    ITMLST2_INIT(subfdsc, 0, sizeof(subfunction), &subfunction);
    ITMLST2_INIT(entdsc, 0, sizeof(buf), buf);
    status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACPCONTROL, &myiosb,
    	    	    	0, 0, &subfdsc,
#ifdef TCPWARE
    	    	    	&tmpdsc,
#else
    	    	    	&adrdsc,
#endif /* TCPWARE */
    	    	    	&length, &entdsc, 0, 0);
    if (OK(status)) status = netlib___cvt_status(&myiosb);
    if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    if (OK(status)) {
    	str$copy_r(namdsc, &length, buf);
    	if (argc > 5 && retlen != 0) *retlen = length;
    }

    return status;

} /* netlib_address_to_name */
示例#29
0
void goq_load(uint4 begin, uint4 end, struct FAB *infab)
{
	int		status;
	msgtype		msg;
	unsigned char	*in_buff, *b;
	unsigned int	n;
	bool		is_begin;
	uint4		rec_count;
	unsigned short	goq_blk_size;
	short		iosb[4];

	error_def(ERR_INVMVXSZ);
	error_def(ERR_MUPIPINFO);
	error_def(ERR_PREMATEOF);
	error_def(ERR_LDGOQFMT);
	error_def(ERR_BEGINST);

	rec_count = 0;
	if (begin > 0)
		is_begin = TRUE;
	else
		is_begin = FALSE;
	goq_blk_size = MVX_BLK_SIZE;
	infab->fab$w_mrs = goq_blk_size;
	in_buff = malloc(goq_blk_size + 8);
	if (is_begin)
	{
		status = sys$qio(efn_bg_qio_read, infab->fab$l_stv, IO$_READVBLK, &iosb[0],
				0, 0, in_buff, goq_blk_size,
				(rec_count * goq_blk_size / 512) + 1, 0, 0, 0);
		if (SS$_NORMAL != status)		/* get header block */
			rts_error(VARLSTCNT(1) status);
		sys$synch(efn_bg_qio_read, &iosb[0]);
		if (SS$_NORMAL != iosb[0])
			rts_error(VARLSTCNT(1) iosb[0]);
		if (iosb[1] != goq_blk_size)
		{
			if (M11_BLK_SIZE != iosb[1])
				rts_error(VARLSTCNT(1) ERR_INVMVXSZ);
			goq_blk_size = M11_BLK_SIZE;
		}
		while ((SS$_ENDOFFILE != iosb[0]) && (rec_count < begin))
		{
			rec_count++;
			status = sys$qio(efn_bg_qio_read, infab->fab$l_stv, IO$_READVBLK, &iosb[0],
					0, 0, in_buff, goq_blk_size,
					(rec_count * goq_blk_size / 512) + 1, 0, 0, 0);
			if (SS$_NORMAL != status)
				rts_error(VARLSTCNT(1) status);
			sys$synch(efn_bg_qio_read, &iosb[0]);
			if ((SS$_NORMAL != iosb[0]) && (SS$_ENDOFFILE != iosb[0]))
			{
				rts_error(VARLSTCNT(1) iosb[0]);
				mupip_exit(iosb[0]);
			}
		}
		for (;rec_count < begin;)
		{
			status = sys$qio(efn_bg_qio_read, infab->fab$l_stv, IO$_READVBLK, &iosb[0],
					0, 0, in_buff, goq_blk_size,
					(rec_count * goq_blk_size / 512) + 1, 0, 0, 0);
			if (SS$_NORMAL != status)
				rts_error(VARLSTCNT(1) status);
			sys$synch(efn_bg_qio_read, &iosb[0]);
			if (SS$_ENDOFFILE == iosb[0])
				rts_error(VARLSTCNT(1) ERR_PREMATEOF);
			if (SS$_NORMAL != iosb[0])
				rts_error(VARLSTCNT(1) iosb[0]);
			rec_count++;
		}
		msg.msg_number = ERR_BEGINST;
		msg.arg_cnt = 3;
		msg.new_opts = msg.def_opts = 1;
		msg.fp_cnt = 1;
		msg.fp[0].n = rec_count;
		sys$putmsg(&msg, 0, 0, 0);
	} else
	{
		status = sys$qio(efn_bg_qio_read, infab->fab$l_stv, IO$_READVBLK, &iosb[0],
				0, 0, in_buff, goq_blk_size,
				(rec_count * goq_blk_size / 512) + 1, 0, 0, 0);
		if (SS$_NORMAL != status)
			rts_error(VARLSTCNT(1) status);
		sys$synch(efn_bg_qio_read, &iosb[0]);
		if (SS$_NORMAL != iosb[0])
		{
			rts_error(VARLSTCNT(1) iosb[0]);
			mupip_exit(iosb[0]);
		}
		if (iosb[1] != goq_blk_size)
		{
			if (M11_BLK_SIZE != iosb[1])
				rts_error(VARLSTCNT(1) ERR_INVMVXSZ);
			goq_blk_size = M11_BLK_SIZE;
		}
		b = in_buff;
		while ((13 != *b++) && (b - in_buff < goq_blk_size - 28))
			;
		if (memcmp(b - SIZEOF("~%GOQ"), LIT_AND_LEN("~%GOQ")) || (10 != *b))
		{
			rts_error(VARLSTCNT(1) ERR_LDGOQFMT);
			mupip_exit(ERR_LDGOQFMT);
		}
		for (n = 0;  n < 3;  n++)
		{
			while ((13 != *b++) && b - in_buff < goq_blk_size)
				;
			if (10 != *b++)
			{
				rts_error(VARLSTCNT(1) ERR_LDGOQFMT);
				mupip_exit(ERR_LDGOQFMT);
			}
		}
		msg.msg_number = ERR_MUPIPINFO;
		msg.arg_cnt = 4;
		msg.new_opts = msg.def_opts = 1;
		msg.fp_cnt = 2;
		msg.fp[0].n = b - in_buff - 1;
		msg.fp[1].cp = in_buff;
		sys$putmsg(&msg, 0, 0, 0);
		while (SS$_ENDOFFILE != iosb[0])
		{
			rec_count++;
			status = sys$qio(efn_bg_qio_read, infab->fab$l_stv, IO$_READVBLK, &iosb[0],
					0, 0, in_buff, goq_blk_size,
					(rec_count * goq_blk_size / 512) + 1, 0, 0, 0);
			if (SS$_NORMAL != status)
			{
				rts_error(VARLSTCNT(1) status);
				mupip_exit(status);
			}
			sys$synch(efn_bg_qio_read, &iosb[0]);
			if ((SS$_NORMAL != iosb[0]) && (SS$_ENDOFFILE != iosb[0]))
			{
				rts_error(VARLSTCNT(1) iosb[0]);
				mupip_exit(iosb[0]);
			}
		}
	}
	if (MVX_BLK_SIZE == goq_blk_size)
		goq_mvx_load(infab, in_buff, rec_count, end);
	else
		goq_m11_load(infab, in_buff, rec_count, end);
	/***********************************************************************************************/
	/*					Shut Down                                              */
	/***********************************************************************************************/
CLOSE:
	free(in_buff);
	gv_cur_region = NULL;
	status = sys$dassgn(infab->fab$l_stv);
	if (SS$_NORMAL != status)
	{
		rts_error(VARLSTCNT(1) status);
		mupip_exit(status);
	}
	return;
}
示例#30
0
/*
**++
**  ROUTINE:	netlib_read
**
**  FUNCTIONAL DESCRIPTION:
**
**  	tbs
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	tbs
**
**  IMPLICIT INPUTS:	None.
**
**  IMPLICIT OUTPUTS:	None.
**
**  COMPLETION CODES:
**
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int netlib_read (struct CTX **xctx, struct dsc$descriptor *dsc,
    	    	    	    struct SINDEF *sa, unsigned int *sasize,
    	    	    	    unsigned int *salen, TIME *timeout,
    	    	    	    struct NETLIBIOSBDEF *iosb,
    	    	    	    void (*astadr)(), void *astprm) {
    struct CTX *ctx;
    struct IOR *ior;
    unsigned int status;
    ITMLST sname;
    int argc, do_from;

    VERIFY_CTX(xctx, ctx);
    SETARGCOUNT(argc);

    if (dsc->dsc$b_dtype != DSC$K_DTYPE_T && dsc->dsc$b_dtype != 0)
    	return SS$_BADPARAM;
    if (dsc->dsc$b_class == DSC$K_CLASS_D) {
	if (dsc->dsc$w_length == 0) return SS$_BADPARAM;
    } else {
    	if (dsc->dsc$b_class != DSC$K_CLASS_S && dsc->dsc$b_class != 0)
    	return SS$_BADPARAM;
    }

    do_from = (argc > 3 && sa != 0 && sasize != 0 && *sasize != 0);
    if (argc > 7 && astadr != 0) {
    	struct IOR *ior;
    	GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);
    	if (do_from) ITMLST_INIT(sname, 0, sizeof(struct SINDEF),
    	    	    &ior->specior.from, &ior->specior.fromlen);
    	if (do_from) {
    	    ior->spec_userfrom = sa;
    	    ior->spec_length = *sasize;
    	    ior->spec_retlen = salen;
    	    ior->iorflags = IOR_M_COPY_FROM;
    	} else ior->iorflags = 0;
    	if (timeout != 0) {
    	    ior->iorflags |= IOR_M_IO_TIMED;
    	    status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior);
    	    if (!OK(status)) {
    	    	FREE_IOR(ior);
    	    	return status;
    	    }
    	}

    	status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_READVBLK, &ior->iosb,
    	    	    	    io_completion, ior, dsc->dsc$a_pointer,
    	    	    	    dsc->dsc$w_length, do_from ? &sname : 0, 0, 0, 0);
    	if (!OK(status)) {
    	    if (timeout != 0) sys$cantim(ior, 0);
    	    FREE_IOR(ior);
    	}
    } else {
    	struct NETLIBIOSBDEF myiosb;
    	struct SINDEF from;
    	unsigned short fromlen;
    	int timed_out;

    	if (do_from) ITMLST_INIT(sname, 0, sizeof(struct SINDEF),
    	    	    &from, &fromlen);

    	timed_out = 0;
    	if (argc > 5 && timeout != 0) {
    	    GET_IOR(ior, ctx, 0, 0, 0);
    	    ior->iorflags = IOR_M_IO_TIMED;
    	    status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior);
    	    if (!OK(status)) {
    	    	FREE_IOR(ior);
    	    	return status;
    	    }
    	}
    	status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_READVBLK,
    	    	    	    &myiosb, 0, 0,
    	    	    	    dsc->dsc$a_pointer, dsc->dsc$w_length,
    	    	    	    do_from ? &sname : 0, 0, 0, 0);
    	if (argc > 5 && timeout != 0) {
    	    sys$cantim(ior, 0);
    	    timed_out = ior->iorflags & IOR_M_IO_TIMEOUT;
    	    FREE_IOR(ior);
    	}
    	if (OK(status)) {
    	    if (timed_out && myiosb.iosb_w_status == SS$_CANCEL)
    	    	myiosb.iosb_w_status = SS$_TIMEOUT;
    	    status = netlib___cvt_status(&myiosb);
    	}
    	if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);
    	if (OK(status) && do_from) {
    	    unsigned int len;
    	    len = fromlen;
    	    if (len > *sasize) len = *sasize;
    	    memcpy(sa, &from, len);
    	    if (argc > 4 && salen != 0) *salen = len;
    	}
    }

    return status;

} /* netlib_read */