extern UL_LOG_CUST(ulogd_forb_request);
-static inline int forb_request_cmp(CORBA_unsigned_long *a, CORBA_unsigned_long *b)
+static inline int forb_request_cmp(const CORBA_unsigned_long *a,
+ const CORBA_unsigned_long *b)
{
return (*a<*b) ? -1 :
((*a>*b) ? +1 :
* @return Zero on success, FOSA error code on error.
*/
int
-forb_request_init(forb_request_t *req, forb_object obj)
+forb_request_init(forb_request_t *req, forb_object obj, char *iface, unsigned method_ind)
{
int ret = 0;
forb_t *forb = forb_object_to_forb(obj);
memset(req, 0, sizeof(*req));
req->obj = obj;
+ req->interface = iface;
+ req->method_ind = method_ind;
fosa_mutex_lock(&forb->request_id_mutex);
req->request_id = forb->request_id++;
fosa_mutex_unlock(&forb->request_id_mutex);
- CDR_codec_init_static(&req->cdr_request);
- bret = CDR_buffer_init(&req->cdr_request, 256, forb_iop_MESSAGE_HEADER_SIZE);
+ FORB_CDR_codec_init_static(&req->cdr_request, obj->orb);
+ bret = FORB_CDR_buffer_init(&req->cdr_request, 4096-8, forb_iop_MESSAGE_HEADER_SIZE);
if (bret == CORBA_FALSE) {
return FOSA_ENOMEM;
}
void
forb_request_destroy(forb_request_t *req)
{
- CDR_codec_release_buffer(&req->cdr_request);
+ forb_t *forb = forb_object_to_forb(req->obj);
+
+ forb_request_delete(forb, req);
+ //FORB_CDR_codec_release_buffer(&req->cdr_request);
forb_syncobj_destroy(&req->reply_ready);
}
void
forb_request_wait_for_reply(forb_request_t *req)
{
- forb_syncobj_wait(&req->reply_ready);
+ fosa_abs_time_t timeout;
+ int ret;
+
+ /* FIXME: What is the appropriate length for timeout? Maybe,
+ * we can specify timeout in forb_env, but since it is
+ * out-direction parameter, we cannot distinguish between
+ * initialized and uninitialized env.timeout. */
+ fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &timeout);
+ timeout = fosa_abs_time_incr(timeout,
+ fosa_msec_to_rel_time(10000));
+
+ ret = forb_syncobj_timedwait(&req->reply_ready, &timeout);
+
+ if (ret == ETIMEDOUT) {
+ req->env->major = FORB_EX_TIMEOUT;
+ } else if (ret) {
+ req->env->major = FORB_EX_INTERNAL;
+ }
}
void
forb_syncobj_signal(req->reply_processed);
}
-/**
- * Sends REQUEST message to another FORB.
- *
- * 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.
- *
- * If no exception is reported, then the caller must wait for response
- * by calling forb_wait_for_reply().
- *
- * @param req A request prepared by forb_iop_prepare_request()
- * @param env Environment for returning exceptions
- */
-void
-forb_request_send(forb_request_t *req, CORBA_Environment *env)
-{
- CORBA_boolean ret;
- forb_peer_t *peer;
- size_t size;
- fosa_abs_time_t timeout;
- forb_t *forb = forb_object_to_forb(req->obj);
-
- if (!forb) {
- env->major = FORB_EX_INTERNAL;
- return;
- }
-
- req->env = env; /* Remember, where to return exceptions */
-
- ret = forb_iop_prepend_message_header(&req->cdr_request, forb_iop_REQUEST);
- if (!ret) {
- /* This should never happen */
- env->major = FORB_EX_INTERNAL;
- return;
- }
-
- fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &timeout);
- timeout = fosa_abs_time_incr(timeout,
- fosa_msec_to_rel_time(1000));
- peer = forb_get_next_hop(forb, &req->obj->server, &timeout);
- if (!peer) {
- char str[50];
- ul_logerr("Cannot find peer to send request to server: %s\n",
- forb_server_id_to_string(str, &req->obj->server, sizeof(str)));
- env->major = FORB_EX_TRANSIENT;
- return;
- }
-
- ret = forb_request_insert(forb, req);
- if (ret <= 0) {
- ul_logerr("Insert request error %d\n", ret);
- env->major = FORB_EX_INTERNAL;
- return;
- }
-
- size = forb_proto_send(peer, &req->cdr_request);
- if (size <= 0) {
- forb_request_delete(forb, req);
- env->major = FORB_EX_COMM_FAILURE;
- }
-}