|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 8422 (0x20e6)
Types: TextFile
Names: »submit2qmgr.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z«
└─⟦e5a54fb17⟧
└─⟦this⟧ »pp-5.0/Lib/qmgr/submit2qmgr.c«
/* submit_interface: interface to qmgr for submit's use */
# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/qmgr/RCS/submit2qmgr.c,v 5.0 90/09/20 16:22:30 pp Exp Locker: pp $";
# endif
/*
* $Header: /cs/research/pp/hubris/pp-beta/Lib/qmgr/RCS/submit2qmgr.c,v 5.0 90/09/20 16:22:30 pp Exp Locker: pp $
*
* $Log: submit2qmgr.c,v $
* Revision 5.0 90/09/20 16:22:30 pp
* rcsforce : 5.0 public release
*
*/
#include "head.h"
#include <varargs.h>
#include "qmgr.h"
/* Sumbit types */
#include "q.h"
#include "prm.h"
/* Outside routines */
struct type_Qmgr_MsgStruct *qstruct2qmgr();
/* DATA */
static char *myservice = "pp qmgr";
/* OPERATIONS */
static int newmessage_result();
static int general_error();
#define newmessage_error general_error
static void acs_log ();
static void ros_log ();
static int getresult ();
/* \f
*/
/* main interface routines */
int qmgr_start(hostname)
char *hostname;
/* copied from ryinitiator */
/* returns NOTOK if fails */
/* otherwise returns the association descriptor */
{
int sd;
struct SSAPref sfs;
register struct SSAPref *sf;
register struct PSAPaddr *pa;
struct AcSAPconnect accs;
register struct AcSAPconnect *acc = &accs;
struct AcSAPindication acis;
register struct AcSAPindication *aci = &acis;
register struct AcSAPabort *aca = &aci -> aci_abort;
AEI aei;
OID ctx,
pci;
struct PSAPctxlist pcs;
register struct PSAPctxlist *pc = &pcs;
struct RoSAPindication rois;
register struct RoSAPindication *roi = &rois;
register struct RoSAPpreject *rop = &roi -> roi_preject;
if ((aei = str2aei (hostname, myservice)) == NULLAEI &&
(aei = str2aei (hostname, "pp-qmgr")) == NULLAEI) {
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface start: %s-%s: unknown application-entity",hostname,myservice));
return NOTOK;
}
if ((pa = aei2addr(aei)) == NULLPA) {
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface start: address translation failed"));
return NOTOK;
}
if ((ctx = oid_cpy(QMGR_AC)) == NULLOID) {
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface start: out of memory"));
return NOTOK;
}
if ((pci = oid_cpy(QMGR_PCI)) == NULLOID) {
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface start: out of memory"));
return NOTOK;
}
pc->pc_nctx = 1;
pc->pc_ctx[0].pc_id = 1;
pc->pc_ctx[0].pc_asn = pci;
pc->pc_ctx[0].pc_atn = NULLOID;
if ((sf = addr2ref (PLocalHostName ())) == NULL) {
sf = &sfs;
(void) bzero ((char *) sf, sizeof(*sf));
}
if (AcAssocRequest (ctx, NULLAEI, aei, NULLPA, pa, pc, NULLOID,
0, ROS_MYREQUIRE, SERIAL_NONE, 0, sf, NULLPEP,
0, NULLQOS, acc, aci) == NOTOK) {
acs_log(aca,"A-ASSOCIATE.REQUEST");
return NOTOK;
}
if (acc->acc_result != ACS_ACCEPT) {
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface start: Association rejected: [%s]",
AcErrString(acc->acc_result)));
return NOTOK;
}
sd = acc->acc_sd;
ACCFREE(acc);
if (RoSetService(sd, RoPService, roi) == NOTOK) {
ros_log(rop,"set RO/PS fails");
return NOTOK;
}
return sd;
}
static int outstanding = NOTOK;
int qmgr_end(sd)
int sd;
/* copied from do_quit in qmgr_start */
{
struct AcSAPrelease acrs;
register struct AcSAPrelease *acr = &acrs;
struct AcSAPindication acis;
register struct AcSAPindication *aci = &acis;
register struct AcSAPabort *aca = &aci -> aci_abort;
if (outstanding != NOTOK)
if (getresult (sd, outstanding, 60) == NOTOK)
return NOTOK;
outstanding = NOTOK;
#ifdef CONNECTING_1
if (AcRelRequest(sd,ACF_NORMAL,NULLPEP,0, NOTOK, acr,aci) == NOTOK) {
#else
if (AcRelRequest(sd,ACF_NORMAL,NULLPEP,0,acr,aci) == NOTOK) {
#endif
acs_log(aca,"A-RELEASE.REQUEST");
return NOTOK;
}
if (!acr->acr_affirmative) {
(void) AcUAbortRequest (sd, NULLPEP, 0, aci);
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface end: Release rejected by peer: %d",
acr->acr_reason));
return NOTOK;
}
ACRFREE(acr);
return OK;
}
int message_send (sd, file, prm, que, sender, recips, rcount)
int sd;
char *file;
struct prm_vars *prm;
Q_struct *que;
ADDR *sender,
*recips;
int rcount;
{
/* copied from invoke in ryinitiator */
int result;
struct type_Qmgr_MsgStruct *in;
struct RoSAPindication rois;
register struct RoSAPindication *roi = &rois;
register struct RoSAPpreject *rop = &roi->roi_preject;
if (outstanding != NOTOK)
if (getresult (sd, outstanding, NOTOK) == NOTOK)
return NOTOK;
outstanding = NOTOK;
if ((in = qstruct2qmgr(file,prm,que,sender,recips,rcount)) == NULL) {
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface: qstruct2qmgr failure for '%s'",
file));
return NOTOK;
}
if (in->recipientlist == NULL) {
/* no users waiting so no need to pass to qmgr */
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface: no recips for '%s'",
file));
free_Qmgr_PerMessageInfo(in->messageinfo);
free((char *) in);
return OK;
}
switch (result = RyStub (sd, table_Qmgr_Operations,
operation_Qmgr_newmessage,
outstanding = RyGenID(sd), NULLIP,
(caddr_t) in,
newmessage_result,
newmessage_error, ROS_ASYNC, roi)) {
case NOTOK:
if (ROS_FATAL(rop->rop_reason)) {
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface: STUB"));
return outstanding = NOTOK;
}
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface message_send:STUB"));
break;
case OK:
break;
case DONE:
PP_LOG (LLOG_EXCEPTIONS,
("got RO-END.INDICATION"));
outstanding = NOTOK;
return qmgr_end(sd);
default:
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface unknown return from RyStub=%d",result));
return outstanding = NOTOK;
}
if (in)
free_Qmgr_MsgStruct(in);
return OK;
}
/* \f
*/
/* subsiduary routines */
/* ARGSUSED */
static int newmessage_result (sd, id, dummy, result, roi)
int sd,
id,
dummy;
struct type_Qmgr_Pseudo__newmessage *result;
struct RoSAPindication *roi;
{
return OK;
}
/* ARGSUSED */
static int general_error (sd, id, error, parameter, roi)
int sd,
id,
error;
caddr_t parameter;
struct RoSAPindication *roi;
{
register struct RyError *rye;
if (error == RY_REJECT) {
PP_LOG (LLOG_EXCEPTIONS, ("%s", RoErrString ((int) parameter)));
return OK;
}
if (rye = finderrbyerr (table_Qmgr_Errors, error))
PP_LOG (LLOG_EXCEPTIONS, ("%s", rye -> rye_name));
else
PP_LOG (LLOG_EXCEPTIONS, ("Error %d", error));
return OK;
}
/* \f
*/
static void ros_log (rop, event)
register struct RoSAPpreject *rop;
char *event;
{
char buffer[BUFSIZ];
if (rop -> rop_cc > 0)
(void) sprintf (buffer, "[%s] %*.*s", RoErrString (rop -> rop_reason),
rop -> rop_cc, rop -> rop_cc, rop -> rop_data);
else
(void) sprintf (buffer, "[%s]", RoErrString (rop -> rop_reason));
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface %s: %s", event, buffer));
}
/* \f
*/
static void acs_log (aca, event)
register struct AcSAPabort *aca;
char *event;
{
char buffer[BUFSIZ];
if (aca -> aca_cc > 0)
(void) sprintf (buffer, "[%s] %*.*s",
AcErrString (aca -> aca_reason),
aca -> aca_cc, aca -> aca_cc, aca -> aca_data);
else
(void) sprintf (buffer, "[%s]",
AcErrString (aca -> aca_reason));
PP_LOG (LLOG_EXCEPTIONS,
("Lib/qmgr/submit_interface %s: %s (source %d)", event, buffer,
aca -> aca_source));
}
static int getresult (sd, id, delay)
int sd, id, delay;
{
caddr_t out;
struct RoSAPindication rois;
register struct RoSAPindication *roi = &rois;
register struct RoSAPpreject *rop = &roi->roi_preject;
switch (RyWait (sd, &id, &out, delay, roi)) {
case NOTOK:
if (rop -> rop_reason == ROS_TIMER)
break;
ros_log (rop, "RyWait Stub");
if (ROS_FATAL (rop -> rop_reason)) {
PP_LOG (LLOG_EXCEPTIONS,
("qmgr-interface failed fatally"));
return NOTOK;
}
break;
case OK:
break;
case DONE:
PP_LOG (LLOG_EXCEPTIONS,
("qmgr interface quit"));
return NOTOK;
default:
PP_LOG (LLOG_EXCEPTIONS,
("qmgr interface - bad response"));
return NOTOK;
}
return OK;
}