]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
forb_request_send() moved to iop.c
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 27 May 2009 15:32:18 +0000 (17:32 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 27 May 2009 19:05:12 +0000 (21:05 +0200)
The reason is that we want all inter-orb protocol related messages in the same
log domain.

src/iop.c
src/iop.h
src/request.c
src/request.h

index 4aa81319c96a4ed2b2599d88c38780fc9b1c8655..90c6e9d533e1badb32745f62302cd913d78bc2c6 100644 (file)
--- a/src/iop.c
+++ b/src/iop.c
@@ -107,6 +107,10 @@ forb_iop_prepare_request(forb_request_t *req,
        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;
 }
@@ -610,3 +614,77 @@ void *forb_iop_discovery_thread(void *arg)
        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);
+}
index 190563c236a8da0c8f58037201b9d6c32ef7ce87..4dc764cfc72e13c510d36a43e4c9517e35a367a5 100644 (file)
--- a/src/iop.h
+++ b/src/iop.h
@@ -88,4 +88,8 @@ forb_iop_receiver_thread(void *arg);
 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
index 5118339d192572a7f3207a1cf444d0d724b4ecf6..b6b1196a76458baefe9e2dabc6d23337c5894124 100644 (file)
@@ -160,75 +160,3 @@ forb_request_signal_processed(forb_request_t *req)
        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);
-}
index 0458760819f071e30017e58ed233109f8a5e64ae..1b1d0fc9c1fa39b4931ee573f2027160c7b74154 100644 (file)
@@ -134,8 +134,5 @@ void
 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