Lines Matching refs:exchange
30 static int32 SharedSend(MQueueId queueId, Exchange *exchange, int initRef);
31 static BOOL FreeReference(Exchange *exchange);
39 Exchange exchange = {*identity, *request, {NULL, 0}, MSG_NON, handler, NULL}; in SAMGR_SendRequest() local
40 exchange.id.queueId = NULL; in SAMGR_SendRequest()
42 exchange.id.queueId = SAMGR_GetCurrentQueueID(); in SAMGR_SendRequest()
43 exchange.type = MSG_CON; in SAMGR_SendRequest()
46 return QUEUE_Put(identity->queueId, &exchange, 0, DONT_WAIT); in SAMGR_SendRequest()
56 Exchange *exchange = GET_OBJECT(request, Exchange, request); in SAMGR_SendResponse() local
57 if (exchange->type != MSG_CON) { in SAMGR_SendResponse()
61 if (exchange->handler == NULL) { in SAMGR_SendResponse()
65 exchange->type = MSG_ACK; in SAMGR_SendResponse()
66 exchange->response.data = NULL; in SAMGR_SendResponse()
67 exchange->response.len = 0; in SAMGR_SendResponse()
69 exchange->response = *response; in SAMGR_SendResponse()
73 if (exchange->id.queueId == NULL) { in SAMGR_SendResponse()
74 exchange->handler(&exchange->request, &exchange->response); in SAMGR_SendResponse()
79 int32 ret = SharedSend(exchange->id.queueId, exchange, 1); in SAMGR_SendResponse()
81 exchange->handler(&exchange->request, &exchange->response); in SAMGR_SendResponse()
82 (void)FreeReference(exchange); in SAMGR_SendResponse()
100 int32 SAMGR_FreeMsg(Exchange *exchange) in SAMGR_FreeMsg() argument
102 if (!FreeReference(exchange)) { in SAMGR_FreeMsg()
106 if (exchange->request.len > 0) { in SAMGR_FreeMsg()
107 SAMGR_Free(exchange->request.data); in SAMGR_FreeMsg()
108 exchange->request.data = NULL; in SAMGR_FreeMsg()
111 if (exchange->response.len > 0) { in SAMGR_FreeMsg()
112 SAMGR_Free(exchange->response.data); in SAMGR_FreeMsg()
113 exchange->response.data = NULL; in SAMGR_FreeMsg()
123 Exchange exchange = {*identity, *request, {NULL, 0}, MSG_NON, handler, token}; in SAMGR_SendSharedRequest() local
124 exchange.type = (handler == NULL) ? MSG_NON : MSG_CON; in SAMGR_SendSharedRequest()
125 exchange.id.queueId = NULL; in SAMGR_SendSharedRequest()
126 int32 err = SharedSend(identity->queueId, &exchange, 0); in SAMGR_SendSharedRequest()
129 (void)FreeReference(&exchange); in SAMGR_SendSharedRequest()
131 return exchange.sharedRef; in SAMGR_SendSharedRequest()
141 Exchange exchange = {0}; in SAMGR_SendSharedDirectRequest() local
143 exchange.request = *req; in SAMGR_SendSharedDirectRequest()
147 exchange.response = *resp; in SAMGR_SendSharedDirectRequest()
150 exchange.handler = handler; in SAMGR_SendSharedDirectRequest()
151 exchange.sharedRef = *ref; in SAMGR_SendSharedDirectRequest()
152 exchange.type = MSG_DIRECT; in SAMGR_SendSharedDirectRequest()
153 exchange.id = *id; in SAMGR_SendSharedDirectRequest()
154 exchange.id.queueId = NULL; in SAMGR_SendSharedDirectRequest()
155 int32 err = SharedSend(id->queueId, &exchange, 0); in SAMGR_SendSharedDirectRequest()
158 (void)FreeReference(&exchange); in SAMGR_SendSharedDirectRequest()
160 *ref = exchange.sharedRef; in SAMGR_SendSharedDirectRequest()
171 Exchange *exchange = GET_OBJECT(request, Exchange, request); in SAMGR_SendResponseByIdentity() local
172 if (exchange->type == MSG_NON) { in SAMGR_SendResponseByIdentity()
175 exchange->id.queueId = id->queueId; in SAMGR_SendResponseByIdentity()
180 static int32 SharedSend(MQueueId queueId, Exchange *exchange, int initRef) in SharedSend() argument
183 if ((exchange->request.data == NULL || exchange->request.len <= 0) && in SharedSend()
184 (exchange->response.data == NULL || exchange->response.len <= 0)) { in SharedSend()
185 return QUEUE_Put(queueId, exchange, 0, DONT_WAIT); in SharedSend()
190 if (exchange->sharedRef == NULL) { in SharedSend()
191 exchange->sharedRef = (uint32*)SAMGR_Malloc(sizeof(uint32)); in SharedSend()
192 if (exchange->sharedRef == NULL) { in SharedSend()
196 *(exchange->sharedRef) = initRef; in SharedSend()
198 (*(exchange->sharedRef))++; in SharedSend()
201 return QUEUE_Put(queueId, exchange, 0, DONT_WAIT); in SharedSend()
204 static BOOL FreeReference(Exchange *exchange) in FreeReference() argument
206 if (exchange == NULL) { in FreeReference()
213 if (exchange->sharedRef != NULL) { in FreeReference()
214 if (*(exchange->sharedRef) > 0) { in FreeReference()
215 (*(exchange->sharedRef))--; in FreeReference()
218 if (*(exchange->sharedRef) > 0) { in FreeReference()
225 SAMGR_Free(exchange->sharedRef); in FreeReference()
226 exchange->sharedRef = NULL; in FreeReference()