if (ret) {
/* Request body is 8 byte aligned */
ret = FORB_CDR_put_align(&req->cdr_request, 8);
+ char str[50];
+ ul_logdeb("preparing request: id=%d dest=%s iface=%s method=%d\n", req->request_id,
+ forb_server_id_to_string(str, &req->obj->server, sizeof(str)),
+ iface, method_ind);
}
return ret;
}
pthread_cleanup_pop(1);
return NULL;
}
+
+/**
+ * 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;
+ ssize_t size;
+ size_t len;
+ 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 for server %s\n",
+ forb_server_id_to_string(str, &req->obj->server, sizeof(str)));
+ env->major = FORB_EX_COMM_FAILURE;
+ return;
+ }
+ /* Register the request with forb so we can match incomming
+ * reply to this request. */
+ ret = forb_request_insert(forb, req);
+ if (ret <= 0) {
+ ul_logerr("Insert request error %d\n", ret);
+ env->major = FORB_EX_INTERNAL;
+ goto err_peer_put;
+ }
+
+ {
+ char str[50];
+ ul_logdeb("sending request: id=%d dest=%s\n", req->request_id,
+ forb_server_id_to_string(str, &req->obj->server, sizeof(str)));
+ }
+ len = FORB_CDR_data_size(&req->cdr_request);
+ fosa_mutex_lock(&peer->send_lock);
+ size = forb_proto_send(peer, &req->cdr_request);
+ fosa_mutex_unlock(&peer->send_lock);
+ if (size <= 0 || size != len) {
+ env->major = FORB_EX_COMM_FAILURE;
+ /* Request is deleted when the stub calls forb_request_destroy() */
+ }
+ err_peer_put:
+ forb_peer_put(peer);
+}
void *
forb_iop_discovery_thread(void *arg);
+/* TODO: rename to forb_iop_send_request */
+void
+forb_request_send(forb_request_t *req, CORBA_Environment *env);
+
#endif
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, len;
- 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 for server %s\n",
- forb_server_id_to_string(str, &req->obj->server, sizeof(str)));
- env->major = FORB_EX_COMM_FAILURE;
- return;
- }
- /* Register the request with forb so we can match incomming
- * reply to this request. */
- ret = forb_request_insert(forb, req);
- if (ret <= 0) {
- ul_logerr("Insert request error %d\n", ret);
- env->major = FORB_EX_INTERNAL;
- goto err_peer_put;
- }
-
- {
- char str[50];
- ul_logdeb("sending request: id=%d dest=%s\n", req->request_id,
- forb_server_id_to_string(str, &req->obj->server, sizeof(str)));
- }
- len = FORB_CDR_data_size(&req->cdr_request);
- fosa_mutex_lock(&peer->send_lock);
- size = forb_proto_send(peer, &req->cdr_request);
- fosa_mutex_unlock(&peer->send_lock);
- if (size <= 0 || size != len) {
- env->major = FORB_EX_COMM_FAILURE;
- /* Request is deleted when the stub calls forb_request_destroy() */
- }
- err_peer_put:
- forb_peer_put(peer);
-}
forb_request_wait_for_reply(forb_request_t *req);
void
forb_request_signal_processed(forb_request_t *req);
-void
-forb_request_send(forb_request_t *req, CORBA_Environment *env);
-
#endif