Beispiel #1
0
/*
 * Queue an ArchReq.
 */
static void *
queueArchReq(
	void *arg,
/* LINTED argument unused in function */
	struct UdsMsgHeader *hdr)
{
	struct AsrArchReq *a = (struct AsrArchReq *)arg;
	static char sizebuf[STR_FROM_FSIZE_BUF_SIZE];
	static char arname[ARCHREQ_NAME_SIZE];
	static struct AsrGeneralRsp rsp;
	static struct QueueEntry *qe;
	struct ArchReq *ar;

	rsp.GrStatus = -1;
	rsp.GrErrno = 0;
	snprintf(arname, sizeof (arname), "%s.%s", a->ArFsname, a->ArArname);
	if (QueueHasArchReq(arname)) {
		Trace(TR_MISC, "Already have %s", arname);
		rsp.GrErrno = EADDRINUSE;
		goto out;
	}
	ar = ArchReqAttach(a->ArFsname, a->ArArname, O_RDWR);
	if (ar == NULL) {
		Trace(TR_ERR,
		    "ArchReqAttach(%s.%s) failed", a->ArFsname, a->ArArname);
		rsp.GrErrno = errno;
		goto out;
	}
	if (!ArchReqValid(ar)) {
		rsp.GrErrno = errno;
		(void) ArchReqDetach(ar);
		goto out;
	}
	qe = QueueGetFree();
	ar->ArFlags |= AR_first;
	ar->ArMsgSent = 0;
	ar->ArTimeQueued = time(NULL);
	memset(&ar->ArCpi[0], 0, ar->ArDrives * sizeof (struct ArcopyInstance));
	qe->QeAr = ar;
	strncpy(qe->QeArname, arname, sizeof (qe->QeArname) - 1);
	ComposeEnqueue(qe);
	Trace(TR_QUEUE,
	    "Queue (%s) files: %d space: %s",
	    qe->QeArname, ar->ArFiles,
	    StrFromFsize(ar->ArSpace, 3, sizebuf, sizeof (sizebuf)));
	rsp.GrStatus = 0;

out:
	return (&rsp);
}
Beispiel #2
0
DWORD COMMAPI ComOutSpace(HCOMM hc)
{
  ComIsOnline(hc);
  return QueueGetFree(&hc->cqTx);
}