|
|
1.1 ! root 1: /* conn.c - */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/quipu/RCS/conn.c,v 7.1 90/07/09 14:45:21 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/quipu/RCS/conn.c,v 7.1 90/07/09 14:45:21 mrose Exp $ ! 9: * ! 10: * ! 11: * $Log: conn.c,v $ ! 12: * Revision 7.1 90/07/09 14:45:21 mrose ! 13: * sync ! 14: * ! 15: * Revision 7.0 89/11/23 22:16:42 mrose ! 16: * Release 6.0 ! 17: * ! 18: */ ! 19: ! 20: /* ! 21: * NOTICE ! 22: * ! 23: * Acquisition, use, and distribution of this module and related ! 24: * materials are subject to the restrictions of a license agreement. ! 25: * Consult the Preface in the User's Manual for the full terms of ! 26: * this agreement. ! 27: * ! 28: */ ! 29: ! 30: #include "quipu/dsap.h" ! 31: #include "quipu/util.h" ! 32: #include "quipu/connection.h" ! 33: ! 34: extern LLog * log_dsap; ! 35: ! 36: struct connection * conn_alloc() ! 37: { ! 38: struct connection * conn_ret; ! 39: ! 40: conn_ret = (struct connection *) calloc(1,sizeof(struct connection)); ! 41: conn_ret->cn_op_id = 1; ! 42: ! 43: return(conn_ret); ! 44: } ! 45: ! 46: conn_free(conn) ! 47: struct connection * conn; ! 48: { ! 49: DLOG(log_dsap, LLOG_TRACE, ("conn_free()")); ! 50: ! 51: if(conn->cn_dn != NULLDN) ! 52: dn_free(conn->cn_dn); ! 53: ! 54: if (conn->cn_initiator) ! 55: { ! 56: conn_connect_free (&(conn->cn_connect)); ! 57: } ! 58: else ! 59: { ! 60: conn_start_free (&(conn->cn_start)); ! 61: } ! 62: ! 63: free((char *)conn); ! 64: } ! 65: ! 66: conn_connect_free (cc) ! 67: struct conn_connect * cc; ! 68: { ! 69: bind_arg_free (&(cc->cc_req)); ! 70: ! 71: DCFREE (&(cc->cc_dc)); ! 72: } ! 73: ! 74: conn_start_free (cs) ! 75: struct conn_start * cs; ! 76: { ! 77: if (cs->cs_svec[0]) ! 78: free (cs->cs_svec[0]); ! 79: if (cs->cs_svec[1]) ! 80: free (cs->cs_svec[1]); ! 81: if (cs->cs_svec[2]) ! 82: free (cs->cs_svec[2]); ! 83: if (cs->cs_svec[3]) ! 84: free (cs->cs_svec[3]); ! 85: ! 86: bind_arg_free (&(cs->cs_res)); ! 87: ! 88: DSFREE (&(cs->cs_ds)); ! 89: } ! 90: ! 91: conn_extract(conn) ! 92: struct connection * conn; ! 93: { ! 94: /* ! 95: * Extract all the operations made on this connection, and all ! 96: * the tasks (and their derivative operations) made on the connection; ! 97: * then remove the connection from the list of active connections. ! 98: */ ! 99: ! 100: struct oper_act * on; ! 101: struct oper_act * on_next; ! 102: struct task_act * tk; ! 103: struct task_act * tk_next; ! 104: struct connection * cn; ! 105: struct connection **cn_p; ! 106: struct DSError * err; ! 107: ! 108: DLOG (log_dsap,LLOG_TRACE, ("conn_extract")); ! 109: ! 110: if(conn == NULLCONN) ! 111: { ! 112: LLOG(log_dsap, LLOG_EXCEPTIONS, ("Extracting NULLCONN!!!")); ! 113: return; ! 114: } ! 115: ! 116: cn_p = &(connlist); ! 117: for(cn=connlist; cn!=NULLCONN; cn=cn->cn_next) ! 118: { ! 119: DLOG(log_dsap, LLOG_DEBUG, ("checking connlist")); ! 120: if(cn == conn) ! 121: break; ! 122: ! 123: cn_p = &(cn->cn_next); ! 124: } ! 125: if(cn==NULLCONN) ! 126: { ! 127: LLOG(log_dsap, LLOG_EXCEPTIONS, ("conn_extract - connection not in connlist")); ! 128: } ! 129: else ! 130: { ! 131: /* Cut connection loose from global list */ ! 132: DLOG(log_dsap, LLOG_DEBUG, ("Extracting conn from connlist")); ! 133: (*cn_p) = cn->cn_next; ! 134: conns_used--; ! 135: } ! 136: ! 137: for(on=conn->cn_operlist; on!=NULLOPER; on=on_next) ! 138: { ! 139: on_next = on->on_next_conn; ! 140: oper_fail_wakeup (on); ! 141: } ! 142: ! 143: for(tk=conn->cn_tasklist; tk!=NULLTASK; tk=tk_next) ! 144: { ! 145: tk_next = tk->tk_next; ! 146: err = &(tk->tk_resp.di_error.de_err); ! 147: if((err->dse_type != DSE_REFERRAL) && (err->dse_type != DSE_DSAREFERRAL)) ! 148: { ! 149: err->dse_type = DSE_SERVICEERROR; ! 150: err->ERR_SERVICE.DSE_sv_problem = DSE_SV_UNAVAILABLE; ! 151: } ! 152: task_error(tk); ! 153: task_extract(tk); ! 154: } ! 155: ! 156: conn_free(conn); ! 157: } ! 158: ! 159: conn_log(conn) ! 160: struct connection * conn; ! 161: { ! 162: struct oper_act * oper; ! 163: struct task_act * task; ! 164: ! 165: if(conn == NULLCONN) ! 166: { ! 167: LLOG (log_dsap,LLOG_NOTICE, ("Connection: NULLCONN")); ! 168: return; ! 169: } ! 170: ! 171: DLOG (log_dsap,LLOG_DEBUG, ("Connection [%x], ad = %d, ctx = %d", conn, conn->cn_ad, conn->cn_ctx)); ! 172: ! 173: #ifdef DEBUG ! 174: switch(conn->cn_state) ! 175: { ! 176: case CN_INDICATED: ! 177: DLOG (log_dsap,LLOG_DEBUG, ("State: INDICATED")); ! 178: break; ! 179: case CN_WAITING: ! 180: DLOG (log_dsap,LLOG_DEBUG, ("State: WAITING")); ! 181: break; ! 182: case CN_CONNECTING1: ! 183: DLOG (log_dsap,LLOG_DEBUG, ("State: CONNECTING 1")); ! 184: break; ! 185: case CN_CONNECTING2: ! 186: DLOG (log_dsap,LLOG_DEBUG, ("State: CONNECTING 2")); ! 187: break; ! 188: case CN_OPEN: ! 189: DLOG (log_dsap,LLOG_DEBUG, ("State: OPEN")); ! 190: break; ! 191: case CN_FAILED: ! 192: DLOG (log_dsap,LLOG_DEBUG, ("State: FAIL")); ! 193: break; ! 194: case CN_CLOSING: ! 195: DLOG (log_dsap,LLOG_DEBUG, ("State: CLOSING")); ! 196: break; ! 197: case CN_OPENING: ! 198: DLOG (log_dsap,LLOG_DEBUG, ("State: OPENING")); ! 199: break; ! 200: default: ! 201: DLOG (log_dsap,LLOG_DEBUG, ("State: Erroneous - %d",conn->cn_state)); ! 202: break; ! 203: } ! 204: #endif ! 205: ! 206: DLOG (log_dsap,LLOG_DEBUG, ("Tasks:")); ! 207: for(task=conn->cn_tasklist; task!=NULLTASK; task=task->tk_next) ! 208: task_log(task); ! 209: DLOG (log_dsap,LLOG_DEBUG, ("Opers:")); ! 210: for(oper=conn->cn_operlist; oper!=NULLOPER; oper=oper->on_next_conn) ! 211: oper_log(oper); ! 212: DLOG (log_dsap,LLOG_DEBUG, ("!")); ! 213: } ! 214: ! 215: conn_list_log(cn) ! 216: struct connection * cn; ! 217: { ! 218: struct connection * cn_tmp; ! 219: ! 220: DLOG(log_dsap, LLOG_DEBUG, ("Connection List:")); ! 221: for(cn_tmp=cn; cn_tmp!=NULLCONN; cn_tmp=cn_tmp->cn_next) ! 222: { ! 223: conn_log(cn_tmp); ! 224: } ! 225: DLOG(log_dsap, LLOG_DEBUG, ("End of Connection List.")); ! 226: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.