CORBA_boolean
forb_iop_prepare_request(forb_request_t *req,
- unsigned *index,
CORBA_Environment *env)
{
CORBA_boolean ret;
forb_server_id_to_string(str, &req->obj->server, sizeof(str)),
rh.iface, rh.method_index);
}
- *index = req->cdr_request.wptr;
+ req->end_of_header_index = req->cdr_request.wptr;
return ret;
}
size_t len;
forb_iop_message_header mh;
bool header_received = false;
+ int oldstate;
while (!port->finish) {
if (c->rptr == c->wptr) {
/* The buffer is empty now - start writing from begining*/
FORB_CDR_buffer_reset(c, 0);
}
+
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
/* TODO: If there is not enough space for reception,
* we should shift the already received data to the
* beginning of the buffer. */
c->wptr += rcvd;
c->wptr_last = c->wptr;
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
+
/* While there are some data in the buffer, process them. */
while (FORB_CDR_data_size(c) > 0) {
len = FORB_CDR_data_size(c);
- /* Wait for and then process message header */
+ /* Find and process message header (if there is any) */
if (!header_received) {
if (len >= forb_iop_MESSAGE_HEADER_SIZE) {
if (c->rptr % 8 != 0) {
}
}
- /* Wait for and then process the message body */
+ /* If the whole message is received, then process it */
if (header_received) {
if (len >= mh.message_size) {
process_message(port, &mh, c);
}
/**
- * Sends REQUEST message to another FORB.
+ * Sends REQUEST to another object.
*
- * The request @a req has to be prepared by
- * forb_iop_prepare_request(). Then, this function adds a message
- * header, connects to the destination FORB and sends the request.
+ * The request @a req has to be prepared previously by calling
+ * forb_iop_prepare_request(). Then, when the request destination is
+ * remote, this function adds a message header, connects to the
+ * destination FORB and sends the request. In the case of local
+ * request, it is directly enqueued into the executor's queue.
*
* If no exception is reported, then the caller must wait for response
* by calling forb_wait_for_reply().
* @param env Environment for returning exceptions
*/
void
-forb_request_send(forb_request_t *req, unsigned index, CORBA_Environment *env)
+forb_request_send(forb_request_t *req, CORBA_Environment *env)
{
CORBA_boolean ret;
forb_peer_t *peer;
memset(exec_req, 0, sizeof(exec_req));
exec_req->request_type = FORB_EXEC_REQ_LOCAL;
exec_req->input_request = req;
- exec_req->obj = req->obj;
+ exec_req->obj = forb_object_duplicate(req->obj);
exec_req->method_index = req->method_ind;
exec_req->interface = req->interface;
- req->cdr_request.rptr = index;
+ req->cdr_request.rptr = req->end_of_header_index;
exec_req->codec = req->cdr_request;
req->cdr_request.release_buffer = CORBA_FALSE;
exec_req->request_id = req->request_id;